Website Translations

Skip to end of metadata
Go to start of metadata

Pimcore provides a simple translation-tool based on Zend_Translate.

The only thing you have to do is to register a locale globally (the ZF way), the easiest way is to do that in the Website_Controller_Action.

In the example Website_Controller_Action which is shipped with Pimcore there is already an example.

Once you have registered the locale you can simply use the translate helper of Zend_View in your templates with: <?= $this->translate("translation_key") ?>

Then call the page where you use the translation, once you have done this, pimcore registers the key in the translation administration, and you can edit the text in the grid.

The columns in the translation administration for the languages is generated automatically by the used locales.

Please make sure that all desired languages are set as valid frontend languages in the pimcore system settings as described here

Next the translations for all registered languages can be edited in Extras > Translations Website

Example in Website_Controller_Action

<?php
 
class Website_Controller_Action extends Pimcore_Controller_Action_Frontend {
 
public function init () {
 
parent::init();

$locale = new Zend_Locale('en_US');
Zend_Registry::set('Zend_Locale', $locale);
 
}
 
?>

Example in Templates / Views

<div>
    <address>&copy; <?= $this->translate("copyright") ?></address>
    <a href="/imprint"><?= $this->translate("imprint") ?></a>
    <a href="/legal"><?= $this->translate("legal_notice") ?></a>
</div>
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Jul 22, 2011

    Brecht Cloetens says:

    How to add other languages to the translation file: Navigate to Settings>S...

    How to add other languages to the translation file:

    1. Navigate to Settings>System
    2. Click on Website
    3. Type your language within 'Valid Languages in Frontend'
      Example: Flemish (nl_BE) French (fr) 
      tasklist: Task lists can not be used in comments.

      French (fr_BE) doesn't exists

    4. Press the save button
    5. Open /website/lib/Website/Controller/Action.php
    6. Change Zend_Locale to the language you want to use:
      For nl_BE: $locale= new Zend_Locale('nl_BE');
      For fr: $locale= new Zend_Locale('fr');
    7. If French (fr_BE) should exist, we had to use $locale= new Zend_Locale('fr_BE');
  2. Mar 02

    Mat says:

    It is important to note that the locale must be set in the init() function of th...

    It is important to note that the locale must be set in the init() function of the controller.