blubb
borriej you lazy person :P
since you need to copy the pages to translate them, i think the best practice will be to use the existing createTranslation method
(if needed to duplicate the pages and not translate them, there is also a function calls "duplicate" ($newpage = $Page->duplicate();))
here the way i would try
(i can't promise you that it will work, never tested, you should do a backup before you run my code
go to /mysite/code
create a new file
<?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 does
protected $Locale = 'en_US'; // language of the pages you want to translate
protected $newLocale = 'de_DE'; // the language it should get translatet 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);
$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);
}
}
}
don forget the set $Locale and $newLocale !
then go to yoursite.com/dev/tasks and run this task, and see if it works :P
greetings <°(((-<
// Edit: fixed typos