views:

425

answers:

2

Quoting from the cakephp Book (ver 1.3):

Note that only fields of the model you are directly doing find on will be translated. Models attached via associations won't be translated because triggering callbacks on associated models is currently not supported.

Has anyone come up with a solution for this???

If not could you give me some pointers concerning the following simple scenario.

I have 2 models: Project, Category.
Project HABTM Category
I have properly set up i18n table and I have a few entries in the db, all translated.
When I retrieve a project it does retrieve the translation but not the translated category because as it says in the cakephp book models attached via associations won't be translated.

Any help would be appreciated

A: 

OK I found a solution. Which is mostly a workaround. I should have thought of that earlier.

What I'm doing is the following. I'm finding all projects and recursively all categories associated with projects. Now since cakephp does not translate categories I am using the results from the initial query and I am performing a second one only for categories but using the category id values that I found on the first query. Now cakephp translates categories since I'm only searching for them and I can have their data translated.

At the moment I'm OK with this solution but it would be nice if first cakephp makes the translate behavior out of the box ready or secondly if someone had a behavior that could support retrieval of translation on associated models.

ion
A: 

Same workarround here

RRazo
Good to know I'm not alone!
ion