Our current game plan with First EMT is to build a Javascript and PHP web application so I've been looking at ways to do internationalization in PHP. If you're writing code that needs to be accessible in many different languages, internationalization is a must. Instead of hard coding text you create a variable for every body of text in your interface. Then you store translation files for every language your UI must support. By changing your locale variable you can quickly and easily switch the language your UI displays. If you make the translation files human readable it is also very easy to add new languages by simply hiring a professional translator for a few hours of work.
My first searches seemed fruitful... I found this documentation describing Resource Bundles. It seemed great until I noticed it was under the header "Future Directions". I'm a fairly proficient programmer but I'm certainly not ready to write a patch to PHP... time to look at other options...
The best option I've found so far is called Zend_Translate. Zend's translate framework is really flexible. You can provide something as basic as arrays of words to translate or as complex as importing a Translation Memory file and dynamically translating everything. For my purposes I think I'm going to use the TMX adapter. TMX is an extension of XML and it's an industry standard for this sort of application. It can be modified in any XML editor which makes it very easy to add new translations. An example TMX file would be something like:
- <?xml version="1.0" ?>
- <!DOCTYPE tmx SYSTEM "tmx14.dtd">
- <tmx version="1.4">
- <header creationtoolversion="1.0.0" datatype="winres"segtype="sentence"
- adminlang="en-us" srclang="de-at" o-tmf="abc"
- creationtool="XYZTool" >
- </header>
- <body>
- <tu tuid='message1'>
- <tuv xml:lang="de"><seg>Nachricht1</seg></tuv>
- <tuv xml:lang="en"><seg>message1</seg></tuv>
- </tu>
- <tu tuid='message2'>
- <tuv xml:lang="de"><seg>Nachricht2</seg></tuv>
- <tuv xml:lang="en"><seg>message2</seg></tuv>
- </tu>
- </body>
- </tmx>
No comments:
Post a Comment