Warning: I'm not a java hacker, so YMMV but...
The problem with using a list of "properties" is that you need a lot of discipline. Every time you add a string that should be output to the user you will need to open your properties file, look to see if that string (or something roughly equivalent to it) is already in the file, and then go and add the new property if it isn't. On top of this, you'd have to hope the properties file was fairly human readable / editable if you wanted to give it to an external translation team to deal with.
The database based approach is useful for all your database based content. Ideally you want to make it easy to tie pieces of content together with their translations. It only really falls down for all the places you may want to output something that isn't out of a database (error messages etc.).
One fairly old technology which we find still works really well, is to use gettext. Gettext or some variant seems to be available for most languages and platforms. The basic premise is that you wrap your output in a special function call like so:
echo _("Please do not press this button again");
Then running the gettext tools over your source code will extract all the instances wrapped like that into a "po" file. This will contain entries such as:
#: myfolder/my.source:239
msgid "Please do not press this button again"
msgstr ""
And you can add your translation to the appropriate place:
#: myfolder/my.source:239
msgid "Please do not press this button again"
msgstr "s’il vous plaît ne pas appuyer sur le bouton ci-dessous à nouveau"
Subsequent runs of the gettext tools simply update your po files. You don't even need to extract the po file from your source. If you know you may want to translate your site down the line, then you can just use the format shown above (the underscored function) with all your output. If you don't provide a po file it will just return whatever you put in the quotes. gettext is designed to work with locales so the users locale is used to retrieve the appropriate po file. This makes it really easy to add new translations.
Gettext Pros
- Doesn't get in your way while coding
- Very easy to add translations
- PO files can be compiled down for speed
- There are libraries available for most languages / platforms
- There are good cross platform tools for dealing with translations. It is actually possible to get your translation team set up with a tool such as poEdit to make it very easy for them to manage translation projects
Gettext Cons
- Solves your site "furniture" needs, but you would usually still want a database based approach for your database driven content
For more info on gettext see this wikipedia page
Have you seen CodeIgniter's Language library?
The Language Class provides functions
to retrieve language files and lines
of text for purposes of internationalization.
In your CodeIgniter system folder you'll
find one called language containing sets
of language files. You can create your
own language files as needed in order
to display error and other messages in
other languages.
Language files are typically stored in
your system/language directory. Alternately
you can create a folder called language
inside your application folder and store
them there. CodeIgniter will look first
in your application/language directory.
If the directory does not exist or the
specified language is not located there
CI will instead look in your global
system/language folder.
In your case...
- you need to create a
polish_lang.php
and english_lang.php
inside application/language/polish
- then create your keys inside that file (e.g.
$lang['hello'] = "Witaj";
- then load it in your controller like
$this->lang->load('polish_lang', 'polish');
- then fetch the line like
$this->lang->line('hello');
Just store the return value of this function in a variable so you can use it in your view.
Repeat the steps for the english language and all other languages you need.
Best Solution
For .mo file support, check out the gettext functions, and look at the original GNU gettext documentation.
In a nutshell, anytime you use natural language, you wrap in a call to _() (an alias for gettext)
Once all your sources are doing this, run the GNU Xgettext tool to build a .pot file, which forms the "template" for your language translations. For each desired language, you'd merge this .pot file into an individual .po file for each language. The merge operation, again provided by xgettext, ensures you update the file with new strings, without losing any existing translations.
These .po files get sent to your translators, who might use a tool like poedit to provide the translation. When the .po file comes back, you can generate the binary .mo file which is used by gettext.
There are also classes in the Zend Framework which provide more facilities beyond this too, e.g. more file formats, and detection and selection of user preferred language in HTTP headers.