简体   繁体   English

Rails 2.3.5和I18n本地化问题

[英]Rails 2.3.5 and I18n localization problem

For a project I am locked into rails version 2.3.5; 对于一个项目,我只能使用Rails 2.3.5版本;

I am trying to localize the application and and I want to use a specific locale. 我正在尝试本地化应用程序,并且我想使用特定的语言环境。

Let's say, for simplicity, I want to switch to en-US https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/en-US.yml 假设,为简单起见,我想切换到英语https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/en-US.yml

My problem is that when I set the default locale in environment.rb to be 'en-US', in my views, wherever I have distance_time_in_words, I get %{count} in months or %{count} in hours. 我的问题是,当我在environment.rb中将默认语言环境设置为“ en-US”时,在我的视图中,无论我在哪里拥有distance_time_in_words,我都会在数月内获得%{count}或在小时内获得%{count}。

I tried other locales and the problem persists with %{count} showing up. 我尝试了其他语言环境,但问题仍然存在,出现了%{count}。

Now, if I don't include a default locale by commenting out config.i18n.default_locale = :en-US in enviroment.rb, distance_time_in_words returns correctly the information; 现在,如果我没有通过注释掉enviroment.rb中的config.i18n.default_locale =:en-US来包括默认语言环境,distance_time_in_words会正确返回信息; that is %{count} is replaced by a number. 即%{count}替换为数字。

I don't want to use the i18n plugin since the I18n module is included with activesupport 2.3.5 (\\activesupport-2.3.5\\lib\\active_support\\vendor\\i18n-0.1.3) 我不想使用i18n插件,因为I18n模块包含在activesupport 2.3.5(\\ activesupport-2.3.5 \\ lib \\ active_support \\ vendor \\ i18n-0.1.3)中

Thank you in advance!! 先感谢您!!

Thank you in advance. 先感谢您。

Rails 2.3.5使用了您想使用{{count}}而不是%{count}进行插值的i18n gem的较旧版本。

I believe underscore is the way to combine country and region codes this way. 我相信下划线是通过这种方式将国家和地区代码组合在一起的方法。

try en_US instead of en-US 尝试使用en_US而不是en-US

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM