将语言环境添加到rails4中的Singular控制器
我有一个单一的控制器,我想添加区域设置。 看起来像
class AboutController < ApplicationController def home end def markdown_syntax end end
我的about.en.yml
看起来像
en: about: home: discover_message: 'Discover, Track and Compare Open Source' join_now: 'Join Now' whats_new: "What's New" popular_projects: 'Most Popular Projects' active_projects: 'Most Active Projects'
我正在获得翻译缺失错误,因为它无法从about.en.yml
识别
错误信息:
translation missing: en.about.home.discover_message
默认情况下,Rails将在config/locales
目录中查找en.yml
。
如果您使用about.en.yml
作为文件名,那么除非您已经配置了其他内容,否则Rails不会找到它。
尝试在语言环境文件中指定控制器的名称,如下所示:
en: controllers: about: home: discover_message: 'Discover, Track and Compare Open Source' join_now: 'Join Now' whats_new: "What's New" popular_projects: 'Most Popular Projects' active_projects: 'Most Active Projects'
我还将1个空格缩进更改为2个空格缩进,这是标准的。
- Rails国际化不在生产模式下工作
- bundler安装获取“i18n需要Ruby版本> = 1.9.3”
- I18narrays中的插值
- Way Rails不会引发I18n :: MissingInterpolationArgumentexception?
- 升级到ruby 2.3.0 NameError:uninitialized constant I18n :: Config :: Backend
- 在切换要转换的Blacklight标签的区域设置后,需要刷新页面
- I18n locale无视后备
- Rails:Model.human_attribute_name:字段应该在找不到翻译时引发错误? (也许是由state_machine引起的?)
- 应用无法访问引擎或gem中的翻译文件