Wednesday, 28 December 2005« A contribution to JSON-RPC-Java | Main | General considerations inspired by Ruby on Rails »
A while ago I sketched a solution to localize the blojsom public
interface but I haven't time to write about it until now. So, for anyone that could find it useful:
the solution is based on ResourceManager and doesn't require any modification to source code.
It uses the Velocity dispatcher and:
- a couple of specific velocimacros that should be added in
- a set of properties files with messages' translations named
lMessages_<language_code>.propertiesand placed in
If a user wants to be newfangled, he can add personal translations in files named
- localized Velocity templates;
- the DateFormatPlugin to format the dates of comments and trackbacks. In fact, differently from
org.blojsom.blog.BlogEntry, the classes
org.blojsom.blog.Trackbackdon't have a method
getDateAsFormatwith a parameter of type
The translation's file is choosen depending on the language code specified in blog configuration.
At http://superfluo.org/blojsom-resources/ you can find:
- blojsom-l-messages.tgz, contains the velocimacros and properties files with standard (English) strings and (my opinable) Italian translations,
- blojsom-asual.tgz, contains localized Asual theme,
- blojsom-grid.tgz, contains localized Grid theme.
To localize your Asual theme, simply:
- configure conveniently DateFormatPlugin,
tar xzf blojsom-l-messages.tgz in WEB-INF/classes,
- if your desired language code is different from en
or it, add in
WEB-INF/classesa new resources file named
- substitute standard Asual templates and resources with the localized ones in
- restart servlet container.
Why not to simply create different templates for different languages? Because, in my opinion:
- it's easier to mantain a set of message sources than a set of templates. This is a crucial point for blojsom developers but is unhelpful for us users :-) ,
- in this way, the blog's owner can change the language with a very simple operation that can be done also by inexperienced users. This could be important in many situations, expecially when new blogs are added frequently.
- many (harmless) ERROR log messages are generated by the attempt by velocimacro
lMsgFto read a user messages file, when this last one is missing.