我在當前的rails項目上遇到了一個非常奇怪的問題。每當我嘗試使用密鑰notifications
時,都會收到翻譯缺失消息。例如:爲什麼「通知」這個詞造成i18n打破軌道?
#en-US.yml
en-US:
notifications:
index:
title: 'notification page'
#/notifications/index.html.erb
<%= content_for :title, t('.title') -%>
這將失敗,並告訴我的翻譯是缺少
#en-US.yml
en-US:
notifications:
index:
title: 'notification page'
#/notifications/index.html.erb
<%= content_for :title, t('notifications.index.title') -%>
這也將失敗。
#en-US.yml
en-US:
notification:
index:
title: 'notification page'
#/notifications/index.html.erb
<%= content_for :title, t('notification.index.title') -%>
這奇怪的是,將工作,去除s
將允許它找到翻譯。
#en-US.yml
en-US:
notifications1:
index:
title: 'notification page'
#/notifications/index.html.erb
<%= content_for :title, t('notifications1.index.title') -%>
這也將工作,加入了1
的通知工程的結束。
看來,鐵軌不喜歡單詞通知。這是一個問題,因爲我不想爲此重命名整個模型,而且我想使用i18n.t視圖快捷方式來保持一致性。是notifications
保留字嗎?它有什麼理由不能找到它?