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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Translatable problem


Go to End


1204 Views

Avatar
HanSolo

Community Member, 87 Posts

1 September 2015 at 12:14am

Edited: 01/09/2015 12:48am

I have downloaded the translatable module and use 2 languages on my site:
In my _vonfig.php file i added the following.

i18n::set_locale('sv_SE');
// i18n::set_locale('en_GB'); //this i had to remove because i get an error
Translatable::set_default_locale('sv_SE');

Translatable::set_allowed_locales(array(
'sv_SE',
'en_GB',
));

SiteTree::add_extension('Translatable');
SiteConfig::add_extension('Translatable');

And in mysite/code/page.php

I wanted to add the following, but i had to remove it because it will generate an error

public function init() {
parent::init();

if($this->dataRecord->hasExtension('Translatable')) {
i18n::set_locale($this->dataRecord->Locale);
}

I can have to language of the site but the _t dont work, do anyone have an idea what is wrong.

Update: When i add the following to _config.php
i18n::set_locale('en_GB');

SOLVED: I had a tab intendention in language yaml file instead of 4 spaces... ;-(