我有一个单一的控制器,我想添加区域设置。它看起来像
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
答案 0 :(得分:0)
默认情况下,Rails会在en.yml
目录中查找config/locales
。
如果您使用about.en.yml
作为文件名,那么除非您已经配置了其他内容,否则Rails不会找到它。
答案 1 :(得分:0)
尝试在语言环境文件中指定控制器的名称,如下所示:
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个空格缩进,这是标准的。