在檢視中使用 I18n

假設你有此 YAML 語言環境檔案:

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

並且你想要顯示標題字串,你可以這樣做

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

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