What developers need to know/do
Hudson's i18n support has two aspects that developers need to be aware of.
- Generation of type-safe
- Marking messages in jelly files
Hudson uses localizer to generate classes for accessing message resources in a type-safe way. For each src/main/resources/**/Messages.properties, a Messages class is generated. See the referenced page for how this class looks like. If your IDE fails to find these classes, manually add "target/generated-sources/localizer" directory to your source root.
Wherever the code returns a String for display purpose (such as
Descriptor.getDisplayName()), use the Messages class to obtain a localized message. At the runtime, a proper locale is selected automatically. A typical workflow for this is as follows:
- You identify messages that need be localized
- You place that in Messages.properties. One can choose to have this file for each package, or you could just have one such file for the whole module/plugin.
- You run
mvn compileonce to re-generate
- Update your code to use the newly generated message formatting method
As usual, looking at how the core code does this might help you get the idea of how to do this.