Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...

When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Creating TMX source files

TMX source files are a new industry standard. They have the advantage of being XML files and so they are readable by every editor and of course by humans. You can either create TMX files manually with a text editor, or you can use a special tool. But most tools currently available for creating TMX source files are not freely available.

Example 965. Example TMX file

<?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" >
       <tu tuid='message1'>
           <tuv xml:lang="de"><seg>Nachricht1</seg></tuv>
           <tuv xml:lang="en"><seg>message1</seg></tuv>
       <tu tuid='message2'>
           <tuv xml:lang="de"><seg>Nachricht2</seg></tuv>
           <tuv xml:lang="en"><seg>message2</seg></tuv>
= new Zend_Translate(
'adapter' => 'tmx',
'content' => 'path/to/mytranslation.tmx',
'locale'  => 'en'

TMX files can have several languages within the same file. All other included languages are added automatically, so you do not have to call addLanguage().

If you want to have only specified languages from the source translated you can set the option defined_language to TRUE. With this option you can add the wished languages explicitly with addLanguage(). The default value for this option is to add all languages.

Option useId

When you set the useId option to FALSE then the srclang header will be used to define the language which sets the message.

In our example the message key would message1 per default. When this option is set to FALSE the message key Nachricht1 would be used.

Note that the tuv entry which is related to the srclang entry must be the first tuv entry which is set like shown in the above example.

Zend Framework