Transl8

Quick start guide

Plugin installation

Requirements

In order to have transl8 working you need to have

  • the Javascript JQuery Framework (>= 1.6.2)
  • the Javascript JQuery UI Framework (>= 1.8.16)
  • Optionnaly you can add the Qtip JQuery plugin (>= 1.0.0)
  • PHP Zend Framework with Autoloader

Installation

  1. Copy the Transl8 folder into your library directory.
  2. Add “Transl8_” prefix in the autoloader.

Plugin initialization

    1. You will have to register the “Transl8_Activated” key in the Registry.
      This item must contain a boolean that specifies whether online translation is activated or not.
      You can set this to true when an admin user is connected for example.

      Zend_Registry::set('Transl8_Activated', true);
      
    2. Initialize enabled locales in translation form. It must be an array of Zend_Locale instances.
      foreach ($enabledLocales as $locale) {
      $locales[trim($locale)] = new Zend_Locale($locale);
      }
      Transl8_Form::setLocales($locales);
      

      You don’t have to specify all the available locale. You can provide only locales for which you want to have the online translation activated.

    3. You must specify in which folder you want to generate translations.
      Transl8_Translate_Writer_Csv::setDestinationFolder(
      '/complete/path/to/your/project/translations-folder'
      );
      

      Complete path to the translation folder must be specified.

      The name of the translation folder can be whatever you want.

      You need to have full access on this folder to allow the plugin to write & read the translation files.

    4. Plugin registration.
      Don’t forget to initialize the urls for getFormData and post actions.
      These actions are in an action helper in the library and must be implemented in a controller in your application.

      $transl8Plugin = new Transl8_Controller_Plugin_Transl8();$transl8Plugin->setActionGetFormData($urlToGetFormDataAction);
      $transl8Plugin->setActionSubmit($urlToPostAction);
      $frontController = Zend_Controller_Front::getInstance();
      $frontController->registerPlugin($transl8Plugin);
      

      Translations initialization

      1.  In case you chose to generate translations in a different folder than the regular one you use, you should load generated translations AFTER regular ones.
      2. You should also load translations for all enabled locales when plugin is activated. Otherwise you will not see these translations in the edition form.

        Make sure that the Zend_Translate instance still has the right locale set after loading translations for all enabled locales.

      Usage

      You just have to use the view helper name “T” shipped with the library to enable translation on a text in your view.

      <?php echo $this->T('My text to translate'); ?>