Locales helper improvement

Added a rescue block in `name_for_locale()` to ensure the application doesn't crash in case it receives an invalid locale.
This commit is contained in:
María Checa
2017-07-03 12:55:22 +02:00
parent da2b55942a
commit 3e2cbabc9c
2 changed files with 4 additions and 2 deletions

View File

@@ -3,6 +3,8 @@ module LocalesHelper
def name_for_locale(locale)
default = I18n.t("locale", locale: locale)
I18n.backend.translate(locale, "i18n.language.name", default: default)
rescue
nil
end
end
end