Prefer natural language over abstracted strings for language keys. This helps to make the views easier to read and understand.
Take advantage of the fact that spaces are legal in YAML keys:
# Bad
t('.all_label')
# Good
t('.All Workspaces')
# Bad
en:
labels:
all_label: All Data Rooms
# Good
en:
labels:
All Workspaces: All Data Rooms
On the other hand don't be too wordy. It's not always necessary or desirable to use the entire string as the key.
# Bad
en:
labels:
You are using too many resources to switch to this plan.: "You are using too many resources to switch to this plan."
# Good
en:
labels:
Too many resources: "You are using too many resources to switch to this plan."
Keys with a '_html' suffix and keys named 'html' are marked as HTML safe. When you use them in views the HTML will not be escaped. Ref: Rails Internationalization (I18n) API — Ruby on Rails Guides
en:
welcome: <b>welcome!</b>
hello_html: <b>hello!</b>
title:
html: <b>title!</b>
Some generic strings can be reused everywhere. These should be placed under the root and referenced without lazy lookup.
# Bad
# app/views/workspaces/index.html.erb
t('.Workspaces')
# Good
t('Workspaces)
# Bad
en:
Workspaces:
index:
title: Data Rooms
# Good
en:
Workspaces: Data Rooms
Rails implements a convenient way to look up the locale inside views.
en:
workspaces:
index:
title: "Data Rooms"
you can look up the books.index.title
value inside app/views/books/index.html.erb
template like this (note the dot):
<%= t '.title' %>
Many places where it can be tempting to use lazy lookup keys, it is better to use ActiveRecord attributes instead.
# Bad
en:
workspaces:
form:
name: Data Room Name
# Good
en:
activerecord:
attributes:
workspace:
name: Data Room Name
# Bad
# Good
# Bad
# Good