Jump to:

3460 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » $lang variable?

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

Page: 1
Go to End
Author Topic: 1448 Views
  • Tempesta
    Avatar
    Community Member
    8 Posts

    $lang variable? Link to this post

    Hey everybody, this is my first post here! I'm building a site with three languages, and I'm having a flash presentation in there too. But since this one is getting the data from a .xml file, it doesnt know what language the site is in. Is there a variable I can send to it to let it know, like a $lang variable or something?

    Thanks

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: $lang variable? Link to this post

    How is your XML generated, and with which data? You could attach a ?lang GET parameter and evaluate that whereever the XML is generated in your controller?

  • Tempesta
    Avatar
    Community Member
    8 Posts

    Re: $lang variable? Link to this post

    Thanks Ingo, for your reply!

    I'm sorry, I wasnt clear, this XML is made outside of silverstripe manually, so never mind that part.
    What I do is I send some information from silverstripe to flash via Javascript.

    I can send $MenuTitle forexample, but I don't know how to get the language, I was hoping there was a $Lang variable or something but there wasn't..

    So what do I need to do here guys?

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: $lang variable? Link to this post

    You're right, in 2.2.x there's no way to find out the language for an existing DataObject instance, apart from inspecting Translatable::current_lang(). This will change in one of the next minor releases, where an overhaul of the Translatable datamodel is planned. Every object has an explicit $Lang property in the new implementation.

  • Tempesta
    Avatar
    Community Member
    8 Posts

    Re: $lang variable? Link to this post

    So how would I go about with the "Translatable::current_lang()", is there a tutorial or something on it?

  • Tempesta
    Avatar
    Community Member
    8 Posts

    Re: $lang variable? Link to this post

    Is there a function I can build in page.php file, so that I can do a <%control%> thing or something, this is kind of important! If anyone can give me a quick overview of what needs to be done, that would be great. The site I am working on has quite a lot of custom templates and stuff, so I would like to postpone the upgrade for now. I'm running 2.2.3.

    I tried a workaround and built different templates for the different languages but then i got the " Fatal error: Call to a member function getAllFields() on a non-object in /usr/data/www/adell.adgrp.net/sapphire/core/model/Translatable.php on line 588 " error, which is also a hazzle to fix.

    Kind of stuck here.

    Thanks, Marius

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