I18n convention : key naming and layout

Hi,

I'm quoting an archived post that did not receive answers and i agregate a few ones :

-"I'm thinking of introducing I18N into my project, which is fairly large now, and is continually growing at quite a quick rate, but I'm unsure as to the best wya to implement it.

I know about the details of loading the strings and such, but what do you recommend for laying out the code/resource bundles? What's your experience on this subject?

For example should each class have it's own properties file, and load this from within the actual class, say as a static final variable. Or each package delegate to one central properties file, creating a new class per-package to load up and retrieve strings? Also, where to place the properties files, place them in with the java source files, or in a separate folder, with a folder structure that seems 'logical'(opposed to in package structure)?"

-Are you loading resouce from one central class or calling resourceBundle.getBundle in each internationalized class ?

-Which resource key naming convention are you using ? I figured out two ways :

- mypackage.myclass.button.save_report : pros = clear, hierarchizable / cons = information for reverse ingeneering, no centralization of commons keys such as "OK" or "Cancel", etc.

- save_report : pros/cons inverted

Thanks for sharing your experience !

Message was edited by:

gl-sub

[1446 byte] By [gl-suba] at [2007-11-26 22:39:43]
# 1

In general, I use the following rules when creating bundles:

* create a bundle for groups of related functionality/screens/ui. This typically means a bundle per package...a nice, natural division.

* generally, I load resources in the class that requires them. However, I can see the appeal of loading them from a "controller" class that might pass the bundle out to other classes in its same package.

* for naming, I don't bother with the full package_name.class_name.button.save_report notation. Why? Well, I'm already creating a bundle for each package...no need for it in the keys too, but I don't see any strong reason not too. I think the most important thing is to give the key some context...like BUTTON_SAVE_REPORT or button.save_report. That's informative.

Regards,

John O'Conner

joconnera at 2007-7-10 11:53:00 > top of Java-index,Desktop,I18N...