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.

All other Modules

Discuss all other Modules here.

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

Translatable::set_default_locale error


Reply

6 Posts   996 Views

Avatar
Marcinkonys

21 April 2013 at 8:11am (Last edited: 21 April 2013 8:12am), Community Member, 11 Posts

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

26 April 2013 at 10:19am Community Member, 1 Post

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

30 April 2013 at 7:55pm Community Member, 5 Posts

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

Avatar
Drumstick

30 April 2013 at 8:03pm (Last edited: 30 April 2013 8:04pm), Community Member, 20 Posts

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

23 May 2013 at 9:21am (Last edited: 23 May 2013 11:58pm), Community Member, 11 Posts

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

18 July 2014 at 12:14am Community Member, 787 Posts

Config it through YAML :

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