How can I specify Rails I18n locale an attribute translation common for all models?

Leticia Esperon

I have in my es.ymllocale the following code:

es:
  activerecord:
    models:
      courier:
        one: Repartidor
        other: Repartidores
      admin_user:
        one: Administrador
        other: Administradores
    attributes:
      courier:
        ci: Cédula
        first_name: Nombre
        last_name: Apellido
        password: Contraseña
        password_confirmation: Confirmación de contraseña
        sign_in_count: Veces que inició sesión
        created_at: Fecha de creación
        updated_at: Última actualización
      admin_user:
        email: Email
        last_sign_in_ip: Útima IP utilizada
        last_sign_in_at: Útimo inicio de sesión
        current_sign_in_ip: Actual IP
        current_sign_in_at: Actual inicio de sesión
        sign_in_count: Veces que inició sesión
        created_at: Fecha de creación
        updated_at: Última actualización
        password: Contraseña
        password_confirmation: Confirmación de contraseña

However, you might have seen that a lot of attributes are common for more than one model like the timestamps and password. How can I tell the locale to translate that for every model so I don't have to repeat the translations of the attributes for each model?

Thank you!

xploshioOn

You just move attributes one level to the left, something like this

es:
  attributes:
    password: Contraseña
    name: Nombre
  activerecord:
    attributes:
      user:
        license_number: Numero de licencia

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Rails I18n: How to set fallback locale?

How to configure locale aliases using i18n & rails?

How can i flatten rails i18n files

Rails i18n gem excludes attribute name from error messages for non-English locale

Can I use embedded Ruby in I18n locale files in Rails?

Rails i18n - how to get all translations for a key

Rails - I18n: How do I find out translation path?

How to use Vue I18n translation in component attribute/property

How can I reuse i18n translation keys in Angular?

How can I add expressive translation to KnockoutJS via i18n?

How can I put CSS style in my I18n locale?

How to add an i18n locale prefix in Vue router for all the locales except for the default one?

How can get a non-trivial i18n translation to work using Sails.js?

Rails select_tag with i18n translation

Rails i18n translation for belongs_to validation

Translation For Dynamic Data Using Rails I18n

Rails language name using I18n locale

Rails I18n do not include default locale in URL

Rails i18n : "fr" is not a valid locale

rails i18n locale specific config settings?

How to pluralize human_attribute_name with Rails 5 and I18n?

How can I load Globalize translation fixtures to test models?

How to use Vue i18n translation in .js file?

How can I deal with i18n and cookies in a multi-language application in Rails?

How Ti.Locale.getCurrentLanguage() , i18n defferent?

How to fix: i18n always translate to default locale

How to get the locale in the i18n file?

Rails 5 I18n default_locale and fallback locale

Rails 4 multidomain application with locale set for each domain i18n locale