Jump to:

10843 Posts in 2514 Topics by 1792 members

All other Modules

SilverStripe Forums » All other Modules » Translatable on SilverStripe 3.1.x - add locales not present in i18n::$common_locales

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 307 Views
  • D-L
    Avatar
    Community Member
    12 Posts

    Translatable on SilverStripe 3.1.x - add locales not present in i18n::$common_locales Link to this post

    Hi All,
    I'm using SilverStripe 3.1.x and the Translatable module and it only allows me to create pages in the locales listed in the i18n::$common_locales array. I need to be able to create pages in the following locales: en_GB (English UK - this is my default locale), fr_FR (French, France), nl_NL (Dutch, Netherlands), fr_BE (French, Belgium) and nl_BE (Dutch, Belgium). The first 3 locales are ok, but I cannot seem to be able to add locales fr_BE and nl_BE to the list of allowed locales. Does anyone know how I can do this?

    The locales that I would like to include (fr_BE and nl_BE) are present in the i18n::$all_locales array, but how do I get them to appear in the drop-down list of translations so that it is available for the content editor to select in order to create content in that locale?

    I have tried the old method of adding a new locale by adding it through mysite/_config.php as follows:

    i18n::$common_locales['fr_BE'] = array('French (Belgium)', 'français (Belgique)');
    i18n::$common_locales['nl_BE'] = array('Dutch (Belgium)', 'Nederlands (België)');


    (as described at the bottom of this page (SS v2.3)), but it does not work in SS 3.1.x, instead I get the following fatal error:

    Fatal error: Cannot access private property i18n::$common_locales in /Applications/MAMP/htdocs/.../mysite/_config.php

    I have also tried explicitly setting the allowed locales in mysite/_config.php as follows, but only English UK, French and Dutch appears, but not French (Beligium) and Dutch (Belgium):

    Translatable::set_allowed_locales(array(
    'en_GB', //English UK
    'fr_FR', //French
    'nl_NL', //Dutch, Holland
    'fr_BE', //French, Belgium
    'nl_BE', //Dutch, Belgium
    'it_IT' //Italian
    ));

    Any help/suggestions, would be greatly appreciated! Thanks in advance.

  • Nobrainer Web
    Avatar
    Community Member
    134 Posts

    Re: Translatable on SilverStripe 3.1.x - add locales not present in i18n::$common_locales Link to this post

    Hi,

    A bit late, but perhaps for future visitors

    i18n::set_locale('da_DK');
    Translatable::set_default_locale('da_DK');

    SiteTree::add_extension('Translatable');
    SiteConfig::add_extension('Translatable');
    Translatable::set_allowed_locales(array('da_DK', 'en_US', 'sv_SE'));

    is what i have in mysite/_cinfig.php and that works fine.

  • ocean
    Avatar
    Community Member
    37 Posts

    Re: Translatable on SilverStripe 3.1.x - add locales not present in i18n::$common_locales Link to this post

    I'm having a similar problem to D-L, latest install of everything yesterday via composer etc...

    es_MX is not showing up as an option in CMS even though it is set in Translatable::set_allowed_locales

    Note, I had this setup and working with the code base from about a year ago using SS3.05, so something changed which stopped certain country codes working, in this case es_MX, the main language used in a current project undergoing updates, so this is a pretty major holdback right now!

    I posted the issue on github yesterday [url= https://github.com/silverstripe/silverstripe-translatable/issues/159] [url]https://github.com/silverstripe/silverstripe-translatable/issues/159

    Any ideas?

    Sean

  • ocean
    Avatar
    Community Member
    37 Posts

    Re: Translatable on SilverStripe 3.1.x - add locales not present in i18n::$common_locales Link to this post

    tried adding this to i18n.php common_languages function (as that is where the language selector menu in CMS seems to be pulling in labels from) but has not worked:

    'es_MX' => array(
       'name' => 'Spanish (MX)',
       'native' => 'Español (MX)'
    ),

    Any ideas?

    This is quite urgent and major blockage in terms of the project I'm working on, can anyone help?

    Best wishes
    Sean

    p.s. I have to say, sometimes working on SS projects is like wandering around in the wilderness!!! Just saying, compared to other projects and frameworks, certain things seem very sketchy and little supported which should be standard. Anyways, thanks for any help you may offer with this.

  • ocean
    Avatar
    Community Member
    37 Posts

    Re: Translatable on SilverStripe 3.1.x - add locales not present in i18n::$common_locales Link to this post

    Correction:
    after adding to common_locales (instead of common languages) in i18n.php es_MX is now showing in CMS menu!

    I feel this should be in core by design, though is something to take up with SS framework devs I suppose.

    307 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.