Jump to:

23007 Posts in 11866 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » Multilingual Content - alternative to 'translatable'

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

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

Page: 1 2 3 4 5 6
Go to End
Author Topic: 10619 Views
  • CriaturaCreativaStudio
    Avatar
    Community Member
    73 Posts

    Re: Multilingual Content - alternative to 'translatable' Link to this post

    THANK you very much!

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

    anyway, thank you very much

    Eduardo

  • Kalileo
    Avatar
    Community Member
    127 Posts

    Re: Multilingual Content - alternative to 'translatable' Link to this post

    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.

  • CriaturaCreativaStudio
    Avatar
    Community Member
    73 Posts

    Re: Multilingual Content - alternative to 'translatable' Link to this post

    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

  • Kalileo
    Avatar
    Community Member
    127 Posts

    Re: Multilingual Content - alternative to 'translatable' Link to this post

    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

  • Kalileo
    Avatar
    Community Member
    127 Posts

    Re: Multilingual Content - alternative to 'translatable' Link to this post

    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.

  • sebaf
    Avatar
    Community Member
    1 Post

    Re: Multilingual Content - alternative to 'translatable' Link to this post

    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 !

  • Kalileo
    Avatar
    Community Member
    127 Posts

    Re: Multilingual Content - alternative to 'translatable' Link to this post

    @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!

  • CriaturaCreativaStudio
    Avatar
    Community Member
    73 Posts

    Re: Multilingual Content - alternative to 'translatable' Link to this post

    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

    10619 Views
Page: 1 2 3 4 5 6
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.