Jump to:

3445 Posts in 1031 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » Help needed with $Translations

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

Page: 1
Go to End
Author Topic: 1503 Views
  • lokash20
    Avatar
    Community Member
    14 Posts

    Help needed with $Translations Link to this post

    Hi,

    I have a local development site running MAMP 1.7.2 (PHP Version 5.2.6, Apache 2.0) on mac OS X 10.5 (Safari 4.0.3) and I am with 1and1 for my hosting. All seems to be fine except that I have come across some behaviour that I don't understand and can't seem to resolve - but then I'm not that deeply into the code.

    I have multilingual set in my _config.php using: Object::add_extension('SiteTree', 'Translatable'); with no default local defined, but I have two translations en_US and es_ES.

    Putting $Translations into my page template on my local dev site results in the following code being delivered in the web-page source:

    <li onclick="location.href = this.getElementsByTagName('a')[0].href"><a href="">whatever</a></li>

    Whereas it produces an empty result on my live site.

    FWIW $Locale gives the correct return on both sites.

    I have tried setting dev mode but nothing changes.

    Can anyone give me some pointers as to where I might look further for a resolution to the problem?

    Thanks.

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: Help needed with $Translations Link to this post

    Hm, to debug anything here we need the actual template code, not the generated markup.

  • lokash20
    Avatar
    Community Member
    14 Posts

    Re: Help needed with $Translations Link to this post

    Thanks Ingo, your post reminded me I'd not tired it with the default Blackcandy template (doh!) and, of course, it works with that so I need to do some template debugging.

    Edited to add ---

    Or not, as the case may be. After more playing around in the name of testing, it appears that some of the pages in the CMS admin aren't marked as existing translations (no idea what I managed to do there because the translations exist!) and that is why no translations appear. Also, the home pages are two of the pages that don't show a translation on the 'Translations' tab, but the ?locale=<whatever> switch works OK.

    So, new question:

    Is there any way I can easily add the necessary flags in the database to mark pages as translations of other pages, or should I just bite the bullet and re-create the pages?

    Another question:

    Is there a page control, such as $URLSegment, that returns a page URL of a translation of the current page? I want to switch between to language versions of a given page and ?locale=<whatever> only seems to work on the home page; which appears to be in keeping with the multilingual documentation.

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: Help needed with $Translations Link to this post

    > Is there any way I can easily add the necessary flags in the database to mark pages as translations of other pages, or should I just bite the bullet and re-create the pages?

    You can add entries to the SiteTree_translationgroups table manually, although thats not recommended unless you know what you're doing. Currently there's no way in the UI to retroactively associate pages to existing translations, sorry.

    > Is there a page control, such as $URLSegment, that returns a page URL of a translation of the current page? I want to switch between to language versions of a given page and ?locale=<whatever> only seems to work on the home page; which appears to be in keeping with the multilingual documentation.

    See http://doc.silverstripe.com/doku.php?id=multilingualcontent#switching_languages

  • lokash20
    Avatar
    Community Member
    14 Posts

    Re: Help needed with $Translations Link to this post

    Ok. I looked and wondered if the SiteTree_translationgroups table was the place.

    Thanks for the pointer. Sometimes we just need a nudge to see what's right in front of us: I had read the multilingual documentation and tried the ?locale= switch but, of course, if the translations aren't registered in my database, then that explains why it's not working properly for me. *sigh*.

    Thanks again for your help and patience, Ingo. It's much appreciated.

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