01 April 2011

I wrote this module to help me with the localization of our application. I used to have similar tool in our old struts based system, so I first copied it to play and later rewrote it all together. I even forced myself to learn regexp, which I have been trying to avoid so far ;).

Setting up

To add this module as dependency of your application, add it to the dependencies.yml file:

require:
    - play -> carbonate {version}

Then you need to add the module routes to your application conf/routes file:

   *    /    module:messages

Now once you restart your application you can access the tool at http://localhost:9000/@messages

Example 1: Managing existing keys

This is the tab where you can modify the existing keys, keys that are found in sources and messages. Header section has selection for the language to edit and another for the language to compare to. Keys can be removed by checking the remove check box.

The keep check box is reserved for valid keys that the tool doesn’t find in the sources, for example keys that are generated in code.

Example 2: Localizing new keys

New keys are those keys that are found in the sources but are not yet localized in the messages file for the selected language.

Since we are not sure about the first key we click on the key to check the sources. From the sources we can see that this key is in fact part of a generated key. We choose to ignore this key, meaning that it will no longer be shown in the new keys list in any language.

After save we can find the key in the ignored keys section. Ignored keys are saved in the messages.ignore file.

Example 3: Separating generated keys from obsolete keys

Obsolete keys are those keys that are in the messages file, but cannot be found in the sources.

We mark keys that are valid with the keep check box. These keys will be added to the keep list and will be displayed among the existing keys. The keep list is saved in messages.keep file.

Keys that are old can be removed by checking the remove check box.

References

You can find the sources at github here https://github.com/huljas/play-messages.



blog comments powered by Disqus