Rails3: Devise internationalization does not localize "Password confirmation" and others

Nicolas Raoul picture Nicolas Raoul · Jun 23, 2011 · Viewed 7.2k times · Source

Here is my whole source code for a minimalist Devise+OmniAuth app.

As you can see, the Japanese devise.ja.yml is in config/locales.

PROBLEM: When I visit the site with lang=ja, some strings are not in Japanese but English:

devise i18n password confirmation

"サインアップ" is displayed correctly, but "Password confirmation" and others are still in English. Actually, I grep'd my the whole project and my entire .rvm directory: No file contain "Password confirmation" ! That's baffling.

Where do those strings come from? How comes they are not in devise.ja.yml? Is it OmniAuth?

Answer

user482594 picture user482594 · Jun 27, 2011

Actually, they come from your default language yml file. Devise locale file just have locales for alert messages and some notices. They do not provide attribute translation for form attributes.

You probably want to visit

https://github.com/svenfuchs/rails-i18n/tree/f8606e62def45279f3498549f97699049135bd11/rails/locale

and download the adequate (Japanese in your case) language file and put it in ./config/locales/ folder

Then in your rails application configuration file (./config/application.rb) change locale setting to use the Japanese locale file.

config.i18n.default_locale = :ja

After changing the setting, if you want any attribute to have Japanese name, add the rules like shown below.

activerecord:
    attributes:
        user:
            email: "Email address in Japanese"
            password: "Password in Japanese"
            password_confirmation: "Password confirmation in Japanese"