This project is archived and is in readonly mode.
i18n key collision with namespaced models
Reported by yves.senn (at gmail) | February 18th, 2011 @ 01:51 PM | in 3.0.6
I just upgraded from Rails 3.0.0 to Rails 3.0.4 and I noticed, that the way to add translations to namespaced models changed from using a "/" to nesting. I am now facing a problem that, I have an attribute, which has the same name as the namespaced model. This creates a key collision and one of the translations is overridden.
Outer model:
en:
activerecord:
models:
article:
one: Article
other: Articles
attributes:
article:
category: Category
Namespaced Model:
en:
activerecord:
models:
article:
category:
one: Category
other: Categories
attributes:
article:
category:
description: Description
In the example above I got a collision on the key: 'activerecord.attributes.article.category'
Comments and changes to this ticket
-
José Valim February 18th, 2011 @ 02:30 PM
- State changed from new to open
- Importance changed from to Low
Bug added in this commit:
https://github.com/rails/rails/commit/8d30193b08bd2321a7a78a1f481bd...
We just need a test and revert it.
-
yves.senn (at gmail) February 18th, 2011 @ 02:59 PM
I added a test, which reveals the key collision.
-
Santiago Pastorino February 18th, 2011 @ 03:29 PM
- Milestone set to 3.0.5
- Assigned user set to Santiago Pastorino
- Importance changed from Low to Medium
-
yves.senn (at gmail) February 24th, 2011 @ 07:30 AM
i've just seen, that 3.0.5.rc1 has been released. Do you think this is still gonna make it into 3.0.5?
-
Santiago Pastorino February 27th, 2011 @ 03:15 AM
- Milestone changed from 3.0.5 to 3.0.6
-
Repository February 27th, 2011 @ 11:44 PM
- State changed from open to committed
(from [a00bed0c48f469d1cd2de364bfaddbc724046195]) Revert "Properly interpolate i18n keys in modules [#5572 state:resolved]"
This breaks #6448, you should use :"module/class" as key for namespacing
[#6448 state:committed]This reverts commit 8d30193b08bd2321a7a78a1f481bd5e4d4d45557.
https://github.com/rails/rails/commit/a00bed0c48f469d1cd2de364bfadd... -
Repository February 27th, 2011 @ 11:49 PM
(from [f80eea3bf30dcceaca3c4a9cd9238bdc44a9e165]) Revert "Properly interpolate i18n keys in modules [#5572 state:resolved]"
This breaks #6448, you should use :"module/class" as key for namespacing
[#6448 state:committed]This reverts commit 8d14fa89599a30a6ab1d14faedd2de8e46651272.
https://github.com/rails/rails/commit/f80eea3bf30dcceaca3c4a9cd9238... -
Rodrigo Rosenfeld Rosas February 28th, 2011 @ 12:34 AM
I didn't understand the test for key collision nor the instructions for using "module/class" as key. For instance, using the standard i18n backend, would the yaml look like below?
# encoding: utf-8 module/class: name: 'Nome'
Also, how is the situation described in this ticket is achieved? Are they two separate yaml files? In what directories? How does it make sense?
Thanks in advance!
-
yves.senn (at gmail) March 2nd, 2011 @ 10:57 AM
the situation is achieved when you got a single yaml file for every model. We have the following directory structure:
config/locales/models/person/de.yml
config/locales/models/person/status/de.ymlwhere the model Person::Status is a namespaced model. We have to use a legacy database with a lot of Status models, so we namespaced them to the corresponding model. since the Person has a status attribute. there is a key collision.
I hope you can follow my explanations.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 5572 [PATCH] Fix i18n scope bug when class belongs to a module [#6448, #5572] https://github.com/rails/rails/commit/030...
- 5572 [PATCH] Fix i18n scope bug when class belongs to a module [#6448, #5572] https://github.com/rails/rails/commit/5b8...
- 5572 [PATCH] Fix i18n scope bug when class belongs to a module This breaks #6448, you should use :"module/class" as key ...
- 5572 [PATCH] Fix i18n scope bug when class belongs to a module This breaks #6448, you should use :"module/class" as key ...
- 6448 i18n key collision with namespaced models This breaks #6448, you should use :"module/class" as key ...
- 6448 i18n key collision with namespaced models This breaks #6448, you should use :"module/class" as key ...
- 6448 i18n key collision with namespaced models This breaks #6448, you should use :"module/class" as key ...
- 6448 i18n key collision with namespaced models This breaks #6448, you should use :"module/class" as key ...
- 5572 [PATCH] Fix i18n scope bug when class belongs to a module This breaks #6448, you should use :"module/class" as key ...
- 5572 [PATCH] Fix i18n scope bug when class belongs to a module This breaks #6448, you should use :"module/class" as key ...