From 825be308444dc4adb521101dcb511b4ef1414b66 Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Sat, 19 Sep 2015 23:33:02 +0200 Subject: [PATCH] FIX: I18n.exists? should use locale fallbacks --- lib/freedom_patches/i18n_fallbacks.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 lib/freedom_patches/i18n_fallbacks.rb diff --git a/lib/freedom_patches/i18n_fallbacks.rb b/lib/freedom_patches/i18n_fallbacks.rb new file mode 100644 index 00000000000..b8aa691835b --- /dev/null +++ b/lib/freedom_patches/i18n_fallbacks.rb @@ -0,0 +1,17 @@ +module I18n + module Backend + module Fallbacks + def exists?(locale, key) + I18n.fallbacks[locale].each do |fallback| + begin + return true if super(fallback, key) + rescue I18n::InvalidLocale + # we do nothing when the locale is invalid, as this is a fallback anyways. + end + end + + false + end + end + end +end