Class: Govspeak::TranslationHelper
- Inherits:
-
Object
- Object
- Govspeak::TranslationHelper
- Defined in:
- lib/govspeak/translation_helper.rb
Class Method Summary collapse
Class Method Details
.supported_locales ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/govspeak/translation_helper.rb', line 18 def self.supported_locales I18n.available_locales.map do |locale| { code: locale, english_name: I18n.t("english_name", locale:), native_name: I18n.t("native_name", locale:), } end end |
.t_with_fallback(key, **options) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/govspeak/translation_helper.rb', line 3 def self.t_with_fallback(key, **) if I18n.available_locales.none?([:locale]&.to_sym) [:locale] = I18n.default_locale end if [:locale] != I18n.default_locale [:default] = I18n.t( key, **.merge(locale: I18n.default_locale), ) end I18n.t(key, **) end |