In Rails 4 (which supports multilingual inflections), I can set:
config.i18n.default_locale = :es
in my config/application.rb, which allows me to do stuff like this in the console:
'general'.pluralize(:es) => "generales"
But when I run:
rails g model General conciencia:string atencion:string
Rails generates files with 'general' pluralized as 'generals' which in spanish should be 'generales'
Shouldn't Rails be using the multilingual inflector for its generators if the locale is set? Is there a way to force it to use them?
Thanks!
A bit late, but for the record: There's an argument in a Rails issue about why is it this way (so it's no a bug, but you can discuss it about):
Source: https://github.com/rails/rails/issues/10125#issuecomment-17274499
Up to Rails 4, the inflector had no support for multiple locales. There was only one set of rules. The application has a default locale, and in a i18n application each request may have a different locale, but that didn't affect the inflector.
The inflector is not only used by the application, it is also used by the framework to convert paths to class names, class names to tables, create method names dynamically for the associations API, etc.
Obviously, those computations cannot vary. If your schema has a "regions" table, Active Record has to map the Region class always to the "regions" table, no matter the evolution of the application (unless the schema changes, but the schema has to be visualized as mostly static regarding to this, much more static that a configuration option).
I have worked on applications that started development using :en, get i18ned, and then switch to a default locale of :es. The locale is something that affects the interface in that mindset. Everything internal should work as it did before.
You should be able to change the default locale and everything else in a way that does not affect static things like association names, tables, routes, etc.
In could be the case that you have i18n routes (which change with the locale of the request), but in general the statement above should be true.
In order to be as backwards compatible as possible, we have left the framework untouched, and have made the inflections to have a default of :en so that existing applications get the same mappings after an upgrade.