Jump to:

3393 Posts in 976 Topics by 852 members

Template Questions

SilverStripe Forums » Template Questions » i18n in main Template Page.ss

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

Page: 1
Go to End
Author Topic: 2228 Views
  • baba-papa
    Avatar
    Community Member
    279 Posts

    i18n in main Template Page.ss Link to this post

    The links in my main navigation have to be translated. They are static and lead to another site. I know how to work with i18n, but this is only described for modules, not for the templates of a theme.

    I appreciate any help.

  • Xeal
    Avatar
    Community Member
    37 Posts

    Re: i18n in main Template Page.ss Link to this post

    If you have the latest SS version 3.2.2 all you have to do is go to the translations tab and create your translations from there. (You have to manually translate the links). This will allow you to make as many different translations for your site as you want.

    Unless I'm mistaken and what you want is to change the language of your site? in Which case all you have to do is put this line
    i18n::set_locale('de_DE');
    Replacing de_DE with your locale of choice of course.
    in the mysite/_config.php file

  • baba-papa
    Avatar
    Community Member
    279 Posts

    Re: i18n in main Template Page.ss Link to this post

    Thanks for Your answer, Xeal. The translationfile de_DE.php contains the following line:

    i18n::include_locale_file('modules: blog', 'en_US');


    The Page.ss is not part of a module. Where do i put those translation files?

  • Xeal
    Avatar
    Community Member
    37 Posts

    Re: i18n in main Template Page.ss Link to this post

    The way I make translations for Page.ss is bu going into the sapphire/lang/<language> files and adding whatever I need.

    $lang['en_US']['Page.ss']['Link'] = 'Lien';
    $lang['fr_FR']['Page.ss']['Link'] = 'Link';

    and then in the Page.ss file you want to add a line that looks like this:
    <% _t("Link","link") %>

    That should do it for translations just add as many as you need.

  • baba-papa
    Avatar
    Community Member
    279 Posts

    Re: i18n in main Template Page.ss Link to this post

    Thanks for Your help Xeal. I will try this way.

  • baba-papa
    Avatar
    Community Member
    279 Posts

    Re: i18n in main Template Page.ss Link to this post

    I tried it and it works, thanks again Xeal. I really have to say, that I love Silverstripe for it´s features anf fexibility

  • Kalileo
    Avatar
    Community Member
    127 Posts

    Re: i18n in main Template Page.ss Link to this post

    Let me suggest to add your translations not to sapphire/lang/<language> but to cms/lang/<language> or even better to mysite/lang/<language> - that way it does not get overwritten when you upgrade.

  • biapar
    Avatar
    Forum Moderator
    435 Posts

    Re: i18n in main Template Page.ss Link to this post

    Good..

    2228 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.