Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 621
Zack Xu Avatar asked Jan 20 '26 23:01

Zack Xu


1 Answers

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

like image 154
tigrish Avatar answered Jan 23 '26 20:01

tigrish



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!