Internationalization with NetBeans

April 6, 2012 - Words by Marjan Šterk

April 6, 2012
Words by Marjan Šterk

The NetBeans rich client platform supports very well the i18n of your modules, but we will address two specific problems here.

Localization of Platform Strings

If your have the misfortune that language is not supported in the platform by default, you also have to translate any platform strings visible from your application. For development, a good option is to:

  1. Create a new cluster and set its branding to e.g. sl for Slovenian.
  2. Right-click it, select Branding, go to Resource Bundles tab, and search for each English string that appears in your application. If you find it, it is part of the platform and you can translate it right there.
  3. Make your application dependant on this new cluster, re-build, run. Note that the locale must be sl right from the start in order for your branding to work as replacement for locale.

To deploy:

  1. Remove dependency of your application on the sl-branded cluster.
  2. Build your sl-branded cluster.
  3. Copy the contents of build/cluster/core/locale to the core/locale folder of your NetBeans platform, and similar for the build/cluster/modules/locale folder. Now your platform sort-of supports your language.
  4. Re-build your application (it will be re-built with your modified platform) and re-package it however you want.

Note that it is also possible to include a copy of the platform into your project’s folder tree, so that all developers build against the same copy of the platform. If your project is set up like that then the platform modifications you made will be visible to all the developers as soon as they update their working copies.

Localizing the Splash Screen

This is something that is AFAIK not really supported, so we will use a slight hack. The default splash image location is branding/core/core.jar/org/netbeans/core/startup/splash.gif - let us suppose you have your English splash screen there. First, save you localized splash into the same folder, e.g. as splash_sl.gif for Slovene. If you now build and package the application as ZIP distribution, the localized splash will be there (in the folder app.name/app.name/core/locale/core_app.name.jar), but it will not be used because during building it was renamed to splash_sl_app.name.gif where it should be splash_app.name_sl.gif. You can manually re-name it in the created distribution, or modify your build script to do it automatically, and voila, the localized splash will be used whenever the application is started with the -J-Duser.language=sl option!


Social media

Keep up with what we do on our social media.