Internationalization

  Defining locales and properties files
  How internationalization works
  Changing locales

RADi makes it easy to internationalize projects using properties files and ResourceBundles. All you will have to do is, edit (translate) the properties files RADi generates.
Tip: You should not start internationalization until (you think) the GUI is finished so far.


Defining locales and properties files     Top of page

To open the Define Properties Files dialog, select 'I18n | Define Properties Files'.
First, select the locales, you wish to support. If the default locale doesn't match your intended default locale, change it.
From the table's support column, select the objects, you wish to internationalize and, for every object, select the language-dependent properties. If no properties files have been generated before or to update all properties files, select Save properties files.
To update properties files for a distinct object, click inside the Object column.

Generated properties files go to the i18n directory inside the project directory. If you package an internationalized application into a JAR, don't forget to include the i18n directory.

Note: If you internationalize additional items (e.g. dialog titles or dynamic messages), then create your own properties files, do not use the one generated by RADi.


How internationalization works     Top of page

If you never heard about ResourceBundles or properties files, you might want to study the "Internationalization Trail" of SUN's "Java Tutorial".

Suppose your supported locales are English(en), Spanish(es) and German(de), you want to internationalize labels and menus and the default locale is Spanish(es). Then RADi will generate the following properties files:
LabelBundle.properties - this is the default properties file for labels, it contains the spanish translation.
LabelBundle_en.properties - the english translation for all labels.
LabelBundle_de.properties - the german translation for all labels.
MenuBundle.properties - this is the default properties file for menus and menu items, it contains the spanish translation.
MenuBundle_en.properties - the english translation for all menus and menu items.
MenuBundle_de.properties - the german translation for all menus and menu items.

Lets take a look at the generated MenuBundle properties files (after translation). Every line starts with a key, followed by an equals sign, followed by a (string) value:
 MenuBundle.properties  MenuBundle_de.properties  MenuBundle_en.properties
 ...  ...  ...
 i18n.menu0.mnemonic = A  i18n.menu0.mnemonic = D  i18n.menu0.mnemonic = F
 i18n.menu0.text = Archivo  i18n.menu0.text = Datei  i18n.menu0.text = File
 i18n.menu1.mnemonic = E  i18n.menu1.mnemonic = B  i18n.menu1.mnemonic = E
 i18n.menu1.text = Editar  i18n.menu1.text = Bearbeiten  i18n.menu1.text = Edit
 i18n.menu2.mnemonic = Y  i18n.menu2.mnemonic = H  i18n.menu2.mnemonic = H
 i18n.menu2.text = Ayuda  i18n.menu2.text = Hilfe  i18n.menu2.text = Help
 ...  ...  ...
The key is made out of the layout name (i18n), the variable name (menu0, menu1, ...) and the property name (mnemonic, text, ...).
The value is a textual representation of the property's value.

As your application runs, the RADi runtime asks the JVM for the ResourceBundles corresponding to the user's locale. Then the runtime will set component's properties to the one it gets from the appropriate ResourceBundle.

RADi makes some effort to keep properties files in sync with the layout. For example, everytime you change a component's name, RADi checks properties files to see, if the name is part of a key in one of those files. If it is, RADi displays this dialog:
(You will see a similar dialog if you try to delete components whose name is part of a key.)

As you try to change a property already defined in properties files, you will see a dialog similar to this one:

If you try to remove a property defined in a properties file (by double-clicking the property name in the property sheet), you will see this dialog:
(It wouldn't make much sense to choose Proceed, because, though the property is still defined in one or more properties files, it will not be loaded, only properties set to non-default values are loaded from properties files.)
Note: Internationalized actions and tab data are special cases. RADi does it's best to synchronize internationalization information and if you are somewhat conscious of what you are doing, everything should work well.


Changing locales     Top of page

From the 'I18n' menu you can select ResourceBundles for a distinct locale (out of the list of supported locales) which then becomes the current locale.
If you do so you will see the localized GUI:
Example 23  Localized Example

Note: R-Bean instances will not be affected by a change of the current locale (see R-Beans and Internationalization).

See: The RADi runtime library about how to test your applications with various locales.