Skip to content

Instantly share code, notes, and snippets.

@r7kamura
Last active November 5, 2020 07:45
Show Gist options
  • Save r7kamura/f4c57bb0473747f6df0924951ea8735f to your computer and use it in GitHub Desktop.
Save r7kamura/f4c57bb0473747f6df0924951ea8735f to your computer and use it in GitHub Desktop.
An example of how to reuse other values by symbol translation key value on i18n gem.
require 'i18n'
require 'yaml'
I18n.backend.store_translations(
:en,
YAML.load(<<-YAML)
activerecord:
attributes:
user:
status:
active: :common.active
inactive: :common.inactive
common:
active: Active
inactive: Inactive
YAML
)
p I18n.t('activerecord.attributes.user.status.active') #=> "Active"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment