21487 Posts in 5783 Topics by 2621 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 2073 Views |
-
Locale/i18n for dummies

19 August 2009 at 10:28pm
I’m trying to use locale translations for the first time, but I seem to be missing a few things.
This is what i’m doing:
• I add this to cms/_config.php
i18n::enable();
i18n::set_default_lang('nl');• I add a folder called lang in mysite. Inside this folder I add a file called nl_NL.php
• In this file I add:<?php
global $lang;
$lang['nl_NL']['Page']['TEST'] = 'Test';
?>
• In the template (Page.ss) I add
<% _t('TEST') %>
-
Re: Locale/i18n for dummies

20 August 2009 at 2:33am
SS looks for the current user's locale first, failing that it falls back on the site default. I'll bet the user you're logged in as was created when your site was set to en_US as the default. Ensure your user account's language is set to nl_NL or try logging out and viewing your site.
-
Re: Locale/i18n for dummies

20 August 2009 at 4:12am
Thanks dalesaurus.
That didn’t solve the problem though. I also tried the suggestions here http://www.silverstripe.org/general-questions/show/267122?showPost=267153 as that question seems realy similar.
Is there extra documentation besides http://doc.silverstripe.com/doku.php?id=i18n with more examples/tutorials,…?
-
Re: Locale/i18n for dummies

20 August 2009 at 7:47am
Hmm, I'm at a loss then. The New Zealanders should be coming online soon, I'm sure one of them will be able to assist.
The wiki is the sole source of documentation at this time (aside from sifting through the code yourself). When you get this sorted out please be sure to update it or let me know and I'll be happy to do it.
-
Re: Locale/i18n for dummies

1 September 2009 at 6:14am
Ok, this is what I was doing wrong:
1/ It seems you need to use the following formatting.
In the template:
<% _t('Page.TEST') %>
In the language file
$lang['nl_NL']['Page']['TEST'] = 'Test';
You can’t exclude the 'page' part. It doesn't have to be 'page', but you can't use:
$lang['nl_NL']['TEST'] = 'Test';
2/ Tou need this in your Page_Controller
class Page_Controller extends ContentController {
public function init() {
parent::init();...
if($this->dataRecord->hasExtension('Translatable')) {
i18n::set_locale($this->dataRecord->Locale);
}
}Both things I found a bit difficult to get from the documentation. Hope other people having problems with it find this useful.
| 2073 Views | ||
|
Page:
1
|
Go to Top |


