在视图中使用 I18n

假设你有此 YAML 语言环境文件:

# config/locales/en.yml
en:
  header:
    title: "My header title"

并且你想要显示标题字符串,你可以这样做

# in ERB files
<%= t('header.title') %>

# in SLIM files
= t('header.title')