SWAMP is localized using the commons-gettext library, which uses standard .po files.
By calling
bin/generate-po.sh
.pot files will get created for webswamp and swamp-core at
conf/i18n/keys.pot
and webapps/webswamp/conf/i18n/keys.pot
.
Based on this .pot file you can create a translation file using a
GUI editor, for example kbabel. When building SWAMP, the available .po files will automatically
get installed. (You have to add the available languages to build.xml and
webapps/webswamp/java/de/suse/swamp/modules/screens/Preferences.java at the moment)
To use localized texts in the code, you have to create an instance of:
de.suse.swamp.util.I18n
like this:
I18n i18n = new I18n(getClass(), "de.suse.swamp.webswamp.i18n.Webswamp"); |
(replace the second parameter with:
de.suse.swamp.webswamp.i18n.Swamp
when
calling from swamp-core code)
Then, each usage of:
i18n.tr("text to translate", user) |
will get trasnlated into the users preferred language and:
i18n.tr("text to translate") |
will get translated to the configured default language of the system.
If a text is not available in the .po file, the text from the method call
will be returned.