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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

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

Empty message boxes with i18n::set_default_locale


Go to End


3 Posts   1494 Views

Avatar
inCharge

Community Member, 102 Posts

25 May 2011 at 6:42am

In SilverStripe 2.4, calling i18n::set_default_locale with anything other that en_US causes empty message boxes in the CMS.

To recreate this behaviour (or behavior if you're en_US!), add to _config.php ...

i18n::set_default_locale('en_GB');

...then log into the CMS (or refresh if already logged in). Edit a page and navigate away without saving. Instead of 'Are you sure you want to navigate away from this page', you get an empty message box.

The reason I want to call i18n::set_default_locale('en_GB') is so new users are automatically assigned the right interface language when they are created via the grid (which only has First Name, Last Name, Email, and Password fields) rather than by clicking 'Add Member'. What's the correct way to set the default language that doesn't have undesirable side effects?

Note: this is about setting the language in the CMS e.g. so people using the CMS see a 'Behaviour' tab not a 'Behavior' tab. This is not about making the resulting site translatable.

Avatar
inCharge

Community Member, 102 Posts

26 May 2011 at 9:49am

Edited: 26/05/2011 9:52am

Solved, kind of...

Messages for CMS popups are available for the following locales (as of SS 2.4):

cs_CZ
de_DE
en_US
fr_FR
sk_SK

The language files are stored in cms/javascript/lang

Either the logged in user's locale (i.e. the interface language selected in their profile) or the default locale must be one of those languages, otherwise popups are empty.

To use a default local that is not one of the 5 available, copy one of those JavaScript language files and rename the locale code in the file name and the file content.

e.g. Copy en_US.js to en_GB.js and change the line...

ss.i18n.addDictionary('en_US', {

...to...
ss.i18n.addDictionary('en_GB', {

For languages where there is not a close equivalent, it would not take long to translate as there are only 35 short messages.

Bear in mind when doing this, care needs to be taken when upgrading SilverStripe.

Are 3rd party translations of these files available and stored somewhere else?
Why is the CMS avaliable in 40 languages (see cms/lang) but the popups are only in 5 languages?

Avatar
martimiz

Forum Moderator, 1391 Posts

28 May 2011 at 10:42pm

Edited: 28/05/2011 10:47pm

Just to add to that: seems there are quite some translations missing from the files in that directory. For anyone interested, I do have an extended dutch version, that covers most (I hope). I could convert it to an en_US, so others could take it from there...

There are more missing/incomplete javascript language files like that hanging around. I did send in patches before, but they just keep popping up, and I'm not that into git yet... :-(