21293 Posts in 5733 Topics by 2602 members
General Questions
SilverStripe Forums » General Questions » Duplicating entire website into new language, get error :(
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 1113 Views |
-
Duplicating entire website into new language, get error :(

10 February 2011 at 4:10am Last edited: 10 February 2011 4:16am
I have this script to duplicate my website into a new language. It worked perfect a while ago, but now (on a different server much bigger sitetree) it wont work.
I get this error
[User Error] Translatable::createTranslation(): Please save your record before creating a translation
GET /sapphire/main.php?url=/dev/tasks/TranslatePages&But i don't know what i need to save? :s Please help!
The script
<?php
class TranslatePages extends BuildTask {protected $title = "Translate all Pages";
protected $description = 'Copys all Pages into another Language (Note: set $Locale and $newLocale!)'; // description of what it doesprotected $Locale = 'en_US'; // language of the pages you want to translate
protected $newLocale = 'de_DE'; // the language it should get translated tofunction run($request) {
$Pages = DataObject::get('SiteTree', "Locale = '".$this->Locale."'");foreach ($Pages as $Page) {
if(!$Page->getTranslation($this->newLocale)) {
$newPage = $Page->createTranslation($this->newLocale);
//$newPage = createTranslation($this->newLocale);
$this->debugMessage('Translated '.$Page->Title.' from '.$this->Locale.' to '.$this->newLocale);
}
}
$this->debugMessage('Done');
}
protected function debugMessage($msg) {
if(!SapphireTest::is_running_test()) {
Debug::message($msg);
}
}
} -
Re: Duplicating entire website into new language, get error :(

21 October 2011 at 10:31pm
I know its a late reply, but i just ran into the same problem.
The reason i got this error was because of orphaned pages in my sitetree. One page was still inside the DB but had no parent. That broke the createTranslation function.
Hope this helps someone with the same problem. =)
| 1113 Views | ||
|
Page:
1
|
Go to Top |
