The localization of I18N in rails

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

Writing in the rails, because the default language is English, so a lot of the tip is in English, but this is for a Chinese site is not friendly.

So usually uses I18N to achieve localization


Writing in the application.rb file

    config.i18n.default_locale = 'zh_CN'

Then create the zh_CN.yml files in the config/locales file

content is as follows;:

zh_CN:
  activerecord:
    attributes:
      user:
        name: "User name"
    errors:
      models:
        user:
          attributes:
            name:
              blank: "Please add a user name"
              taken: "Occupied"


This is a simple description, I18N can be achieved for the default language in Chinese.

At the same time, can also be used for Internationalization


Attached: the three occurrences of'zh_CN'name must be the same. Otherwise it will appear in translation missing problem

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Joan at December 29, 2013 - 1:17 PM