Jump to:

10979 Posts in 2722 Topics by 1815 members

All other Modules

SilverStripe Forums » All other Modules » Translatable::set_default_locale error

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 932 Views
  • Marcinkonys
    Avatar
    Community Member
    11 Posts

    Translatable::set_default_locale error Link to this post

    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?

  • den01
    Avatar
    Community Member
    1 Post

    Re: Translatable::set_default_locale error Link to this 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?

  • dondon
    Avatar
    Community Member
    5 Posts

    Re: Translatable::set_default_locale error Link to this post

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

  • Drumstick
    Avatar
    Community Member
    20 Posts

    Re: Translatable::set_default_locale error Link to this post

    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;

  • Marcinkonys
    Avatar
    Community Member
    11 Posts

    Re: Translatable::set_default_locale error Link to this post

    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

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: Translatable::set_default_locale error Link to this post

    Config it through YAML :

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

    932 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.