2

I have an existing codebase and I want to support internationalization for all the validations on the models. It should be as easy as adding the appropriate lines in each locale file like es.yml and de.yml in the format of

  activerecord:
    errors:
      models:
        user:
          attributes:
            some_property:
              inclusion: 'must be one of [foo, bar]'

, except I have a lot of models and it'd take a very long time to comb through them by hand. Is there a tool out there that can go through my models and generate the appropriate lines for the validations in each model for me?

  • Have you tried https://github.com/glebm/i18n-tasks ? Does it solve your issue? – AntonTkachov Nov 21 '17 at 18:22
  • @AntonTkachov thanks but not quite. It's basing its translations on my `en.yml` but my `en.yml` only has the handful of validation messages I put there by hand. It doesn't seem like this gem can go into each of my models to do a static analysis of the errors that can be raised. – user8896804 Nov 21 '17 at 18:41

1 Answers1

0

No, if you want to customize error messages for inclusion, you'll have to write them individually. Are you aware of the translations at https://github.com/svenfuchs/rails-i18n/tree/master/rails/locale? These provide standardized error messages in a variety of languages.

Aaron Breckenridge
  • 1,723
  • 18
  • 25