Last active
November 5, 2020 07:45
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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