2012-03-15 80 views
0

我试着翻译我的web应用程序,并按照本指南中失踪:Ruby on Rails Guides的I18n翻译仅供管理员

我让我el.yml我的语言(希腊),我的Gemfile有宝石“的轨道,国际化”和我在application_controller代码有

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 

,一切都是好与我的用户寻找在希腊的时间。但用户的前5个ID是admins和admins_controller处理文章。当管理员看的时候采取这个错误:

I18n::MissingTranslationData in Admin#articles 
Showing /home/panagiotis/projects/diplomatiki/app/views/layouts/application.html.erb where line #43 raised: 
translation missing: el?state=4.time.formats.short 

-

class AdminController < ApplicationController 

class ApplicationController < ActionController::Base 

与ApplicationController中所有的工作,为什么有AdminController(继承)不?

回答

0

我的问题最终解决方案删除如下代码

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 

与此代码各个环节都有延长像埃尔?和我的默认链接不起作用 现在我已经与l(Time.now,:format =>:short)一切都在希腊语中。