Search code examples
ruby-on-railsinternationalizationsimple-form

SimpleForm, I18n and Rails: Change namespace from de.simple_form.* to de.activerecord.*?


We just replaced FormTastic with SimpleForm, and while FormTastic used our translations in the namespace de.activerecord.*, SimpleForm seems to insist on de.simple_form.*. I googled around and also read the documentation, which interestingly has the following code snippet:

en:
  activerecord:
    models:
        admin/user: User
    attributes:
        admin/user:
            name: Name

But nowhere else I can find more information about whether it is possible to make SimpleForm use en.activerecord.* as its namespace, or not.

So can I force SimpleForm to change its namespace? Any help is highly appreciated.


Solution

  • I realize this is a very old question, but I just came across it when looking to do the same thing in SimpleForm 3.1.

    SimpleForm now has a config option to specify the i18n prefix, it can be found at the bottom of config/initializers/simple_form.rb. You can simply configure it to use whatever scope you wish, eg. activerecord instead of simple_form:

    # Defines which i18n scope will be used in Simple Form.
    config.i18n_scope = 'activerecord'