Sunday, December 23, 2012

Re: Translate behaviour / Save multiple languages at once

Hey

The translate behaviour seems to be quite bad documented.

If you want to work with it correctly, you've to mind to set the locale attribute:

$this->Yourmodel->locale = false; //storing multiple languages at once
$this->Yourmodel->locale = null; //will use the locale in your conf
$this->Yourmodel->locale = 'any string you that you makes happy';//custom one

if you save or retrieve the data you've to set that attribute!


greetz


Am Samstag, 1. Dezember 2012 16:29:56 UTC+1 schrieb LDSign:
Hi

Ive searched for several hours now and unfortunatly the translate behaviour does not work as expected. I try to save multiple translation fields at once like so:

echo $this->Form->adminText('name.deu',__('Name german'));
echo $this->Form->adminText('name.eng',__('Name english'));

 My controller (save)action is unmodified from the one baked. In the model Ive correctly included the translate behaviour:

public $actsAs = array('Translate' => array('name'));

Cake-Version is 2.2.3

So what happens? I expect that the two name fields would be saved to the i18n table under their corresponding langauge after transmitting the form. But instead of this only the (actual) language stored in the session will be used...so only one language-entry is added to the i18n table and the other language will be completly ignored.

After searching the net several people had success with the approach shown above, but on my side it doesn't work. What I am doing wrong? Is this a bug?

Thank you for your help.

Greetings,
Frank

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: