Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions /

Help needed with $Translations


Reply


5 Posts   1580 Views

Avatar
lokash20

Community Member, 14 Posts

13 September 2009 at 3:39am

Edited: 13/09/2009 3:42am

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.

Avatar
Ingo

Forum Moderator, 801 Posts

13 September 2009 at 6:30pm

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

Avatar
lokash20

Community Member, 14 Posts

14 September 2009 at 10:54pm

Edited: 14/09/2009 11:20pm

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.

Avatar
Ingo

Forum Moderator, 801 Posts

15 September 2009 at 9:12am

> 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

Avatar
lokash20

Community Member, 14 Posts

15 September 2009 at 10:12pm

Edited: 15/09/2009 11:19pm

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.