Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

i18n key collision with namespaced models

#6448

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'

Reported by yves.senn (at gmail) · February 18th, 2011 @ 01:51 PM

State: committed
Milestone: 3.0.6
Assigned to: Santiago Pastorino Santiago Pastorino
Importance: Medium

Activity

  1. José Valim
    José Valim
    • 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.

    February 18th, 2011 @ 02:30 PM

  2. yves.senn (at gmail)
  3. Santiago Pastorino
    Santiago Pastorino
    • Milestone set to 3.0.5
    • Assigned user set to Santiago Pastorino
    • Importance changed from Low to Medium

    February 18th, 2011 @ 03:29 PM

  4. yves.senn (at gmail)
    yves.senn (at gmail)

    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?

    February 24th, 2011 @ 07:30 AM

  5. Santiago Pastorino
    Santiago Pastorino
    • Milestone changed from 3.0.5 to 3.0.6

    February 27th, 2011 @ 03:15 AM

  6. Repository
    Repository
    • State changed from open to committed

    (from [a00bed0c48f469d1cd2de364bfaddbc724046195]) Revert "Properly interpolate i18n keys in modules [#5572 [PATCH] Fix i18n scope bug when class belongs to a module state:resolved]"

    This breaks #6448 i18n key collision with namespaced models, you should use :"module/class" as key for namespacing
    [#6448 i18n key collision with namespaced models state:committed]

    This reverts commit 8d30193b08bd2321a7a78a1f481bd5e4d4d45557.
    https://github.com/rails/rails/commit/a00bed0c48f469d1cd2de364bfadd...

    February 27th, 2011 @ 11:44 PM

  7. Repository
    Repository

    (from [f80eea3bf30dcceaca3c4a9cd9238bdc44a9e165]) Revert "Properly interpolate i18n keys in modules [#5572 [PATCH] Fix i18n scope bug when class belongs to a module state:resolved]"

    This breaks #6448 i18n key collision with namespaced models, you should use :"module/class" as key for namespacing
    [#6448 i18n key collision with namespaced models state:committed]

    This reverts commit 8d14fa89599a30a6ab1d14faedd2de8e46651272.
    https://github.com/rails/rails/commit/f80eea3bf30dcceaca3c4a9cd9238...

    February 27th, 2011 @ 11:49 PM

  8. Rodrigo Rosenfeld Rosas
    Rodrigo Rosenfeld Rosas

    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!

    February 28th, 2011 @ 12:34 AM

  9. yves.senn (at gmail)
    yves.senn (at gmail)

    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.yml

    where 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.

    March 2nd, 2011 @ 10:57 AM

  10. Robert Pankowecki
  11. José Valim
    José Valim

    So we can consider 6034 as fixed as well?

    March 30th, 2011 @ 09:38 AM