[Logo] Mentawai Recipes
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 
[Moderation Log] Moderation Log   [Register] Register / 
[Login] Login 
Easy internationalization (i18n)  XML
Forum Index » Official Recipes
Author Message
saoj



Joined: 10/01/2008 08:20:15
Messages: 39
Offline

OBS: Mentawai i18n files are auto-reloadable, in other words, from time to time the file is checked for modifications. If it was modified it is reloaded. That means you do NOT have to restart your web container each time you change some text inside your i18n file.

When the user is authenticated, you set his locale:

Then all you have to do is create a directory i18n and place one file per language in there. Example:

/i18n/master_en_US.i18n

/i18n/master_es_ES.i18n

Then in the JSP you can do:

To better organize your text file you can use prefixes. Example:

/i18n/master_en_US.i18n

/i18n/master_es_ES.i18n

Then in the JSP you do:

If you have a text that is global, for example, the title of all pages, you can skip the prefix by doing:

/i18n/master_en_US.i18n

/i18n/master_es_ES.i18n

An in the JSP:

And there is much more:

You can have localized texts inside your actions.

If the user is not logged, you can pick a locale based on browser request, cookie, etc.

You can use placeholders to help the designer:

You can configure what to do if the key is not found: show the default locale translation or show the key with exclamation marks around it so someone can spot the problem and fix it. (good for QA)
 
Forum Index » Official Recipes
Go to:   
Powered by JForum 2.1.8 © JForum Team