You've made the choice (or it was made for you), that your current site or the next project, has to support several languages. You've done your research and found a lot out there, but not all of it as easy as it appears. Some questions that may have crossed your mind could include:
- How do you manage the text?
- How do you get all the text out of all your libraries and templates?
- Where should the text be stored and in what format?
- What about performance impacts?
- Just how is the text translated?
In this tutorial we will look at answering most of these questions and more and how the Scorpio Framework can assist you.
First a little background on the translation system.
Like most developers, we behind Scorpio had to research multiple language systems in PHP that implement translation. The main requirements being flexibility and supporting PHP5. There are numerous types including PEAR extensions as well as the gettext() PHP extension. In fact, there are so many options it can be difficult to know where to begin. Ultimately quite a lot of time was spent looking into several solutions with the Zend Framework proving to be the most useful implementation. The Scorpio translation system is thus based on Zend_Translate with a few additional patches, updates and tweaks to accommodate Scorpio.
The primary benefit of the Zend system is the presence of multiple adaptors for a variety of translation formats including gettext, simply array / ini files as well as XLIFF, XML and other XML formats. Some of these formats are quite complex, others relatively simple.
With that behind us, the first decision to make is which format your language files will be stored in.
- Choosing a storage format
- Building templates for translation
- Building a language resource file
- Testing the site
- Performance considerations
- Finishing up
This work is licenced under a Creative Commons Licence.