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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Releases and Announcements /

Latest news about the SilverStripe software.

Moderators: martimiz, Sean, Ed, biapar, assertchris, Willr, Ingo, swaiba, Graves

2.3 - Default Language Bug ?


Go to End


38 Posts   12271 Views

Avatar
Juanitou

Community Member, 323 Posts

10 May 2009 at 10:09pm

Edited: 10/05/2009 10:11pm

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

Avatar
Ingo

Forum Moderator, 801 Posts

11 May 2009 at 8:05am

Edited: 11/05/2009 8:10am

@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

Avatar
Juanitou

Community Member, 323 Posts

11 May 2009 at 8:32pm

@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

Avatar
ChrisBryer

Community Member, 95 Posts

10 June 2009 at 5:00am

Edited: 10/06/2009 5:48am

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

Avatar
Ingo

Forum Moderator, 801 Posts

10 June 2009 at 9:01am

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

Avatar
ChrisBryer

Community Member, 95 Posts

10 June 2009 at 12:52pm

Edited: 10/06/2009 3:18pm

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

Go to Top