Translate
Text snippet translations in multilingual applications
Translate
The Translate functionality in Redspark extends mainly the one from Zend. There are a few features added as described above.
Location Storage
The main extension is the storage of the locale data. In Redspark there is an extension, that untranslated entries are loged. In RedSparkCore untranslated entries are written into the database and can be translated inside the backend. The result of this translation will be stored in a temporary tmx file per module. An initial set of translations will be loaded automaticaly via a module-specific tmx file, too.
Locale specialty
In Redspark there is a strict distinguish between the Interface-Language and the Account-Language.
If you want a text to have a text translated, you should therefore always be aware, where it should be displayed.
A good starting point is to assume frontend content is in the Account-Language, while backend content is in the Interface-Language.
In short: If you want to translate frontend content, be sure to use second parameter to set to Redspark_Locale::ACCOUNT_LOCALE.
Interface Language
The first one is used mainly in the backend, comes from the browser locale and can be switched in the backend. This should be the language the user understands best.
Account Language
The Account-Language is the language, in which the content is delivered, for this account. Internaly it is saved with a fake-locale "Account_<aid>". The abstract account text (see "system" in interface language) is saved under the locale "Account"
Usage in PHP
<?php
Broker::getTranslate()->get("Modulname", "Text");
Broker::getTranslate()->get("Modulname", "Text", Redspark_Locale::ACCOUNT_LOCALE);
$this->_("This is my text");
$this->_("This is my text",Redspark_Locale::ACCOUNT_LOCALE);
?>
Usage in Smarty
{"This is my text"❙translate:'MyModule'}
{"This is my text"❙translate:'MyModule':'account'}