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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Duplicating entire website into new language, get error :(

Go to End

3 Posts   1734 Views


Community Member, 267 Posts

10 February 2011 at 4:10am

Edited: 10/02/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

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 does
   protected $Locale = 'en_US'; // language of the pages you want to translate
   protected $newLocale = 'de_DE'; // the language it should get translated to

   function 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);
   protected function debugMessage($msg) {
      if(!SapphireTest::is_running_test()) {


Community Member, 267 Posts

14 February 2011 at 8:12am



Community Member, 36 Posts

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. =)