Jump to:

659 Posts in 2116 Topics by 163 members

Releases and Announcements

SilverStripe Forums » Releases and Announcements » 2.3 - Default Language Bug ?

Latest news about the SilverStripe software.

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

Page: 1 2 3 4 5
Go to End
Author Topic: 7297 Views
  • Juanitou
    Avatar
    Community Member
    323 Posts

    Re: 2.3 - Default Language Bug ? Link to this post

    I've been playing with a LanguageSwitcher function and remarked that I can't make work any of Translatable::hasTranslation or Translatable::getTranslationGroup (and so Translatable::getTranslation, Translatable::getTranslations, etc.).

    It's maybe my lack of PHP knowledge, but if I add such a function in Page_Controller and load a page that positively has a translation:

    function TestTranslatable () {
       $langs = Translatable::get_existing_content_languages();
       Debug::show($langs); // It works!
       $translationGroupID = Translatable::getTranslatedLangs();
       Debug::show($translationGroupID); // It shows nothing
       die();
    }

    I can see the two languages I have used but nothing related with the actual page. I can't debug the PHP or SQL behind those functions. Am I doing something wrong?

    Best regards,
    Juan

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: 2.3 - Default Language Bug ? Link to this post

    @Juanitou: You're calling getTranslatedLangs() as a static method, which should give you a PHP error anyway ("Using $this in a static context"). This method is used to get translations for an instance.

    Thanks for your _config.php addition - this is something we should check when setting locales: http://open.silverstripe.com/ticket/4038

  • Juanitou
    Avatar
    Community Member
    323 Posts

    Re: 2.3 - Default Language Bug ? Link to this post

    @Ingo: Thanks for the explanation. I've been reading the PHP manual trying to better understand how OOP works, it's tough! I'll look for examples of use of these Translatable methods in the SS code, soon or later I'll get it!

    Best regards,
    Juan

  • ChrisBryer
    Avatar
    Community Member
    95 Posts

    Re: 2.3 - Default Language Bug ? Link to this post

    Hi guys,
    i am having problems with translating dataobjects: a few problems (these could completely be user error, so please let me know if i am doing anything wrong):

    1 is that CTF's with autorelation turned on creates a relation between a databoject and a pageID. translatable seems to create a second sitetree record with a different ID so all my dataobjects arent tied to the page anymore. any recommendations on how to keep the page-dataobject relation?

    the second problem is that i can CRUD dataobjects through the default en_US locale via any CTF, but when i switch to another language, when i try to create, read, or update through the CTF, the popup says 'I can't handle sub-URL's of a CMSMain object.' no errors are caught.

    the last problem is that when I add

    Object::add_extension('DOArticle', 'Translatable'); // DOArticle is a pretty simple extended DataObject


    to mysite/_config.php and rebuild the database i get

    [User Error] Couldn't run query: SELECT "DOArticle"."ClassName", "DOArticle"."Created", "DOArticle"."LastEdited", "DOArticle"."SourceOfArticle", "DOArticle"."SourceURL", "DOArticle"."ArticleDate", "DOArticle"."Locale", "DOArticle"."SourceLogoID", "DOArticle"."ID", CASE WHEN "DOArticle"."ClassName" IS NOT NULL THEN "DOArticle"."ClassName" ELSE 'DOArticle' END AS "RecordClassName" FROM "DOArticle" WHERE ("SiteTree"."ID" = 2) LIMIT 1 Unknown column 'SiteTree.ID' in 'where clause'

    GET /dev/build

    Line 516 in \sapphire\core\model\MySQLDatabase.php

    Trace

    * Couldn't run query: SELECT "DOArticle"."ClassName", "DOArticle"."Created", "DOArticle"."LastEdited", "DOArticle"."SourceOfArticle", "DOArticle"."SourceURL", "DOArticle"."ArticleDate", "DOArticle"."Locale", "DOArticle"."SourceLogoID", "DOArticle"."ID", CASE WHEN "DOArticle"."ClassName" IS NOT NULL THEN "DOArticle"."ClassName" ELSE 'DOArticle' END AS "RecordClassName" FROM "DOArticle" WHERE ("SiteTree"."ID" = 2) LIMIT 1 Unknown column 'SiteTree.ID' in 'where clause'

    Line 516 of MySQLDatabase.php
    * MySQLDatabase->databaseError(Couldn't run query: SELECT "DOArticle"."ClassName", "DOArticle"."Created", "DOArticle"."LastEdited", "DOArticle"."SourceOfArticle", "DOArticle"."SourceURL", "DOArticle"."ArticleDate", "DOArticle"."Locale", "DOArticle"."SourceLogoID", "DOArticle"."ID", CASE WHEN "DOArticle"."ClassName" IS NOT NULL THEN "DOArticle"."ClassName" ELSE 'DOArticle' END AS "RecordClassName" FROM "DOArticle" WHERE ("SiteTree"."ID" = 2) LIMIT 1 | Unknown column 'SiteTree.ID' in 'where clause',256)

    Line 107 of MySQLDatabase.php
    * MySQLDatabase->query(SELECT "DOArticle"."ClassName", "DOArticle"."Created", "DOArticle"."LastEdited", "DOArticle"."SourceOfArticle", "DOArticle"."SourceURL", "DOArticle"."ArticleDate", "DOArticle"."Locale", "DOArticle"."SourceLogoID", "DOArticle"."ID", CASE WHEN "DOArticle"."ClassName" IS NOT NULL THEN "DOArticle"."ClassName" ELSE 'DOArticle' END AS "RecordClassName" FROM "DOArticle" WHERE ("SiteTree"."ID" = 2) LIMIT 1,256)

    Line 120 of DB.php
    * DB::query(SELECT "DOArticle"."ClassName", "DOArticle"."Created", "DOArticle"."LastEdited", "DOArticle"."SourceOfArticle", "DOArticle"."SourceURL", "DOArticle"."ArticleDate", "DOArticle"."Locale", "DOArticle"."SourceLogoID", "DOArticle"."ID", CASE WHEN "DOArticle"."ClassName" IS NOT NULL THEN "DOArticle"."ClassName" ELSE 'DOArticle' END AS "RecordClassName" FROM "DOArticle" WHERE ("SiteTree"."ID" = 2) LIMIT 1)

    Line 396 of SQLQuery.php
    * SQLQuery->execute()
    Line 2615 of DataObject.php
    * DataObject->instance_get_one("SiteTree"."ID" = 2,)
    Line 2552 of DataObject.php
    * DataObject::get_one(DOArticle,"SiteTree"."ID" = 2,1,)
    Line 623 of Versioned.php
    * Versioned::get_one_by_stage(DOArticle,Stage,"SiteTree"."ID" = 2)
    Line 536 of Translatable.php
    * Translatable->requireDefaultRecords(,,,,,,)
    Line 749 of Object.php
    * Object->extend(requireDefaultRecords,)
    Line 2771 of DataObject.php
    * DataObject->requireDefaultRecords()
    Line 216 of DatabaseAdmin.php
    * DatabaseAdmin->doBuild(,1)
    Line 103 of DatabaseAdmin.php
    * DatabaseAdmin->build()
    Line 130 of DevelopmentAdmin.php
    * DevelopmentAdmin->build(HTTPRequest)
    Line 129 of RequestHandler.php
    * RequestHandler->handleRequest(HTTPRequest)
    Line 127 of Controller.php
    * Controller->handleRequest(HTTPRequest)
    Line 280 of Director.php
    * Director::handleRequest(HTTPRequest,Session)
    Line 121 of Director.php
    * Director::direct(/dev/build)
    Line 122 of main.php

    I'd love to know if i am doing anything wrong with anything.

    thanks alot,
    -Chris

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: 2.3 - Default Language Bug ? Link to this post

    The requireDefaultRecords() issue should be fixed in branches/2.3 now, thanks for reporting!

  • ChrisBryer
    Avatar
    Community Member
    95 Posts

    Re: 2.3 - Default Language Bug ? Link to this post

    Thanks alot Ingo,
    that and the patch fixed a lot of things.
    I'm just curious now if dataobjects from the english (default) translation should show up in the german CTF (even without the autorelation set to true)? I was thinking that adding a Translatable extension to a DataObject would give 'original text' fields and 'translation fields', but the DataObjects just seem to show up like normal and I dont see any DataObjects that I've already created in a CTF.

    also, DataObjects show up in HasManyCTFs, but if they are checked off in the english translation they are disabled in the german version.

    just curious if you can shed a little light on if this is normal behavior or not,

    **EDIT**
    There is a locale textfield that shows up in the popup which if left blank gets filled in as the current locale, but the record only shows up in one locale and not across all locales. not sure if i'm doing anything wrong or not.

    thanks again for all the help,
    -Chris

    7297 Views
Page: 1 2 3 4 5
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.