0

I'm Taiwanese , I saw most people use 'zh-TW' to represents Taiwan language

but zh-TW contains special character ? so it has strange behavior in rails console.

if I changed my locale to English, it works perfect I18n.locale= :en

But failed to I18n.locale= :zh-TW

NameError: uninitialized constant TW
    from (irb):2
    from /Users/hsu-wei-cheng/.rvm/gems/ruby-2.1.0/gems/railties-4.0.2/lib/rails/commands/console.rb:90:in `start'
    from /Users/hsu-wei-cheng/.rvm/gems/ruby-2.1.0/gems/railties-4.0.2/lib/rails/commands/console.rb:9:in `start'
    from /Users/hsu-wei-cheng/.rvm/gems/ruby-2.1.0/gems/railties-4.0.2/lib/rails/commands.rb:62:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

Is it a good idea to change the zh-TW to tw for the Taiwan language ?

  1. zh-TW.yml -> tw.yml

In the locale yml file

tw:
  hello: "Hello world"
newBike
  • 14,385
  • 29
  • 109
  • 192

1 Answers1

0

No, you cannot. :tw is not an international Language code. As per http://guides.rubyonrails.org/i18n.html#configure-the-i18n-module

The i18n library takes a pragmatic approach to locale keys (after some discussion), including only the locale ("language") part, like :en, :pl, not the region part, like :en-US or :en-GB, which are traditionally used for separating "languages" and "regional setting" or "dialects". Many international applications use only the "language" element of a locale such as :cs, :th or :es (for Czech, Thai and Spanish). However, there are also regional differences within different language groups that may be important. For instance, in the :en-US locale you would have $ as a currency symbol, while in :en-GB, you would have £. Nothing stops you from separating regional and other settings in this way: you just have to provide full "English - United Kingdom" locale in a :en-GB dictionary.

So, you can use :zh for Taiwan. No issues.

Rajesh Omanakuttan
  • 6,788
  • 7
  • 47
  • 85