I18n translation in Rails console doesn't show proper Chinese (or any other language)

Zack Xu picture Zack Xu · Jun 6, 2012 · Viewed 7.2k times · Source

So we're using I18n to localize our website to traditional Chinese

I have a zh-TW.yml file under directory config/locales

I'm trying to see that the translation works in Rails Console.

So I tried:

1.9.3-p0 :001 > I18n.default_locale
 => :zh
1.9.3-p0 :008 > I18n.t 'users.account_header'
 => "zh, users.account_header" 
1.9.3-p0 :009 > I18n.t "x_days", :count => 10
 => "zh, x_days"

Why does it not return the proper Chinese translation? so we know it works and gets the right translation.

I also tried some garbage string, eg

1.9.3-p0 :011 > I18n.t "dfkjafkjadf", :count => 10
 => "zh, dfkjafkjadf" 

It didn't even complain that the translation is missing!

Have I missed something?

Thanks!

Answer

tigrish picture tigrish · Jun 6, 2012

This might sound silly, but could it simply be that your default locale is zh but your translations are stored under zh-TW?