OK, that explain the issue. Maybe that behavior should be more clear in the docs.
I think that I "broked" the behavior with my DRY logic because I run this code for all languages:
And probably should be only executed for the other languages that the main app language.
El miércoles, 13 de mayo de 2015, 9:41:42 (UTC+1), José Lorenzo escribió:
-- I think that I "broked" the behavior with my DRY logic because I run this code for all languages:
$entity->translation($lang)->set($translated_fields, ['guard' => false]);
And probably should be only executed for the other languages that the main app language.
El miércoles, 13 de mayo de 2015, 9:41:42 (UTC+1), José Lorenzo escribió:
The behavior is thought so that the main application language is store in the real table and all the translations in the i18n table
On Tuesday, May 12, 2015 at 10:40:25 AM UTC+2, Aday Talavera wrote:While following the guide http://book.cakephp.org/3.0/en/orm/behaviors/translate. to apply translate behaviour to my models I detected some problems, but I don't know if I'm following bad the guide or if the guide needs to be improved.html
Let me explain using an example.
I had this table in my system and wanted to apply translate behavior.
CREATE TABLE `boards` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`description` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
So I added this to BoardsTable initialize method:
$this->addBehavior('Translate', [
'fields' => ['name', 'description'],
]);
And added TranslateTrait to BoardEntity
In that scenario I detected the next things:
- If I create a new board providing english and spanish texts, they are stored correctly in i18n table.
- If I edit an existing board before applying Translate behavior, current locale language (spanish) is stored in boards.name and boards.description while english locale is stored in i18n table.
- If I nullify name and description fields before editing the row in point 2, everything is stored in i18n table.
How can we avoid point 2 issue? Is a bug or I missed something?
Cheers.
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:
Post a Comment