PKP Bugzilla – Bug 5269
Performance optimization: create single optimized translation cache
Last modified: 2012-09-21 13:11:56 PDT
Profiling shows that up to 30% overall request execution time is spent in the Locale::translate() method.
- highly fragmented translation files (and translation cache files)
- loop over all translation files for each translation key (including full cache timeout check with only that causing 5 file/inode accesses per file and translation key!)
- build a single cache of all translation keys
- enable in-memory caching for translation keys
- do cache timeout check with a single inode access (current system time - mtime) and only once per request
Florian, I've also been toying around with the idea of namespacing for translation keys. This would help keep everything organized more logically, too. That way, we could map a prefix to a particular file rather than searching through them all sequentially.
Translation should be based on a performance optimized and proven technology like the gettext library. Translation strings could probably quite easily be translated into .po/.mo files for release. AFAIK gettext is much faster than alternative I18N solutions from Zend or PEAR. As gettext is based on the same "message id" or "message key" principle as our translation system it might be easy to use it internally. A bit of thought needs to be invested for string replacement. Gettext has of course very flexible mechanisms in place for that but they differ a bit from our approach.