Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.
For a while now I've been wanting to support localizations/translations within my framework - but I just can't decide on the best way of doing it! The frameworks use is the backend of an open-source CMS I'm developing if that's any relevance. Anyway, here are the ways I can think of for localization:
Gettext
Advantages:
There are many web based (Launchpad for example) tools out there to help with translating the .po files (also a lot of applications as well)
It's the fastest way (after looking at some benchmarking) to provide localization
Disadvantages:
Requires the server to have the correct Locales installed
Requires PHP to be compiled with gettext support
Have to re-generate .mo files once you have edited the .po files - and if people want to just tweak a string and they don't have the tools to create the .mo it could be tricky
PHP Gettext (Gettext implementation written in PHP)
Advantages:
Again many web-based and applications to help translate .po files
Doesn't require the server to have Locales installed
No need for PHP gettext extension
Disadvantages:
Quite slow
Again, have to re-generate .mo files
Ini/XML File
Advantages:
Simple to use
No need to convert to another file type, just edit it and off you go!
Fast
Disadvantages:
No web-based or application to help translations
What do you think I should go with? I would really like to use the Translations part of Launchpad since I already use it a lot of Bugs and Features (Blueprints), it would make it a lot easier for people to translate my CMS - but is it worth using gettext just for that? Help!
I _could_ support the first 2, however supporting all 3 would be a bad move. It would mean the translators would have to edit 2 lots of files, in 2 different places.
ini/xml can be used for personal tweaks while gettext can be used for more "official" changes. It should be possible to mix the two by allowing the ini/xml override lines in the official text.
You can't override the lines in the mo file, there is no way of getting to the strings of the .mo file other than trying to translate via _() or gettext() etc.
Ah I see what you mean, Feyd - I'll look more into that.
My only concern with using Gettext is the server has to have the locales installed - if it doesn't, it will show the strings in English, how likely is it that servers don't have the correct locales installed?
PHP Array : Small pages; simplest usage; only for programmers
Csv : Simple text file format; very fast; possible problems with unicode characters
Gettext : GNU standard for linux; very fast; thread-safe; needs tools for translation
TMX : Industry standard for inter application translation; XML format; human readable
QT : (qt linguist (*.ts) files) Cross platform application framework; XML format; human readable
XLIFF : A simpler format as TMX but related to it; XML format; human readable
Others : *.sql, *.tbx, *.qt
Not sure if it is of use but may provide inspiration of other things to look at. In a lot of systems a combination of methods may work best.