I want i18n application. It has lots of (for me) panels and I'd like to
ease my translation work. What is the better way: point all classes to one
big file with translations (now I made it through static method in main
class of an application) or point every class to its own translation
within its own package? And this is the other thing that makes me do it
one-big-file way - there are many packages and I think it would be easier
to maintain one file then walk through lots of directories
Thanks for any response
>I want i18n application. It has lots of (for me) panels and I'd like to
> ease my translation work. What is the better way: point all classes to one
[quoted text clipped - 5 lines]
>
> Thanks for any response
Have you read the chapter on i18n in the Java Tutorial? This is the link in
case you haven't: http://java.sun.com/docs/books/tutorial/i18n/index.html.
I've used the approach they suggest and found it quite satisfactory. They
certainly don't recommend putting everything in one big file!
I think most Java programs will consist of many different classes in several
different packages; this is almost inevitable if you design Java correctly,
according to the OO paradigm.
In my case, my projects tend to have one package that has the main classes
for the project and that all tends to be in a single package. I also find
myself using a number of different "common" classes in each project. I have
my common classes organized into different categories: panels, error
handling, preferences, utilities, etc. Each category of common classes has
its own package.
Each package used for common classes has a corresponding package for
resource bundles. For example, package com.foo.common.utilities contains
common utility classes. The resource bundles for the classes in this package
are in package com.foo.common.utilities.Resources.
I also have a separate package for the resources used by my main project
classes. If the main project classes are in a package called
com.foo.myproject, the resources for the classes in that package are in a
package called com.foo.myproject.Resources.
I create List, Message and Text resource bundles for each language/locale
that I want to support so I typically have a separate List, Message, and
Text resource bundle for English, French, and German. (On some projects, I
have had separate bundles for English Canada, English US, English UK, French
Canada, French France, German Germany, German Switzerland and German
Austria. But that was just a little demo project where I wanted to practice
using i18n.)
Organizing things this way is very beneficial for my common code; each
common class can support different languages than the others and I only have
to translate phrases that are relevant to that class. But putting all of the
locale-sensitive information for the main project in just three resource
bundles, the List, Message, and Text bundles, means that I have to manage a
lot of different files for the main work of the project. I would not really
want to make a separate resource bundle for each dialog and panel in the
main application but I suppose I could live with that if it was the shop
standard for an employer.
Just my two cents worth; I'm sure other people do things differently!
--
Rhino
I tend to have a one List resource bundle, one Text resource bundle, and one
Message resource bundle for each language/locale that is