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):
These changes were necessary to simplify and fix behaviour of
which was closely modeled to the Versioned decorator when it was created
during GSOC06. Keeping track of translated pages in separate tables
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
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
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
but simply attaches a " AND Lang='fr'" condition instead of doing
We're just in the process of writing a migration script to convert old
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
and "current language" for specific calls. While this problem isn't
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
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
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!
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(),
augmentStageChildren() to Translatable class to allow for more stable
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-
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
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
Ingo Schommer | Senior Developer
Phone: +64 4 978 7330 ext 42