Getting Started
Ergo is multilingual & ready for your language, whatever that is! It comes with a translate system, ready-to-go translations and it's really easy to use and customize - as simple as editing a CSV file with OpenOffice or Excel.
Zend_Translate is Zend Framework's solution for multilingual applications. In multilingual applications, the content must be translated into several languages and display content depending on the user's language. PHP offers already several ways to handle such problems, however the PHP solution has some problems. You can read more about it on Zend_Translate's official documentation.
Translation files
All translations are organized into the lang/ folder of the application. Each language has it's own folder & file like lang/en/<translation>.csv. You can edit these files with OpenOffice or Excel.
Translation
Each translation string resides on it's own row and it's made of two columns, the string to be translated and the translated value, just like this:
username;Nom d'utilisateur password;Mot de passe login;Login forgot_password;oublié mot de passe register;Enregistrer logout;Déconnexion new_chat_messages;nouveaux messages de chat new_products;produits nouveaux
Then, using PHP it's really simple to get that value in any page of Ergo and display it to the user:
<?php echo $translate->_('username'); // prints Nom d'utilisateur ?>
Changing the language
Zend_Translate has the following configuration:
<?php $locale = isset($_GET['lang']) ? $_GET['lang'] : 'en'; // default language $translate = new Zend_Translate( array( 'adapter' => 'csv', 'content' => APP_LANG, 'scan' => Zend_Translate::LOCALE_DIRECTORY ) ); $translate->setLocale($locale); ?>
With this configuration, any translation file is loaded automagically by Zend and whatever value $locale
is set to, Zend_Translate will get the translations from the corresponding folder, so for example, when $locale = 'en';
Zend_Translate will search for .csv files in the lang/en/ folder.