将语言环境添加到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个空格缩进,这是标准的。