Friday, December 4, 2015

CakePHP 2.x translation fallback

I need to have fallback in translation.

If I have 2 translations ex.: 'eng' and 'es'
Some records have both translations and some only one or none.
I hoped that if I do it this way:

$this->Post->locale = ['es', 'eng'];  $results = $this->Post->find('first', array(      'conditions' => array('Post.id' => $id)  ));
I'll get 'es' translation and if 'es' is not available I'll get 'eng'.
but this does not seem to work. If I set 'locale' to a single value 'eng' or 'es' it works fine, but when I set $this->locale = ['es', 'eng'];
It seems to be ignored and no translation is taken into the result, just data from model table.

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: