2016-11-21 73 views
1

我在Middleman安裝中使用文件locales/en.ymllocales/ar.yml設置語言環境。Middleman中嵌套的I18n語言環境

所面臨的挑戰是,我已經得到了很多織補文本的翻譯,並希望有東西嵌套像這樣:

--- 
en: 
    main_page: 
    hello_and_welcome: "Hello and Welcome to ..." 
    bye_and_well_bye: "Bye now" 

我以前可以訪問的話作爲I18n.t(:hello)在我的網頁。當我使用嵌套YAML時它將如何工作?

嘗試I18n.t(:main_page, :hello_and_welcome)但返回:

{:hello_and_welcome => 「您好,歡迎光臨......」}

回答

2

您可以通過引用作爲一個字符串:

<%= I18n.t('main_page.hello_and_welcome') %> 

或附帶短標籤:

<%= t('main_page.hello_and_welcome') %> 
+1

先生,你救了我的命。 – bartimar

相關問題