For my module Content Blocks: https://github.com/NobrainerWeb/Silverstripe-Content-Blocks
i would like to handle translations in a simple way.
What i would like to do is, when a page is translated
- duplicate all the many_many Blocks of that page
- change the relation for the Block from page in old language to page in new language
I have seen that there is some kind of hook in on the translatable class: "onTranslatableCreate", but how do i use this, to do the above?
I'm guessing i have to add something along the lines of the following to my https://github.com/NobrainerWeb/Silverstripe-Content-Blocks/blob/master/code/ContentBlocksModule.php
public function onTranslatableCreate() {
$pageblocks = $this->owner->Blocks();
foreach($pageblocks as $orgBlock) {
//print_r($orgBlock);
//exit();
$block = $orgBlock->duplicate(false);
$block->ParentID = $duplicateWidgetArea->ID;
$block->write();
}
}
But the function onTranslatableCreate does not get called.
Any help greatly appriciated :o)