Ruby on rails Rails i18n传递URL参数

Ruby on rails Rails i18n传递URL参数,ruby-on-rails,ruby,internationalization,Ruby On Rails,Ruby,Internationalization,我在Rails中成功地使用了i18n,但当我在url中传递一个参数时,i18n停止工作,似乎又回到了英语。我的表单标签被切换回英语而不是荷兰语。我怎样才能防止这种情况发生 相关线路: config.i18n.default_locale = :nl config.i18n.locale = :nl 示例URL: #/users?param1=abc localized do resources :users end 如果您在URL中提供区域设置(我不能用您提供的信息来弥补),那么您可以

我在Rails中成功地使用了i18n,但当我在url中传递一个参数时,i18n停止工作,似乎又回到了英语。我的表单标签被切换回英语而不是荷兰语。我怎样才能防止这种情况发生

相关线路:

config.i18n.default_locale = :nl
config.i18n.locale = :nl
示例URL:

#/users?param1=abc

localized do
  resources :users
end

如果您在URL中提供区域设置(我不能用您提供的信息来弥补),那么您可以通过在应用程序控制器中使用以下代码段覆盖默认URL选项来确保它始终传递给URL帮助程序:

def default_url_options(options={})
  { :locale => I18n.locale }
end
通过

在导轨中使用:

# config/routes.rb
scope "/:locale" do
  resources :books
end
设置区域设置:

before_filter :set_current_locale

private
def set_current_locale
  I18n.locale = params[:locale]
end

你能提供一个示例URL吗?