2012-03-15 60 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)一切都在希臘語中。