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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Locale/i18n for dummies

Go to End

5 Posts   2901 Views


Community Member, 135 Posts

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


• I add a folder called lang in mysite. Inside this folder I add a file called nl_NL.php
• In this file I add:


global $lang;

$lang['nl_NL']['Page']['TEST'] = 'Test';


• In the template ( I add

<% _t('TEST') %>


Community Member, 283 Posts

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.


Community Member, 135 Posts

20 August 2009 at 4:12am

Thanks dalesaurus.

That didn’t solve the problem though. I also tried the suggestions here as that question seems realy similar.

Is there extra documentation besides with more examples/tutorials,…?


Community Member, 283 Posts

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.


Community Member, 135 Posts

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() {

		if($this->dataRecord->hasExtension('Translatable')) {

Both things I found a bit difficult to get from the documentation. Hope other people having problems with it find this useful.