It is replaced after a call. For instance.
Yaml.load_file('locale/en.yml')['en']['message']['welcome'].gsub('%{username}', username)
So in a method, it could be:
def t(key, changes) result = yaml_locale['en'] key.split('.').each |k| result = result[k] end changes.each_keys do |k| result.gsub!("%{#{k}}%", changes[k]) end result end
Reformat it again, but the idea is.
The original method is here: https://github.com/svenfuchs/i18n/blob/master/lib/i18n.rb#L143 Manage many thoughts, I do not do this :)
source share