Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 981
Nicolas Raoul Avatar asked Jun 23 '11 08:06

Nicolas Raoul


1 Answers

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"
like image 181
user482594 Avatar answered Oct 24 '22 10:10

user482594