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.

Customising the CMS /

[SOLVED] Cutomising language names on a multilingual website


Go to End
Reply


9 Posts   1187 Views

Avatar
vodoomoth

Community Member, 22 Posts

11 September 2012 at 2:44am

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.

Avatar
martimiz

Forum Moderator, 1106 Posts

12 September 2012 at 2:20am

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

Avatar
vodoomoth

Community Member, 22 Posts

12 September 2012 at 4:12am

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.

Avatar
martimiz

Forum Moderator, 1106 Posts

12 September 2012 at 4:39am

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?

Avatar
vodoomoth

Community Member, 22 Posts

12 September 2012 at 5:41am

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.

Avatar
martimiz

Forum Moderator, 1106 Posts

13 September 2012 at 12:51am

Edited: 13/09/2012 12:52am

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

Avatar
vodoomoth

Community Member, 22 Posts

15 September 2012 at 3:18am

Edited: 15/09/2012 3:19am

$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 [url]documentation on templates[/url] but I don't see a way to call a PHP function. Is it possible to do so?

Avatar
martimiz

Forum Moderator, 1106 Posts

15 September 2012 at 6:47am

Edited: 15/09/2012 6:49am

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'),
      ...
};

Go to Top