2012-12-03 22 views
1

我正在運行一個帶有英文和西班牙文翻譯文件的網站,英文爲默認文件。human_attribute_name和rails中的翻譯文件

使用翻譯如:

en: 
    tenants: 
    about: "About" 

es: 
    tenants: 
    about: "Acera" 

使用

t "tenants.about" 

作品沒有問題,無論從en.yml和es.yml文件時正確地讀取適當。

但是,當試圖使用human_attribute_name屬性從西班牙語es.yml文件的另一部分拉取模型屬性時,值不會被讀取。

因此,像

Job.human_attribute_name(:title) 

返回 「稱號」,而不是 「性標題」。

與人源化的屬性相同es.yml文件的部分如下:

es: 
    tenants: 
    about: "Acerca" 
    activerecord: 
    attributes: 
     job: 
     title: "Título de la oferta de trabajo" 
     location: "Localización de la oferta de trabajo" 
     job_type: "Tipo de trabajo" 
     description: "Descripción" 

任何瞭解,將不勝感激。

回答

-1

我認爲'es:'丟失,或縮進不正確。 "沒有必要:

es: 
    activerecord: 
    attributes: 
     job: 
     title: Título 
+0

我不認爲這是問題,但我已經添加了完整的es.yml來幫助澄清 – cman77

3

哇 - 超級討厭。

這是在長es.yml翻譯文件從GitHub底部:https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale

# remove these aliases after 'activemodel' and 'activerecord' namespaces are removed from 
Rails repository 
    activemodel: 
    errors: 
     <<: *errors 
    activerecord: 
    errors: 
     <<: *errors 

這是壓倒一切的我的ActiveRecord的:聲明在文件的頂部。

考慮到它是一個200多行的文件,不是最好的位置,但對我沒有閱讀整個事情感到羞恥。希望這可以幫助某人。