Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » Enable translation of templates (i18n)

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 10601 Views
  • Tobbe
    Community Member
    25 Posts

    Enable translation of templates (i18n) Link to this post


    I have been struggling some time trying to translate some of the templates of my site. This example below is done on a fresh install of SS 2.2.1.

    This is what I tried and what happens...

    1) add the i18n::enable(); to my _config.php file in mysite folder.
    2) run the /db/build
    3) open my Page.ss file in my Theme directory and add <% _t('LOGOTEXT', 'my logo') %> to the template
    4) run the /i18n/textcollector and it says it created three files (cms, saphire, auth_openid). Shouldn't it create one for mysite too?
    5) I try to go to my site, I get FATAL ERROR: Locale file /lang/en_US.php should exist
    At line 1251 in C:\xampp\htdocs\ss2\sapphire\core\i18n.php

    I tried to create a new en_US.php file and place it in a lang folder. But where should it be placed? I thought I should place it in the mysite folder, but that doesn't work.

    Anyone that can see that I have done wrong?

    many thanks!

  • MIke
    Community Member
    7 Posts

    Re: Enable translation of templates (i18n) Link to this post

    I know that you are still working on a i18n modules final versions. But I have the same kind of issue, I do not success to use themes and the function _t in a templates.
    From what i read in the log irc, I can forget to use this in the templates of the widget but it works in the templates of a pages.
    So my questions is very similar than tobbe.

    Where should I put my lang folder:
    - mysite\lang\en_US.php (in my site)
    - or themes\Mythemes\lang\en_US.php or themes\lang\en_US.php (in a theme folder)

    Or both ?

    And after when you run http://localhost/silverstripe-v2.2.1/i18n/textcollector/
    Should you see appears this folders ? because in fact I tried the 3 solutions above and at each time I just saw :

    Collecting text...

    Created file: C:/wamp/www/silverstripe-v2.2.1/auth_openid/lang/en_US.php
    Created file: C:/wamp/www/silverstripe-v2.2.1/cms/lang/en_US.php
    Created file: C:/wamp/www/silverstripe-v2.2.1/sapphire/lang/en_US.php

    Notice: I am able to use the class that I had in mysite/lang in the file code/page.php by the _t
    But not in the templates... Could you explain me the difference? How to manage templates and lang ?

    Thank you very much

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.