我尝试使用I18n解决rails 4应用程序中缺少的翻译问题。
我得到的错误如下:
translation missing: en.ice_cube.each_day
所以我检查翻译应该来自哪里,它应该在/usr/local/rvm/gems/ruby-2.1.1@nacore/gems/ice_cube-0.14.0/config/locales/en.yml 。然后我检查I18n.load_path和/usr/local/rvm/gems/ruby-2.1.1@nacore/gems/ice_cube-0.14.0/config/locales/en.yml肯定在那里。然后我检查翻译,我得到了这个:
2.1.1 :054 > I18n.t('ice_cube')
=> {:string=>{:format=>{:day=>"%{rest} %{current}", :day_of_week=>"%{rest} %{current}", :day_of_month=>"%{rest} %{current}", :day_of_year=>"%{rest} %{current}", :hour_of_day=>"%{rest} %{current}", :minute_of_hour=>"%{rest} %{current}", :until=>"%{rest} %{current}", :count=>"%{rest} %{current}", :default=>"%{rest} %{current}"}}}
如果我只是引入/usr/local/rvm/gems/ruby-2.1.1@nacore/gems/ice_cube-0.14.0/config/locales/en的内容,这与我得到的非常不同。将yml变成这样的哈希:
2.1.1 :061 > y['en']['ice_cube']
=> {"pieces_connector"=>" / ", "not"=>"not %{target}", "not_on"=>"not on %{target}", "date"=>{"formats"=>{"default"=>"%B %-d, %Y"}, "month_names"=>[nil, "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], "day_names"=>["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]}, "times"=>{"other"=>"%{count} times", "one"=>"%{count} time"}, "until"=>"until %{date}", "days_of_week"=>"%{segments} %{day}", "days_of_month"=>{"other"=>"%{segments} days of the month", "one"=>"%{segments} day of the month"}, "days_of_year"=>{"other"=>"%{segments} days of the year", "one"=>"%{segments} day of the year"}, "at_hours_of_the_day"=>{"other"=>"on the %{segments} hours of the day", "one"=>"on the %{segments} hour of the day"}, "on_minutes_of_hour"=>{"other"=>"on the %{segments} minutes of the hour", "one"=>"on the %{segments} minute of the hour"}, "at_seconds_of_minute"=>{"other"=>"at the %{segments} seconds", "one"=>"at the %{segments} second"}, "on_seconds_of_minute"=>{"other"=>"on the %{segments} seconds of the minute", "one"=>"on the %{segments} second of the minute"}, "each_second"=>{"one"=>"Secondly", "other"=>"Every %{count} seconds"}, "each_minute"=>{"one"=>"Minutely", "other"=>"Every %{count} minutes"}, "each_hour"=>{"one"=>"Hourly", "other"=>"Every %{count} hours"}, "each_day"=>{"one"=>"Daily", "other"=>"Every %{count} days"}, "each_week"=>{"one"=>"Weekly", "other"=>"Every %{count} weeks"}, "each_month"=>{"one"=>"Monthly", "other"=>"Every %{count} months"}, "each_year"=>{"one"=>"Yearly", "other"=>"Every %{count} years"}, "on"=>"on the %{sentence}", "in"=>"in %{target}", "integer"=>{"negative"=>"%{ordinal} to last", "literal_ordinals"=>{-1=>"last", -2=>"2nd to last"}, "ordinal"=>"%{number}%{ordinal}", "ordinals"=>{"default"=>"th", 1=>"st", 2=>"nd", 3=>"rd", 11=>"th", 12=>"th", 13=>"th"}}, "on_weekends"=>"on Weekends", "on_weekdays"=>"on Weekdays", "days_on"=>["Sundays", "Mondays", "Tuesdays", "Wednesdays", "Thursdays", "Fridays", "Saturdays"], "on_days"=>"on %{days}", "array"=>{"last_word_connector"=>", and ", "two_words_connector"=>" and ", "words_connector"=>", "}, "string"=>{"format"=>{"day"=>"%{rest} %{current}", "day_of_week"=>"%{rest} %{current}", "day_of_month"=>"%{rest} %{current}", "day_of_year"=>"%{rest} %{current}", "hour_of_day"=>"%{rest} %{current}", "minute_of_hour"=>"%{rest} %{current}", "until"=>"%{rest} %{current}", "count"=>"%{rest} %{current}", "default"=>"%{rest} %{current}"}}}
应用程序在ice_cube中使用的翻译似乎只是/usr/local/rvm/gems/ruby-2.1.1@nacore/gems/ice_cube-0.14.0/中的一小部分内容。 config / locales / en.yml文件... 这个应用程序部署在十几个服务器上,它发生在所有这些服务器上。这可能会发生什么?