Hey there,
would like to ask if someone could help me out with this one.
I just found out how to use the t-function, though I don't get it working.
This is how my _config.php looks like
Translatable::set_default_locale('de_DE');
i18n::set_locale('de_DE');
i18n::set_locale('en_GB');
i18n::set_locale('it_IT');
i18n::set_locale('fr_FR');
Translatable::set_allowed_locales(array(
'de_DE',
'en_GB',
'it_IT',
'fr_FR'
)
);
SiteTree::add_extension('Translatable');
SiteConfig::add_extension('Translatable');
My header has the $ContentLocale
<html lang="$ContentLocale" xmlns="http://www.w3.org/1999/xhtml">
This is the function in my template file HomePage.ss
<p><% _t('HomePage.ss.LEISTUNGSPROFIL','LEISTUNGSPROFIL') %></p>
This is the content of my Page.php
<?php
class Page extends SiteTree {
private static $db = array(
'SideBar'=>'HTMLText',
);
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Main',new HTMLEditorField('SideBar','Sidebar Inhalt'));
return $fields;
}
private static $has_one = array(
);
}
class Page_Controller extends ContentController {
/**
* An array of actions that can be accessed via a request. Each array element should be an action name, and the
* permissions or conditions required to allow the user to access it.
*
* <code>
* array (
* 'action', // anyone can access this action
* 'action' => true, // same as above
* 'action' => 'ADMIN', // you must have ADMIN permissions to access this action
* 'action' => '->checkAction' // you can only access this action if $this->checkAction() returns true
* );
* </code>
*
* @var array
*/
private static $allowed_actions = array (
);
public function init() {
parent::init();
if($this->dataRecord->hasExtension('Translatable')) {
i18n::set_locale($this->dataRecord->Locale);
}
}
}
And lastly I created a "lang" folder in "mysite" folder which consists of 3 files:
en_GB.php
fr_FR.php
it_IT.php
<?php
$lang['en_GB']['HomePage.ss']['LEISTUNGSPROFIL'] = 'LEISTUNGSPROFIL English';
So, what am I doing wrong? Is everything it it's right place? Does the lang folder belong into mysite?
Would be awesome if someone could help me out.
You can check out the non working translation on the HomePage of greenrhythm.org
Best regards,
Richard