让 Rails 2.3.x 忽略 i18n gem
我有一个 Rails 2.3.5 项目,它使用 Rails 的本地化功能。我也碰巧安装了 Rails 3 beta(这取决于 i18n gem)。 Rails 2.3.5 很乐意自行处理本地化(无需安装 i18n),但是如果 i18n gem 可用,它就会使用它。
最近我升级了 gems,现在安装了 i18n 0.3.7 和 0.4.0 版本。当然,Rails 想要加载并使用最新版本,这导致我的项目出现错误。我尝试将 gem 版本设置为 0.3.7,这可以解决网络应用程序中的错误。但是,我们使用 resque 和 resque_mailer 来延迟消息的发送。当工作人员从队列中获取邮件程序作业时,它会忽略environment.rb 中的 config.gem 要求并使用 0.4.0 版本。
理想情况下,我想告诉 Rails 根本不要使用 i18n gem。我该怎么做?
更新:从 beta 4 开始,Rails 3 现在需要 i18n 版本 0.4.1。我不明白有多少人没有遇到这个问题,因为现在看来,如果您同时安装了 Rails 2 和 Rails 3,您就会遇到这个问题。
I have a Rails 2.3.5 project that uses the localization features of Rails. I also happen to have Rails 3 beta installed (which depends on the i18n gem). Rails 2.3.5 will happily handle localization on it's own (without i18n installed), however if the i18n gem is available, it makes use of it.
Recently I upgraded my gems and now have version 0.3.7 and 0.4.0 of i18n installed. Rails, of course, wants to load and use the latest version which is causing errors in my project. I tried setting the gem version to 0.3.7 which gets around the errors in the web app. However, we're using resque and resque_mailer to delay the sending of messages. When the worker picks up the mailer job from the queue, it ignores my config.gem requirement in environment.rb and uses version 0.4.0 anyway.
Ideally, I'd like to tell Rails to just not use the i18n gem at all. How do I do that?
Update: As of beta 4, Rails 3 now requires i18n version 0.4.1. I don't see how more people aren't running into this problem as it would seem now if you have both Rails 2 and Rails 3 installed, you're going to run into this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我按照此处定义的说明进行操作:
http://gembundler.com/rails23.html
并且它有效。
I followed instructions as defined here:
http://gembundler.com/rails23.html
and it worked.
您可以使用 Bundler 或 RVM 的 Gemsets 使 i18n gem 在您的应用程序中不可用。或者您可以升级您的 Rails 应用程序。
You could use Bundler or RVM's Gemsets to make the i18n gem unavailable from within your app. Or you could upgrade your Rails app.
rake VERSION=2.3.5rails:freeze:gems
gem 'i18n', '>= 0.1.3', '< 0.4.0'
rake VERSION=2.3.5 rails:freeze:gems
gem 'i18n', '>= 0.1.3', '< 0.4.0'
或者只需编辑:
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/vendor.rb
并将
gem 'i18n', '>; = 0.1.3'
进入
gem 'i18n', '0.1.3'
Or just edit:
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/vendor.rb
And turn
gem 'i18n', '>= 0.1.3'
Into
gem 'i18n', '0.1.3'