How do I - Localization and Internationalization (l10n, i18n) - Transcript.pdf
1. How do I?
In this short video we’ll discuss some of the core concepts of internationalization and localization which are often abbreviated as i18n and l10n. We’ll start by defining
these two big terms. Internationalization is the system of making an application adaptable to the various locales which means the application will be flexible when we
need to make it work for users in different countries.
2. I18N & L10N
Internationalization & Localization
In this short video we’ll discuss some of the core concepts of internationalization and localization which are often abbreviated as i18n and l10n. We’ll start by defining
these two big terms. Internationalization is the system of making an application adaptable to the various locales which means the application will be flexible when we
need to make it work for users in different countries.
5. Localization of a Codename One application starts in the designer tool. Open the theme.res file for your application and select the localization section. You can add a
resource bundle here to set the keys and values.
6. You can add additional locales using this button. In this case I added the iw locale.
7. Notice that the text is translated in the iw column. In this case it’s pretty simple to just edit the column value in the table.
Notice the last highlighted row which uses the @rtl notation. That’s a special case marker indicating whether the language is a right to left language. Notice that the iw
locale is marked right to left, we’ll discuss RTL languages soon
8. But first check out the buttons in the bottom. With these you can add, remove or rename complex properties in the tool
9. Moving on to the code lets review this line by line
10. We get the language from the localization manager tool, this is a short iso code for the language and not the actual string name
11. It should be lower case and non-null by default but I’m just playing safe here…
12. The locale sometimes changes iso codes so some platforms might still be using the old “he” code instead of the newer “iw” code.
13. There are two important methods here. First is set bundle, we set the key value pairs for the current language. The second is getL10N where we get the localization
bundle for iw from the theme.
Notice we ignore English as that is the default language for the application.
14. Now here is a really neat trick to test this. Right click the project and select project properties
15. In the IDE’s project properties you can set the vm arguments passed to the simulator and manipulate the language of the JVM. This makes debugging localization very
easy. Just enter the run section and add the build hint -Duser.language=iw and it will become the language of the JVM. This saves you the need of updating your OS
localization settings to debug locale issues
18. If we look at the UI of the restaurant app in bidi mode we can see several cases where this behaves as expected. The menu and play button are reversed. But notice the
play button points in the opposite direction, that’s exactly one of those nuances we need to pay attention to as the icon itself should be flipped for bidi. Notice that all the
text is aligned to the right as well instead of the left.