21285 Posts in 5732 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1029 Views |
-
Multilingual support in templates

30 April 2010 at 12:44am Last edited: 30 April 2010 12:45am
Im trying to do some multilingual support but can't get i to work, I've added this in my sv_SE.php language file:
$lang['sv_SE']['SplashScreen']['SVENSKA'] = "Svenska";
$lang['sv_SE']['SplashScreen']['ENGLISH'] = "English";And this is my template:
<div id="SplashScreen" class="hidden">
<div id="SplashContent">
<div id="SplashLanguages">
<a onclick=""><% _t('SplashScreen.SVENSKA', 'Swedish') %></a>
<a onclick=""><% _t('SplashScreen.ENGLISH', 'English') %></a>
</div>
</div>
</div>But all that I can see is the fallback "Swedish" and "English"
-
Re: Multilingual support in templates

30 April 2010 at 6:21pm
Your sv_SE.php language file should contain template filename. Like this:
$lang['sv_SE']['SplashScreen.ss']['SVENSKA'] = "Svenska";
$lang['sv_SE']['SplashScreen.ss']['ENGLISH'] = "English";Without .ss it only works in your SplashScreen.php (class/controller file).
Harl
-
Re: Multilingual support in templates

3 May 2010 at 6:14pm
Tried to add .ss to SplashScreen, but still the only thing that shows is the fallback string!
-
Re: Multilingual support in templates

4 May 2010 at 1:19am
The preferred way is to just leave out the namespace bit in templates, to keep it readable, and add:
<a onclick=""><% _t('SVENSKA', 'Swedish') %></a>
<a onclick=""><% _t('ENGLISH', 'English') %></a>
Now, if you template name were to be mytemplate.ss, you can add this to your language file and SilverStripe should find it:$lang['sv_SE']['mytemplate.ss']['SVENSKA'] = "Svenska";
$lang['sv_SE']['mytemplate.ss']['ENGLISH'] = "English";Just in case: it still might not work if your template is included in some other template. In that case you could use the enveloping template's namespace. So supposing a template sometemplate.ss has a <% include mytemplate %>, add this to your languagefile:
$lang['sv_SE']['sometemplate.ss']['SVENSKA'] = "Svenska";
$lang['sv_SE']['sometemplate.ss']['ENGLISH'] = "English";
Hope it helps,
Martine
| 1029 Views | ||
|
Page:
1
|
Go to Top |

