Jump to:

3444 Posts in 1030 Topics by 871 members

Template Questions

SilverStripe Forums » Template Questions » Multi Language Issues

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

Page: 1
Go to End
Author Topic: 3627 Views
  • dickv
    Avatar
    Community Member
    3 Posts

    Multi Language Issues Link to this post

    I am developing a site in 2 languages, English and German. I have set up Translatable.

    I woul like to setup the ability to create links in the template to switch between the 2 languages.

    Here is the code I am using:

    <% if Translations %>
    <ul class="translations">
    <% control Translations %>
    <li class="$Locale.RFC1766">
       <a href="$Link" hreflang="$Locale.RFC1766" title="$Title">
    <% sprintf(_t('SHOWINPAGE','Show page in %s'),$Locale.Nice) %>
       </a>
    </li>
    <% end_control %>
    </ul>
    <% end_if %>

    This works for the German translation: It shows Show Page in German

    It does no t work for the English translation, it shows Show Page in . It appears the variable

    $Locale.Nice

    is empty.

    I then tried the following:

    <% if Translations %>
    <ul class="translations">
    <% control Translations %>
    <li class="$Locale.RFC1766">
       <a href="$Link" hreflang="$Locale.RFC1766" title="$Title">
    <% if Locale.RFC1766 == en_NZ %>
        <% echo _t('SHOWINPAGE','Show page in English') %>
        <% else %>
        <% sprintf(_t('SHOWINPAGE','Show page in %s'),$Locale.Nice) %>
        <% end_if %>
       </a>
    </li>
    <% end_control %>
    </ul>
    <% end_if %>

    It now comes with the following error message:

    Parse error: syntax error, unexpected '}'

  • kudesign
    Avatar
    Community Member
    64 Posts

    Re: Multi Language Issues Link to this post

    Hi there, I am having the same problem, it switches languages for me, but it does not say ' Show page in <language>', instead it says '<% sprintf(_t('SHOWINPAGE','Show page in %s'),$Locale.Nice)%>'.... The system doesn't seem to recognize this line of code.

    Any tips?

    I am running v2.3.2 at the moment. Thanks for sharing!!!

  • dickv
    Avatar
    Community Member
    3 Posts

    Re: Multi Language Issues Link to this post

    Is there a space between

    $Locale.Nice)

    and

    %>

  • kudesign
    Avatar
    Community Member
    64 Posts

    Re: Multi Language Issues Link to this post

    Thanks for the reply. I entered the spaces,

    <% sprintf(_t('SHOWINPAGE','Show page in %s'),$Locale.Nice) %>

    and it reads a little better iin the live site, it says: 'Show page in' But it still does not type the 'language name'.

    It must be something easy to do for the system to type the name of the available language, the information in the silverstripe doc require updating I think...

    Please help silverstripe team!

  • kudesign
    Avatar
    Community Member
    64 Posts

    Re: Multi Language Issues Link to this post

    When I take out .nice

    <% sprintf(_t('SHOWINPAGE','Show page in % s'),$Locale) %>

    In the English site it reads:

    'Show the page in en_GB'

    In the Chinese site it reads:

    'Show the page in zh_TW'

    Now I just need the system to translate en_GB to say 'English', and zh_TW to say 'Chinese'

    PLEASE HELP!!

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: Multi Language Issues Link to this post

    Hm, zh_TW is probably not in the i18n::$common_locales table, see http://doc.silverstripe.com/doku.php?id=multilingualcontent#add_new_locales

  • lerni
    Avatar
    Community Member
    80 Posts

    Re: Multi Language Issues Link to this post

    just in case someone else is struggling with this as well. this post helped me:

    http://silverstripe.org/template-questions/show/265935

    3627 Views
Page: 1
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.