How can I create localization modules using Maven?

If you have localized versions of resources in your own modules, you can simply place them alongside the base version; for example, src/main/resources/my/module/ would provide a German translation of src/main/resources/my/module/

But to localize other people's modules, then as explained in Physical Placement of Localized Resources you will need to create modules/locale/*_*.jar JARs with the localized resources. (Simply bundling localized resources in your own module will not work, because these are usually searched for starting with the original module's ClassLoader, which cannot "see" your modules.)

The simplest way to do this is to use the existing nbm:branding goal, which despite its name can handle localization as well as branding. (These are nearly interchangeable in the NB Platform.) demonstrates how to localize parts of the Options dialog to Czech. Take note of:

  • lokalizace/pom.xml asks to use this goal when building the module. It overrides the "branding token" (otherwise inherited from the parent POM) with your locale identifier. (Specifying this custom execution is required in the 3.3 plugin; future versions may run the goal automatically during the package phase when there is anything to process, but you would still need to declare the locale in your plugin configuration.)
  • lokalizace/src/main/nbm-branding/ contains the actual localizations.
    • Localizations must be grouped by module to be localized, under a folder path matching the path of the original module in its cluster.
    • The locale suffix (_cs in this case) is inserted automatically by the build, so the source file should be named simply
  • application/pom.xml specifies --locale cs so that you can quickly test the localization just by running the app.
  • It also turns on NbBundle debugging mode when requested by a special profile. This can be helpful to pinpoint where a particular English string is coming from: every visible string will be annotated with a bundle number (cross reference with console output) and line number. You can also use the Search field in the branding editor (available from the context menu of lokalizace) to find all potentially localizable strings in the Platform matching some keyword; this editor also creates the right folder structure for you automatically when localizing new bundles.

The module bundling the localizations can now be included in your app, or distributed by any other means. When the specified locale is active, your localizations will be applied.

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo