Created
March 22, 2017 12:58
-
-
Save ebeigarts/c9872fd6db8a4c1e305dd3fa3c1a26f1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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" | |
I18n.backend = I18n::Backend::KeyValue.new({}) | |
I18n.backend.store_translations(:en, { test: "Hello %{value}" }, escape: false) | |
module I18nSafeTranslations | |
def translate(*args) | |
super | |
rescue I18n::MissingInterpolationArgument => e | |
# Raven.capture_exception(e) # send to Sentry | |
"" | |
end | |
end | |
I18n.singleton_class.prepend I18nSafeTranslations | |
puts I18n.translate("test", value: "John") | |
puts I18n.translate("test", val: "John") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment