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:

Template Questions /

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

multilingual footer

Go to End

7 Posts   1971 Views


Community Member, 25 Posts

28 August 2009 at 3:40am

Edited: 28/08/2009 4:14am


I'm developing a bilingual site. Translatable works fine for the articles, but I don't know how to make the footer language-aware. Out of the box, it won't, so I know I'll need to modify something. Maybe it would be the best to have some <% control Page(footer-LOCALE) %> in and have both versions of the footer as independent pages in the CMS? But how would I choose the right page in my Is there something like <% if locale = 'de-de' %>? I can't find anything in the docs. Any ideas?



Community Member, 25 Posts

28 August 2009 at 4:11am

Thanks, Taffy, but neither of both will do it. The Translatable control will give me all translations, but I need just one - the right one. The _t function also won't do it, as the footer is too complex.


Community Member, 323 Posts

28 August 2009 at 5:55am

Hi! I think I don't understand that “The _t function also won't do it, as the footer is too complex” thing.

Example of one of my footers:

<div id="Footer">
	<span class="left"><% _t('DESIGNBY', 'Conception :') %> <a href="">EuroV&eacute;rtice</a></span>
	<% if ClassName != ContactPage %>
	&nbsp;|&nbsp;<a href="$ContactPageLink"><% _t('CONTACTPAGE','Contact') %></a>
	<% end_if %>

That gives footers translated in as much languages as xx_XX.php files you put in the lang folder, containing:

$lang['xx_XX']['']['DESIGNBY'] = 'Conception :';
$lang['xx_XX']['']['CONTACTPAGE'] = 'Contact';

If I got you well…


Community Member, 25 Posts

28 August 2009 at 11:20pm

Sorry, I don't like the _t() solution. _t() is ok for buttons, labels, "read more" links, etc, but it's not appropriate for translating content. What if the customer wants to edit his footer in the future? You won't tell him too edit and xx_YY.php. A footer is content, thus it should be managed and translated through the admin interface. I actually set my to <% control page(Footer) %>... for all my Silverstripe projects. This is the first time I need to make it bilingual.

I did some hacking and now this does that work for me:

function PageForCurrentLocale( $pagename ) {
	if ( Object::has_extension('Page','Translatable') ) {
		Translatable::$enable_lang_filter = false; 
		$page = DataObject::get_one("Page","URLSegment='$pagename'");
		Translatable::$enable_lang_filter = true;
		if ( empty($page) )
		else if ( Translatable::get_current_locale() != Translatable::default_locale() )
			return $page->getTranslation( Translatable::get_current_locale() );
			return $page;

just put it in your Page class and this one in your

<% control PageForCurrentLocale(footer) %>
<% end_control %>



Community Member, 323 Posts

29 August 2009 at 5:26am

Ah! I understand now. Thanks for the contribution, it's most useful.

Best regards,


Community Member, 25 Posts

29 August 2009 at 6:43am

Thanks for your comment. I've opened a new Ticket for this. Maybe it will get included in future releases.