How to Make Multilanguage Pages in SilverStripe

  1. Make site translatable. go to mysite/_config.php and add lines:
    // Set the site default locale
    global $allowed_i18n;
    // Set the site allowed locales
    $allowed_i18n = array( 'de' => "de_DE", 'en' => "en_US");
    // Set the site default locale
    // Activate translatable and make siteconfig translatable
    Object::add_extension('SiteTree', 'Translatable');
    Object::add_extension('SiteConfig', 'Translatable');
  2. In mysite/code/page.php change code on page_controller:
    class Page_Controller extends ContentController {
        public function init() {
            if($this->dataRecord->hasExtension('Translatable')) {
  3. Make folder named lang in to mysite folder
  4. Make locale named file to lang folder (example:en_US.php)
  5. Add translation codes to mysite/lang/en_US.php like so:
    global $lang;
    // translated fields
    $lang['en_US']['']['WAYTO'] = 'Find the way...';
    $lang['en_US']['']['TRANSLATABLEFIELD'] = 'Translatable field translation';
  6. in you (example use code for translatable like so:
    <% _t('WAYTO','Find the way...') %> //this part add the translation for WAYTO in your theme file.
  7. Flush your website cache to make the changes viewable:

Looking for quality SilverStripe Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , | Posted under SilverStripe CMS | RSS 2.0

Author Spotlight

Teet Bergmann

Teet Bergmann

I'm a freelance web designer from Estonia. Mostly doing sites using Silverstripe, magento, prestashop, wordpress.

Leave a Reply

Your email address will not be published. Required fields are marked *