Hello,
I have a problem with 'translate' behaviour from cake. I want to use it to
add news to the website in several languages, however I want to add them all
simultaneously from one form. By now I have managed to do an 'add' function.
Maybe not in the most elegant way:
foreach ($languages as $language) {
$iso = $language['iso639_3'];
if ((!empty($this->data['News'][$iso]['title'])) &&
(!empty($this->data['News'][$iso]['text']))) {
$this->data['News']['title'] =
$this->data['News'][$iso]['title'];
$this->data['News']['text'] =
$this->data['News'][$iso]['text'];
$this->News->locale = $iso;
if (!$this->News->save($this->data))
return;
}
}
Here the $languages variable is an array representing the languages used in
my applications. Each element contains 'iso693_3' field with it's language
code. This code iterates this array and saves the data several times. The
view looks like this:
<?php foreach ($languages as $language): ?>
<?php echo '<div id="tab-'.$language['iso639_3'].'">'?>
<?php echo $form->input("News.{$language['iso639_3']}.title",
array('label' => 'Nazwa')); ?>
<?php echo $form->input("News.{$language['iso639_3']}.text",
array('label'
=> 'Treść')); ?>
</div>
<?php endforeach ?>
So e.g. News['eng']['title'] coming from this form would be an English
translation of the message's title.
This works as intended. However, I can't find any solution to make a good
'edit' function, that would fill all the fields on the page with
corresponding translations.
What is the best way to do it (maybe the one intended by creators of the
behaviour?)
Best regards,
Szymon
--
View this message in context:
http://n2.nabble.com/Entering-several-translations-simultaneously-with-%27translate%27-behaviour-tp2945627p2945627.html
Sent from the CakePHP mailing list archive at Nabble.com.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---