- Make site translatable. go to mysite/_config.php and add lines:
// Set the site default locale i18n::set_locale('en_US'); i18n::enable(); global $allowed_i18n; // Set the site allowed locales $allowed_i18n = array( 'de' => "de_DE", 'en' => "en_US"); // Set the site default locale Translatable::set_default_locale('en_US'); // Activate translatable and make siteconfig translatable Object::add_extension('SiteTree', 'Translatable'); Object::add_extension('SiteConfig', 'Translatable');
- In mysite/code/page.php change code on page_controller:
class Page_Controller extends ContentController { public function init() { parent::init(); if($this->dataRecord->hasExtension('Translatable')) { i18n::set_locale($this->dataRecord->Locale); } } }
- Make folder named lang in to mysite folder
- Make locale named file to lang folder (example:en_US.php)
- Add translation codes to mysite/lang/en_US.php like so:
<?php global $lang;
//Page.ss translated fields $lang['en_US']['Page.ss']['WAYTO'] = 'Find the way...'; $lang['en_US']['Otherthemefilename.ss']['TRANSLATABLEFIELD'] = 'Translatable field translation'; ?>
- in you yourthemefile.ss (example Page.ss) use code for translatable like so:
<% _t('WAYTO','Find the way...') %> //this part add the translation for WAYTO in your theme file.
- Flush your website cache to make the changes viewable:
http://www.yoursite.com/?flush=all
Looking for quality SilverStripe Web Hosting? Look no further than Arvixe Web Hosting!