I will shortly describe the systems available and what speaks in my eyes for and against them:
1. The current system (constants)
The current system is simple: Loading every possibly needed string as a constant which is afterwards globally available.
Pro:
- Easy to understand
- Plain text, easy to edit
- Tools in place, and code wouldn't need to get changed
- As fast as a constant-lookup in PHP
- The code loading that is a bit cumbersome, for example the include/lang.inc.php is included twice in serendipity_config to load the language
- A mix of custom charsets and UTF-8 (in my eyes, it's time for a UTF-8 solution)
- On every load of serendipity, all those constants are fetched from the file and loaded into memory. According to my test, this costs about of 1,25 MB (checked with memory_get_usage(true) directly for and after the second include - if someone knows a better way to measure that, please speak up). Depending on the perspective, that is either a lot (for mere language constants) or negligible (compared to ram available on modern systems)
- As fast as a constant-lookup in PHP
That looks like a pretty simple system. Translations are stored in .ini-files, it includes a system for automatic language detection (which can be overwritten) and caching is integrated as well. Glancing over the code, it seems to work by translating the ini via parse_ini_file into an associative array, caching that step, and creating an object containing the translated strings.
Pro:
- Plain text, easy to edit
- Having the translations enclosed in its own array prettier than having them as constants
- Could be a bit faster
- I don't think it would save any memory compared to the current system
- Lots of changes necessary
- Speed difference probably minimal
Gettext is the professional and right way to do something like this. That said, I personally don't like that system very much, I try not to let affect that my judgement too much. It translates .po files into binary mo-files, which could be the fastest option if done right.
Pro
- Probably fast
- Proven, widely used system
- compilation step necessary
- Lots of changes necessary
- Is the gettext-extension available on every target system (guess it should be, and there is a fallback: https://launchpad.net/php-gettext/)
A new PHP-API for internationalization, probably also somehow useable for our purposes, but I understand exactly nil of the documentation. But if someone has an understanding of that system, maybe it is an option as well.