Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I18N: Attributes labels translation issue #625

Open
michaelkl opened this issue Jul 4, 2016 · 11 comments
Open

I18N: Attributes labels translation issue #625

michaelkl opened this issue Jul 4, 2016 · 11 comments
Labels
bug breakages in functionality that is implemented i18n translations and language support

Comments

@michaelkl
Copy link

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.

@FerPerales
Copy link
Member

FerPerales commented Aug 5, 2016

@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

@michaelkl
Copy link
Author

michaelkl commented Aug 6, 2016

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

@fikrikarim
Copy link

Any update on this? Thanks :)

@nickcharlton nickcharlton added bug breakages in functionality that is implemented and removed in progress labels Jan 2, 2020
@nickcharlton
Copy link
Member

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.

@kaelumania
Copy link

This issue still exists!

@pablobm
Copy link
Collaborator

pablobm commented Jan 23, 2020

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

@pablobm pablobm reopened this Jan 23, 2020
@jubilee2
Copy link
Contributor

@pablobm i think it's fixed on index page right?

@pablobm
Copy link
Collaborator

pablobm commented Oct 6, 2022

Indeed, I think it was fixed by https://github.com/thoughtbot/administrate/pull/1064/files 🙂

Thank you for the heads up, @jubilee2. If anyone still sees this problem, please let us know and we'll reopen.

@pablobm pablobm closed this as completed Oct 6, 2022
@lubieniebieski
Copy link

hi there!
@pablobm I think that the PR #1064 you mentioned solved the issue partially - I can see a proper behaviour for show and index actions, however in form the i18n doesn't work correctly for Field::BelongsTo type. In case of Field::HasMany - everything works as expected.

Examples that fails to apply the correct translation inf form for Field::BelongsTo type:

en:
  attributes: 
    user: "Some translation for user belongs_to#1"
en:
 activerecord:
    attributes:
      post:
        user: "Some translation for user belongs_to#2"

@nickcharlton
Copy link
Member

Hey @lubieniebieski, do you think you'd be able to contribute a PR for fixing the forms part of it?

@nickcharlton nickcharlton reopened this May 16, 2024
@lubieniebieski
Copy link

hi @nickcharlton, I gave it a try in #2590 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug breakages in functionality that is implemented i18n translations and language support
Projects
None yet
Development

No branches or pull requests

9 participants