Ruby on rails 3 I18n翻译仅对管理员丢失
我尝试翻译我的web应用程序并遵循以下指南: 我将el.yml作为我的语言(希腊语),我的gem文件有gem'rails-i18n',我在应用程序中的代码有Ruby on rails 3 I18n翻译仅对管理员丢失,ruby-on-rails-3,internationalization,Ruby On Rails 3,Internationalization,我尝试翻译我的web应用程序并遵循以下指南: 我将el.yml作为我的语言(希腊语),我的gem文件有gem'rails-i18n',我在应用程序中的代码有 before_filter :set_locale def set_locale I18n.locale = params[:locale] || I18n.default_locale end def default_url_options(options={}) logger.debug "default_ur
before_filter :set_locale
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
def default_url_options(options={})
logger.debug "default_url_options is passed options: #{options.inspect}\n"
{ :locale => I18n.locale }
end
在我的application.html.erb中,我使用
<%= l(Time.now, :format => :short) %></p
-
class AdminController
全部使用ApplicationController为什么不使用AdminController(继承)?我的问题的最终解决方案删除以下代码
before_filter :set_locale
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
def default_url_options(options={})
logger.debug "default_url_options is passed options: #{options.inspect}\n"
{ :locale => I18n.locale }
end
使用此代码,所有链接都有扩展名,如el?我的默认链接不起作用
现在我有了l(Time.Now,:format=>:short)所有的希腊语
class AdminController < ApplicationController
class ApplicationController < ActionController::Base
before_filter :set_locale
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
def default_url_options(options={})
logger.debug "default_url_options is passed options: #{options.inspect}\n"
{ :locale => I18n.locale }
end