Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Translatable datamodel changes and fixes
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Expand all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ingo Schommer  
View profile  
 More options Jan 12 2009, 10:16 pm
From: Ingo Schommer <i...@silverstripe.com>
Date: Tue, 13 Jan 2009 16:16:21 +1300
Local: Mon, Jan 12 2009 10:16 pm
Subject: Translatable datamodel changes and fixes
Hey guys,

I've recently merged in a whole heap of changes to the content-
translations in SilverStripe core (mostly around the Translatable  
decorator). They're mostly patches by Michael Gall (wakeless), so  
massive thanks to him for taking on this tricky bugfixing.

Most changes are contained in this commit to trunk (changelog below):
http://open.silverstripe.com/changeset/69959

These changes were necessary to simplify and fix behaviour of  
Translatable,
which was closely modeled to the Versioned decorator when it was created
during GSOC06. Keeping track of translated pages in separate tables  
(SiteTree_lang, etc)
meant that each SiteTree-related query had to be modified to join  
these additional tables.
This was implemented mainly by circumventing the ORM, and hooking  
straight into
the SQL calls, which proved to be very hard to maintain and errorprone.

With this in mind, we decided to switch the datamodel to have the  
translated records
contained in the original tables. So a french translation of a page  
would have a new record
in the SiteTree table, with a $Lang attribute denoting the language  
code, and an $OriginalID
field pointing back to the "master record". The decorator still has to  
modify queries,
but simply attaches a " AND Lang='fr'" condition instead of doing  
complicated joins.
We're just in the process of writing a migration script to convert old  
database schemas
including their data.

Another architectural decision which got us into trouble was the  
reliance on static state
to set the language context used in the decorator. This caused a lot  
of nasty side-effects
and workarounds, e.g. globally setting the language back and forth  
between default
and "current language" for specific calls. While this problem isn't  
complety solved,
Michael has made some progress in passing around this state explicitly  
through the call stack
with a new $context argument to methods (mostly in Hierarchy and  
CMSMain).
Sam was thinking about implementing different datamappers and gateways
between DataObject::get*() and the actual ORM-calls which could  
contain the current language.
Suggestions welcome of course!

I'm just writing some very basic unit tests for the new behaviour, and  
checking against
known bugs of the old implementation logged at http://open.silverstripe.com/query?status=assigned&status=new&status=...

While this is considered alpha code at the moment, I'd encourage  
everybody to have a look
at the changes and provide feedback!

Ingo

Changelog:
Merged, debugged and enhanced Translatable patches from branches/
translatable at r64523, r64523, 64523, thanks wakeless!
API CHANGE Changed Translatable schema from auxilliary tables  
(SiteTree_lang, SiteTree_lang_Live) to automatically filtered records  
on the original table (SiteTree, SiteTree_Live), using $Lang and  
$OriginalID properties. Incompatible update to old schema, migration  
script is in the works.
API CHANGE Removed Translatable::get_one(), Translatable::write()
ENHANCEMENT Simplified Translatable tree generation by using  
getSiteTreeFor() in CMSMain->createtranslation()
ENHANCEMENT Added AllChildrenIncludingDeleted(),  
augmentNumChildrenCountQuery(), augmentAllChildrenIncludingDeleted(),  
augmentStageChildren() to Translatable class to allow for more stable  
tree generation.
ENHANCEMENT Moved definition of Translatable schema from  
augmentDatabase() to Translatable->extraStatics()
ENHANCEMENT Changes to the CMS language selection refresh the whole  
admin interface instead of the tree only. This way we can add a URL  
parameter lang=<lang> to /admin, which makes the specific language  
bookmarkable and reloadable. Changes to LangSelector.js
ENHANCEMENT Added fallback to ModelAsController->getNestedController()  
to fetch page with matching URLSegment but different language in case  
no page is found in the current language.
ENHANCEMENT Added helper methods to Translatable: getTranslation(),  
hasTranslation(), isTranslation(), findOriginalIDs()
ENHANCEMENT Getters and setters for Translatable->getOriginalPage() etc.
ENHANCEMENT Hooking Translatable into ModelAsController and  
ContentController initialization in order to call choose_site_lang()
ENHANCEMENT Simplified Translatable->augmentSQL(), augmentWrite() by  
not using auxilliary tables
ENHANCEMENT Showing clickable links for Translations in Translatable-
 >updateCMSFields()
BUGFIX Modifying Hierarchy/SiteTree Children getters to accept  
optional "context" which can be used to set a language explicitly  
through the $Lang property, rather than implicitly reyling on the  
static Translatable::current_lang()
BUGFIX Fixed TranslatableTest to work with new datamodel
BUGFIX Temporarily disabled cookie/session selection in  
Translatable::choose_site_lang() until we have a good test suite for  
the side effects.
MINOR Added "untranslated" CSS styles to tree nodes and marking them  
as inactive/grey

-------
Ingo Schommer | Senior Developer
SilverStripe
http://silverstripe.com

Phone: +64 4 978 7330 ext 42
Skype: chillu23


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »