Rails 3.1 [DEPRECATION WARNING] Nested I18n namespace lookup is no longer supported

New Rails, new i18n, new warnings:

[DEPRECATION WARNING] Nested I18n namespace lookup under "activerecord.attributes.admin" is no longer supported
[DEPRECATION WARNING] Nested I18n namespace lookup under "activerecord.attributes.scanlation" is no longer supported
[DEPRECATION WARNING] Nested I18n namespace lookup under "activerecord.attributes.manga" is no longer supported
[DEPRECATION WARNING] Nested I18n namespace lookup under "activerecord.attributes.character" is no longer supported

From now on, you cannot use nested namespaced models translations. Lil bit weird since I remember, that when I've been moving from 2.3.7 to 3.0 I needed to do opposite thing.

Fix is easy to implement, just replace nested stuff like:

pl:
  admin:
    su: "Super user"

with slash separeted names:

pl:
  "admin/su": "Super user"

Same for attributes and warning will disappear.

Categories: Rails, Ruby

2 Comments

  1. Ta… W jednej z wersji 3.0.* ten sposób zaczął działać ale okazało się, że to był bug, który trwał kilka wersji 3.0.*, później się zorientowali i poprawili ale okazało się, że ludzie już zaczęli tego używać dlatego do końca 3.0.* będą supportowane obie wersje ale w 3.1 już z powrotem tego nie ma. Masakrycznie zamotali w tej sprawie. Wszystko przez to, że tak długo nikt nie reagował na mega prosty błąd, że ludzie myśleli, że nowy sposób to ficzer a nie bug.

    Bug jest dlatego, że są konflikty przy sposobie z kropkami kiedy się zagnieżdża klasy w namespacie podchodzącym od innej klasy a nie od modułu.

  2. I think that this solution don’t work for all cases as I I’ve said here https://github.com/rails/rails/issues/1869#issuecomment-2100403

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Copyright © 2024 Closer to Code

Theme by Anders NorenUp ↑