Hi,
as a cake newbe I'am also playing around with the translation
behaviour. This thread helped my much to get it working.
Right now I'm stucked with creating localized model records. This
works smoothly if i create a model record for each locale (lets say
article 1 for locale de_de, article 2 for locale en). But it fails if
I try to create 1 to n translations for a model record (article 1 for
locale de_de und locale en). This what I'm trying to do:
// create new article record
function create() {
if (isset ($this->data['Article']['locale'])) {
$this->Article->locale = $this->data['Article']['locale'];
}
if (!empty($this->data)) {
if ($this->Article>save($this->data)) {
$this->flash('Article been saved.', '/articles');
}
}
}
// update article record, this may mean that a new translation is
added or an old one is updated
function update($id = null) {
if (empty ($this->data)) {
$this->Article->id = $id;
$this->data = $this->Article->read();
} else {
// set locale
if (isset ($this->data['Article']['locale'])) {
$this->Article->locale =
$this->data['Article']['locale'];
}
if ($this->Article->save($this->data['Article'])) {
$this->flash('Article has been updated.', '/articles');
}
}
}
There is a way to accomplish this by changig the beforeFind and
afterSave methods of the TranslateBehavior class but fear that I may
have overlooked something. Any suggestions on that?
Thanks,
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---