| Version 1 (modified by robert, 6 years ago) |
|---|
Creating the JavaScript Message Files
After all translations have been done you need to convert them into JavaScript message files which will be used by the Jala I18n library to translate the messages in the application code and skins. For this the build script in Jala HopKit? provides a second task called "messages". Start the script using the following commandline:
build.bat messages
After issueing the command you'll be first asked to specify the directory containing the PO files with the translated messages. The file names must follow a certain convention:
language[_COUNTRY][_variant].po
"language" must be a two letter lowercase ISO code. The country part of the file name is optional and must be a two letter uppercase ISO Country Code. The variant is also optional and can be freely defined. In any case the extension of the file must be ".po" to be recognised by the script.
The second thing the script will ask you for is the path to the directory where the generated JavaScript message files should be placed.
An finally, you can specify an optional namespace where the object containing the messages will be placed. The script will create one JavaScript file for each locale, containing a plain object literal with the messages, where the message key is the property name, and the value of the property is the translation. Each of these message "catalogs" will be placed by default in a global object called "messages", with the locale key (eg. de_AT) as property name and the message catalog object as value. By specifying a different namespace when running the generator script you can place the messages object in a property of a different object. This way you can avoid cluttering the global namespace. Eg. when defining "jala" as namespace the message object containing the different catalogs will be located in global.jala.messages.
After that the script will start to parse and create the JavaScript message catalog files.
Using build.properties
Always answering the questions of the Jala HopKit? script to create the PO file template or the JavaScript message catalog files can be quite tedious. To make things easier you can place a file called build.properties somewhere (preferably in the root of your application directory), containing pre-defined arguments to the scripts. A sample build.properties file looks like this:
############################################# ## Properties used by "pot" task ## ############################################# ## the name of the template file to create ## (including any relative or absolute path) i18n.template = ./i18n/messages.pot ## the directories to scan for gettext function ## and macro calls (separated with spaces) i18n.scan = ./code ./skins ############################################### ## Properties used by "messages" task ## ############################################### ## the directory containing the .po files to compile ## into the messages.jar (MUST be an absolute path!) i18n.poDirectory = /helma/apps/myApp/i18n/ ## the path to the directory where to put the messages.jar ## (MUST be an absolute path!) i18n.destination = /helma/apps/myApp/code/Global/i18n/
![(please configure the [header_logo] section in trac.ini)](/jala/chrome/common/trac_banner.png)