Administrate: I18N: Attributes labels translation issue

Created on 4 Jul 2016  路  6Comments  路  Source: thoughtbot/administrate

Hello.

First of all, here's my locale/ru.yml:

ru:
  activerecord:
    attributes:
      user:
        email: Email
        password: 袩邪褉芯谢褜
        password_confirmation: 袩邪褉芯谢褜 械褖褢 褉邪蟹
        name: 袠屑褟
        role: 袪芯谢褜
        provider: OAuth-锌褉芯胁邪泄写械褉

Now in my User dashboard on _new/edit_ page (one which got the edit form) labels of attributes are displayed using thier translation from locale/ru.yml, but on _index_ and _show_ pages they are don't!

I've dived in sources and found out that on index page the translation is taken from helper.label section, not from the activerecord.attributes one.

I think translation sources should be unified all over Administrate pages and using activerecord.attribues section looks more straightforward to me.

Thank you.

bug i18n

Most helpful comment

@michaelkl I ran into this problem. So far, what I've done to avoid duplicated translations is this:


common: &commons
  patient:
    address: 'Direccion'
    weight: 'Peso (kg)'
    height: 'Altura (cm)'
    allergies: 'Alergias'
    patient_antecedents: 'Antecedentes del paciente'

And then, include &commons in

es:
  activerecord:
    models:
      attributes:
         <<: *commons

Hope it helps

All 6 comments

@michaelkl I ran into this problem. So far, what I've done to avoid duplicated translations is this:


common: &commons
  patient:
    address: 'Direccion'
    weight: 'Peso (kg)'
    height: 'Altura (cm)'
    allergies: 'Alergias'
    patient_antecedents: 'Antecedentes del paciente'

And then, include &commons in

es:
  activerecord:
    models:
      attributes:
         <<: *commons

Hope it helps

@FerPerales Good workaround until the issue will have been fixed! Thank you!

Any update on this? Thanks :)

I'm closing this as the original issue is quite old and the translations have changed quite a bit since this was opened, please open another if this is still an issue.

This issue still exists!

Yup; I can reproduce.

I agree this is odd. I wonder what the original intent was, using helpers.label.RESOURCE_NAME.ATTR_NAME instead of activerecord.attributes.RESOURCE_NAME.ATTR_NAME.

Hm, thinking a bit more, I can see an edge case. In forms, fields will tend to match ActiveRecord attributes. On the other hand, in lists/shows there's a higher chance of showing other things, such as constructed attributes (eg: Customer#lifetime_value). I'm not sure if these make sense under activerecord.attributes.* (honestly don't know; perhaps it makes sense).

A potential idea would be to use a helper that tries for helper.label.*, then fall backs for activerecord.attributes.* if missing. I may be overthinking this though. I don't have enough experience with i18n to tell what the conventions are here.

Does anyone have experience with these? /cc @nickcharlton

Was this page helpful?
0 / 5 - 0 ratings