Jump to:

5513 Posts in 1732 Topics by 1218 members

Customising the CMS

SilverStripe Forums » Customising the CMS » [SOLVED] Cutomising language names on a multilingual website

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

Page: 1 2
Go to End
Author Topic: 1050 Views
  • vodoomoth
    Avatar
    Community Member
    22 Posts

    [SOLVED] Cutomising language names on a multilingual website Link to this post

    Hi,

    I have a website in both English and French and with potentially more languages tomorrow.

    Today, the "French" label is used to refer to a language that the people who speak it call "Français". I'm expecting language names to be expressed in the language and script that the people who read and write that language use. I wouldn't expect someone who speaks only Russian to know that "Russian" is the call sign for their language… Rather, I'm expecting "Russian" to be written using the Cyrillic alphabet and reading what the Russians call their language.

    So my question is: "where can I modify the language names"? Is it in some configuration file or hardcoded in a source file? Whatever the case, can someone please tell me which file it is?

    Thank you.

  • martimiz
    Avatar
    Forum Moderator
    1067 Posts

    Re: [SOLVED] Cutomising language names on a multilingual website Link to this post

    Are you referring to the languagse dropdown in the cms or to a language switcher on the webste?

  • vodoomoth
    Avatar
    Community Member
    22 Posts

    Re: [SOLVED] Cutomising language names on a multilingual website Link to this post

    Thanks for your reply. I am referring to a language switcher on the actual website.
    I am the only content editor for my website and I read both English and French so the back end side of things isn't an issue.

  • martimiz
    Avatar
    Forum Moderator
    1067 Posts

    Re: [SOLVED] Cutomising language names on a multilingual website Link to this post

    Ok, in that case - can you tell us more about the languageswitcher you're using, maybe post the code used to build it, is it an existing module or widget, or do you have a link to the tutorial/docs it came from?

  • vodoomoth
    Avatar
    Community Member
    22 Posts

    Re: [SOLVED] Cutomising language names on a multilingual website Link to this post

    The website design and template were made by an intern and I don't have much info. But it doesn't look like there's a plugin involved. I've attached the a screen capture of the appropriate code in Header.ss and a screen capture of its rendition on the website.

  • martimiz
    Avatar
    Forum Moderator
    1067 Posts

    Re: [SOLVED] Cutomising language names on a multilingual website Link to this post

    $Locale.Nice (in your Header.ss template) should normally return the languagename based on the current users language. So if you're currently at the English site, you'll get 'English' and 'French'. At the French site, the names should now read 'Anglais' and 'Français'.

    If you'd want the names to be in their native form always (English, Français), you should be able to do (haven't tested this):

    $Locale.Nice(true)

    Don't forget to ?flush=1 after changing your template...

  • vodoomoth
    Avatar
    Community Member
    22 Posts

    Re: [SOLVED] Cutomising language names on a multilingual website Link to this post

    $Locale.nice(true) did the trick but the first letter for "Français" is lower case.

    I've tried

    ucfirst($Locale.Nice(true))


    and

    <% ucfirst($Locale.Nice(true)) %>


    but these appear as such on the webpage.

    I've read the documentation on templates but I don't see a way to call a PHP function. Is it possible to do so?

  • martimiz
    Avatar
    Forum Moderator
    1067 Posts

    Re: [SOLVED] Cutomising language names on a multilingual website Link to this post

    You'll find the list of $common_locales in framework/i18n/i18n.php. The native name for french is indeed lowercase.

    I think you can easily define your own (shorter!) list of common locales from your _config.php. Something like:

    i18n::$common_locales = array(
          'af_ZA' => array('Afrikaans', 'Afrikaans'),
          ...
    };

    1050 Views
Page: 1 2
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.