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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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

Multilingual Content - alternative to 'translatable'


Go to End


44 Posts   16910 Views

Avatar
CriaturaCreativaStudio

Community Member, 73 Posts

23 June 2009 at 12:15pm

THANK you very much!

i'll give this a try and let you know...!

anyway, thank you very much :)

Eduardo

Avatar
Kalileo

Community Member, 127 Posts

23 June 2009 at 2:44pm

Howard,

just to be sure that you know this:

i18n (which was not broken, only translatable was) would do the same more elegantly, as long as you just need to display translated text.

Avatar
CriaturaCreativaStudio

Community Member, 73 Posts

23 June 2009 at 2:52pm

Howard:

Confirmed. Your fix works! thank you very much! :)

Kalileo:

I don't know if you are refering to the new version of SS. I've asked for a more friendly tutorial to implement the new version of multi language support, but i did not find any "no programmer friendly" tutorial.

If you have some post that explains this, i will be very happy!

:)

Thanks

Regards

Eduardo

Avatar
Kalileo

Community Member, 127 Posts

23 June 2009 at 3:17pm

Edited: 23/06/2009 3:19pm

Eduardo,

to go with Howard's example, instead of


<% if LangIsMaori %> 
 <h2>Ngā mahi whai muri mai</h2> 
<% else %> 
 <h2>Upcoming Events</h2> 
<% end_if %>

when using i18n you simply need


<h2><% _t('Events.Upcoming_Events',"Upcoming Events") %></h2>

and the translations are in files in /mysite/lang/ such as for English in en_US.php


$lang['en_US']['Events']['Upcoming_Events'] = 'Upcoming Events';

or for Maori in mr_MR.php (I assume, check the correct code)


$lang['mr_MR']['Events']['Upcoming_Events'] = 'Ngā mahi whai muri mai';

You can see that the code in the templates is much more simple and universal than starting to check languages there with if-elseif-else constructions, and scalable, you can add as many translations as you want without changing the template.

If you need to add language specific stuff other than text the if-else might be the way you need to go though.

As said, while translatable needs i18n the fact that translatable was broken does not mean that i18n was broken. I mix the Multilingual Content - alternative to 'translatable' in SS 2.3.1 with i18n, works fine. See also my posts on the previous page about i18n and a bug in i18n in SS 2.3.1

Avatar
Kalileo

Community Member, 127 Posts

23 June 2009 at 3:23pm

Eduardo,

i18n is of course also available and heavily used in 2.3.2. many of the more recent templates now already use it, instead of hardcoding the English text, so often you only need to add your translations in /mysite/lang.

Avatar
sebaf

Community Member, 1 Post

8 July 2009 at 10:23pm

I have exactly the same problem than Cem. Wilhe I followed exactly the two first steps of the "recipes:multilingual_content", I have the following error message when I try to visit mysite.com/en/page/:

Fatal error: Class 'MultiLingual' not found in [...]/sapphire/core/control/Director.php on line 274

Since I added the Multilingual class in mysite/code/Page.php, mysite.com/page/ works fine
Version: 2.3.2

Does anyone has an idea to help me? I suppose we should show the system that the Multilingual class is present in mysite/Multilingual.php but I have no idea how to do it...

Thanks in advance !

Avatar
Kalileo

Community Member, 127 Posts

10 July 2009 at 11:37pm

Edited: 11/07/2009 12:56pm

@sebaf, the "Alternative Multilingual" recipe is for SS 2.3.1 only.

In SS 2.3.1 the "translatable" module was broken, so we needed it this alternative. However in 2.3.2 the translatable module is back and better than ever before, so if you use SS 2.3.2 you neither need the alternative nor was it ever meant to be used with it.

In short: With SS 2.3.2 use the translatable module!

Avatar
CriaturaCreativaStudio

Community Member, 73 Posts

11 July 2009 at 5:47am

Kalileo,

Thanks for your answer, actually i'm having a problem with a form wich i need to translate.
I don't want to appear like an asshole here, but i think the documentation for the multi language sites it's far to be clear.

Anyway, thank you very much for your help! :)

Regards

Eduardo