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::set_default_locale error


Go to End


6 Posts   2714 Views

Avatar
Marcinkonys

Community Member, 11 Posts

21 April 2013 at 8:11am

Edited: 21/04/2013 8:12am

Hey guys,

I've used Translatable without problems before, but now I'm bumping into one problem after another. I've tried installing Translatable on SS3.1, didn't work. Then I tried SS3.0.5, and am getting the same error.

I've downloaded Translatable and stored it in the root folder, naming the folder 'translatable'. I've added this to the config file in mysite/:

// Set the site locale
i18n::set_locale('en_GB');

//default translation
Translatable::set_default_locale('en_GB');
Object::add_extension('SiteTree', 'Translatable');

When I do a 'dev/build', I'm presented with these errors:

Strict standards: Non-static method Object::config() should not be called statically in C:\wamp\www\ss3s\translatable\code\model\Translatable.php on line 270

Fatal error: Using $this when not in object context in C:\wamp\www\ss3s\framework\core\Object.php on line 67

Now when I add quotes to the line

Translatable::set_default_locale('en_GB');
, the build works fine. What might be the problem?

Avatar
den01

Community Member, 1 Post

26 April 2013 at 10:19am

Hi, I have the same problem, but when I make the build it still does not work fine. I tried with default local language 'de_DE' and 'en_US'.
Did you make some further experience?

Avatar
dondon

Community Member, 5 Posts

30 April 2013 at 7:55pm

I have the same issue...Please Help guys!...Thanks in advance.

Avatar
Drumstick

Community Member, 20 Posts

30 April 2013 at 8:03pm

Edited: 30/04/2013 8:04pm


I found what works...with Silverstripe 3 you installl the module translatable with first install, and

then write this code in the file mysite/_config.php

Translatable::set_default_locale("de_DE");
Object::add_extension('SiteTree', 'Translatable');
Object::add_extension('SiteConfig', 'Translatable');

$allowed_locales = array(
'de_DE' => array('German', 'Deutsch'),
'en_US' => array('English', 'English'),
'fr_FR' => array('French', 'Français'),
'es_ES' => array('Spanish', 'Español')
);
i18n::$common_locales = $allowed_locales;

Avatar
Marcinkonys

Community Member, 11 Posts

23 May 2013 at 9:21am

Edited: 23/05/2013 11:58pm

I've tried this, and still have the exact same problem :/ Which version of Silverstripe are you using? I installed the framework, did a 'dev/build', then imported the translatable folder and edited the config file, and on the next 'dev/build', the same error showed up.

Edit: I got it to work! Here's what my _config.php looks like now:

Translatable::set_default_locale("en_US"); 
Object::add_extension('SiteTree', 'Translatable'); 
Object::add_extension('SiteConfig', 'Translatable');

$allowed_locales = array(
'en_US' => array('name' => 'English', 'native' => 'English'),
'de_DE' => array('name' => 'German', 'native' => 'Deutsch')
);

Config::inst()->update('i18n', 'common_locales', $allowed_locales);
Translatable::set_allowed_locales(array(
	'en_US',
	'de_DE'
));

Thanks for the help everyone :)

Avatar
Fuzz10

Community Member, 791 Posts

18 July 2014 at 12:14am

Config it through YAML :

i18n:
common_locales:
nl_BE:
name: Dutch (Belgium)
native: Nederlands
fr_BE:
name: French (Belgium)
native: Francais