Geertjan's Blog

  • April 22, 2011

Runtime Swedish/English Language Switching (Part 2)

Geertjan Wielenga
Product Manager
In part 1 I showed how to get started creating a runtime language switcher in your NetBeans Platform application so that the end user can (without a restart) switch from one human language to another, such as from English to Swedish and back.

A starting point is to download the community translated version of NetBeans IDE. I.e., go to the NetBeans download page, choose the human language you're interested in from the "IDE Language" drop-down and then download the IDE. Two binaries exist. The official binary, which includes en + officially supported languages (ja,zh_CN,pt_BR and ru) and the community binary, which includes the community-translated languages, which includes, among several others, Swedish (sv).

Once you've got the IDE of your choice, build on top of that, using "--locale sv" in the "run.args.extra" key in "platform.properties", if you'd like to deploy your application in Swedish mode. Also use the tricks shown in part 1, together with those referred to there from Toni's blog, to refresh the UI after the runtime language switch has been made.

Now, once you've translated everything (and make sure to take a look at i8nchecker, you might need it somehow and it's good to know it's there), you'll need to include only the NetBeans Platform's Swedish JARs (and not also all the other translated JARs from the community binary) in your distribution. Here's how, thanks to an e-mail I received today from Johan Walter from Mercur in Sweden:

<target name="copy-cluster" description="Copies cluster specified by basedir to dir ${dest.dir}">
<pathconvert property="cluster.name">
<path path="${basedir}"/>
<mapper type="regexp" from="[/\\\\]([\^/\\\\]+)([/\\\\]build[/\\\\]cluster)?[/\\\\]?$" to="\\1"/>
<copy todir="${dest.dir}/${cluster.name}">
<fileset dir="${basedir}">
<filename name="\*\*/lib/nbexec\*"/>
<selector refid="zip.platform.included.files"/>
<touch file="${dest.dir}/${cluster.name}/.lastModified"/>
<condition property="copy.nbexec" value="true">
<matches pattern="\^platform[0-9]\*$" string="${cluster.name}"/>
<antcall target="copy-nbexec"/><copy todir="${dest.dir}/${cluster.name}">
<fileset dir="${basedir}">
<filename name="\*\*/locale/\*_sv.jar"/>


The section in bold above needs to be added to the "copy-cluster" target in the "suite.xml" of your application, which is shown in its entirety above. What you then end up with, once you create the ZIP from the IDE (or command line via Ant target) is several folders named "locale", containing "_sv.jar" files.

If you want to predefine for the end user the locale they should use, refer to this blog entry, which tells you about "app.conf" where you can specify your own ".conf" file in which you'll have "--locale sv" in "netbeans_default_options".

Join the discussion

Comments ( 2 )
  • Benjamin Ihle Thursday, July 14, 2011

    Hi Geertjan!

    My colleague and me are writing a NetBeans RCP application based on NetBeans Platform 7.0. We need to deploy this application via Java WebStart which all works fine with NetBeans 7.0. But the default locale of the application shall be German and not English.

    Although we already managed to start the NetBeans 7.0 IDE in German language (manually deployed the nb70_platform_l10n.zip to the NetBeans installation folder) and added the parameter "run.args.extra=--locale de:DE" in the project.properties file we do not manage to get the app starting via Java WebStart in German language.

    Do you have any idea? Is it possible to do that?

    kind regards,


  • guest Tuesday, January 28, 2014


    i apply your work. but the menu bar is not change the language.

    i think that i should add key to the platform.properties.


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.