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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

Our old forums are still available as a read-only archive.

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

Problem with i18n translation for included .ss files

Go to End

12 Posts   17325 Views


Community Member, 75 Posts

25 April 2008 at 3:41am

Edited: 25/04/2008 3:42am

Hi there,

I have a problem with the i18 n translation. I guess there is a bug! The translation doesn't work when I call it from an included .ss file:

I use the file Includes/ with the code inside:

<p>My Translation: <% _t('HELLO', 'Hello world') %></p>

And there is in the en_US.php language file
$lang['en_US']['']['HELLO'] = 'Hello world';

And the de_DE.php file width
$lang['de_DE']['']['HELLO'] = 'Hallo Welt';

The translation dosen't work! What's wrong?
Is anybody able to help me!


Community Member, 20 Posts

25 April 2008 at 1:11pm

Edited: 25/04/2008 1:12pm

My best guess would be that files are first included, then parsed by the i18n module. This means that instead of

$lang['de_DE']['']['HELLO'] = 'Hallo Welt';

you would have to use
$lang['de_DE']['<Name of file where is included>']['HELLO'] = 'Hallöchen';

Could you try that and see if it works?

Cheers, Blynx


Community Member, 75 Posts

25 April 2008 at 9:43pm

Thank you, it works!!! Fine!
But I guess it's not the way it should work! Normally I may use the include on multiple page types - now I have to write many similar translation code terms for every page-type?

Actually there are other problems; I'm trying to build a Blog with i18n translation (on the latest SilverStripe SVN Version).
Some code - the BlogManagementWidget.php e.g. has static parts (static $title = "Blog Management";) How does it work to translate this title?

On the BlogEntry page is also included the
All translations here (like <% _t('REMCOM','remove this comment') %>) don't work.

What's wrong with the code?



Community Member, 20 Posts

26 April 2008 at 5:51pm

Edited: 26/04/2008 5:53pm

Well, it depends - this way you can include your page snippet in numerous pages, and always have the translations that are appropriate. But this might be a feature to look at, you could open a ticket here, and see what the development team thinks of it.

Translating the title of a widget cannot be done with the standard _t() function (yet). There's already a ticket for this issue, so hopefully this is possible soon:
As a workaround for now, you can use functions instead of the static variables:

  function Title(){
    return _t("Widget.TITLE","title of the widget");
  function CMSTitle(){
    return _t("Widget.CMSTITLE","cmstitle of the widget");
  function Description(){
    return _t("Widget.DESCRIPTION","description of the widget");

I can't really follow you with the 3rd problem, as the is part of the CMS in my installation, not the blog.

Cheers, Blynx


Community Member, 75 Posts

29 April 2008 at 3:07am

Thanx, great! That helped me a lot! :-)
I'm going to open your recommendet tickets for the include problem and the widget translation.

There is still the problem with the This is not a part of the blog module but needed for blog comments management (Called from the Page). The translation works in a strange way. Some parts will only be translated when I'm in "logged in" status. Other parts like <% _t('REMCOM','remove this comment') %> don't work. I'm not able to comprehend why and when some included files will be correct translated! Any idea?


Community Member, 20 Posts

29 April 2008 at 5:37am

Which theme are you using?
I've looked in the original blog module (tarballs version from 28/4), the blackcandy theme and the itheme, none of the files include a - could you post the contents of your please?

Also, have you tries copying the language file from the cms (where the is located in my installation) to the blog (where it is included)?


Community Member, 75 Posts

29 April 2008 at 8:16pm

I'm using my own theme and the newest blog modul (checked out from with the language assistance. There ist the Blog file:

<!--------------------------------------------- -->
<% include BlogSideBar %>
<div id="BlogContent" class="typography">
	<% include BreadCrumbs %>
	<div class="blogEntry">
			<p class="authorDate"><% _t('POSTEDBY', 'Posted by') %> $Author.XML <% _t('POSTEDON', 'on') %> $Date.Long | $Comments.Count <% _t('COMMENTS', 'Comments') %></p>
				<% if Tags %>
					<p class="tags">
						 <% _t('TAGS', 'Tags:') %> 
						<% control Tags %>
							<a href="$Link" title="<% _t('VIEWALLPOSTTAGGED', 'View all posts tagged') %> '$Tag'" rel="tag">$Tag</a><% if Last %><% else %>,<% end_if %>
						<% end_control %>
				<% end_if %>
			<br />
			<% if CurrentMember %><p><a href="$EditURL" id="editpost" title="<% _t('EDITTHIS', 'Edit this post') %>"><% _t('EDITTHIS', 'Edit this post') %></a> | <a href="$Link(unpublishPost)" id="unpublishpost"><% _t('UNPUBLISHTHIS', 'Unpublish this post') %></a></p><% end_if %>

</div><!--------------------------------------------- -->

You see the $PageComments? This is not from the blog module!
Inside the folder cms/lang are the language files, e.g.

$lang['en_US']['']['REMCOM'] = 'remove this comment';

But they translation does not work on my BlogEntry Page.
I also tried to change to
$lang['en_US']['']['REMCOM'] = 'remove this comment';

but it's not working.


Community Member, 20 Posts

29 April 2008 at 8:49pm

Ah, I see. This is a tricky one.
I'll try to break it down for you a little:
- The $PageComments executes the equivalent function in \sapphire\core\control\ContentController.php, because the class BlogEntry_Controller extends Page_Controller extends ContentController.
- This function now returns an object called PageCommentInterface, which itself uses the file to be rendered.
- In this file, the is then included.

I don't know how much you're into PHP and Objects and if the above makes any sense (it's almost 2am here...), but basically this means that the appropriate line in your translation file should look like
$lang['en_US']['']['REMCOM'] = 'remove this comment';

Unfortunately I can't test it here as I don't use any comments on my page.

Cheers, Blynx

Go to Top