Skip to main content
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
I've got some problem with using _t() function in my multilanguage site.
In my template i put:
<% _t('DESIGN', 'some text') %>
I have 2 lang files under mysite/lang folder: en_US.php and pl_PL.php where I enter:
$lang['en_US']['Page.ss']['DESIGN'] = 'some text';
$lang['pl_PL']['Page.ss']['DESIGN'] = 'polish text';
Whatever language I choose in my site it always give me back 'polish text'. Its seems to work ok, but it never wants to load english text (unless I delete pl_PL.php).
In my _config.php I have:
I dont have a clue what is wrong... General content translations done in CMS admin work fine.
Any help I will be grateful.
In my _config.php I have some other lines:
// Define allowed locales overriding those present in i18n::$common_locales
$allowed_locales = array(
'fr_FR' => array('French', 'français'),
'en_GB' => array('English', 'English'),
'es_ES' => array('Spanish', 'español')
i18n::$common_locales = $allowed_locales;
// Define defaults
setlocale(LC_ALL, 'fr_FR.UTF8', 'fr_FR', 'fr-FR', 'french'); // Needed for dates
Also, you need to set your locale in the init() function of your Page_Controller with some code implementing i18n::set_locale(). Do you have it? ([url=http://doc.silverstripe.org/doku.php?id=multilingualcontent#setting_the_i18n_locale]see here[/url]).
Hope it helps,
Shouldn't it be:
<% _t('Page.ss.DESIGN', 'some text') %>
Or should this work regardless because page.ss is the location?
Thatâ€™s true! Thereâ€™s also a bug with included templates: http://open.silverstripe.org/ticket/4915
Thank you for your responses.
Juanitou, ,you were right, I didnt set locale in my Page_Controller.
After adding this in my init() function:
everything is working just fine :)