Now on to the (exciting?) part of testing that the translation is working. We've marked up our site, extracted the language data and (perhaps) made some partial translations.
First step - visit the site again in development and... chances are you are seeing all the {t}{/t} text (at worst) or you get an error that there is no such tag.
This is because the internationalisation is disabled by default and we need to configure it in the site config.xml file. Open this and then add a new section: i18n. The following parameters will need to be set:
Your config may look something like the following example:
<section name="il8n" override="1">
<option name="active" value="true" />
<option name="identifier" value="t" />
<option name="defaultLanguage" value="en" />
<option name="adaptor" value="xliff" />
<option name="adaptorOptions" value="disableNotices=true|scan=directory" />
</section>
adaptorOptions are documented in the API docs for translateAdaptor, however they are listed below:
| clear | clears already loaded data when adding new files |
| scan | searches for translation files using the SEARCH_LOCALE constants |
| locale | the actual set locale to use |
| ignore | ignore files with this character, default . |
| disableNotices | disable trigger notices if no translation found |
With the config updated, try the site again. You should now see your page without any markup tags and with the translated text; better yet - all those Smarty variables, modifiers and function calls have still been made!
Why is that?
The language filtering is handled BEFORE the template is executed meaning that anything within the {t}{/t} tags will still be executed as Smarty code. This allows date formatting, currency formatting and other things to be done in the translation data without needing any additional transformations in the view layer.
Posted by: Dave Redfern (Writer), in Tutorials on 07 Sep 2009 @ 22:54
Tags: languages, translation system, tutorial,
Contents:
This
work is licenced under a
Creative Commons Licence.