org.sonar.api.i18n.I18n is available for server extensions. Batch extensions are not supported yet and can not load bundles.
How to localize a plugin
create a Language Pack for the Sonar Community
A Language Pack defines bundles for the Sonar Core Platform and for Sonar Community Plugins. The easiest way to create a new pack is to copy the French Pack and to adapt it to your language.
From there, you can regularly check bundles from:
- The English Pack - which contains all the bundles of the Sonar Core Platform that should be translated (you are not obliged to translate them all at once, you can proceed with baby steps)
- The following Sonar Community Plugins which support L10n (as of August 2012):
- Tab Metrics
- Useless Code Tracker
- Violation Density
- Widget Lab
How to localize an independant plugin
This part applies if you are developing a commercial / closed-source plugin, or an open-source plugin that is not part of the Sonar Community Plugins.
Such plugins must embed their own bundles. Bundles must be added to src/main/resources with the following convention names :
- Standard messages : org/sonar/l10n/<plugin key>_<language>.properties
- Rule descriptions :
- Up to Sonar 3.0: org/sonar/l10n/<plugin key>_<language>/*.html
- Since Sonar 3.0: org/sonar/l10n/<plugin key>_<language>/rules/<repository key>/*.html
The english default bundle is mandatory, and must be the English translation. For example the plugin with key "technicaldebtmysonarplugin" must define the following files in order to enable the french bundle French translation:
How to create a language pack
A language pack defines bundles for the whole Sonar distribution.
To create a new pack, it's recommended to copy the English bundles and to adapt them to the new language.
The language pack plugin must be executed in the same classloader than the English pack, so the property "basePlugin" must be set to "l10nen" into the configuration of sonar-packaging-maven-plugin (see example).