Search code examples
ruby-on-railsruby-on-rails-5rails-i18n

I18n.t falls back to key instead to default locale


In my frontend non-translated strings are replaced with word form of their key instead of the translation of base language.

That means that changing locale to :en or :tr both shows Summaries Header for t('activerecord.misc.badge.summaries_header') instead of Auswertungen from German locale. So it's obviously build from the last part of the key. Summaries Header does not appear as Label in any locale.

Other in :en/:tr translated strings are shown correctly.

# config/application.rb

config.i18n.default_locale = :de
config.i18n.available_locales = [
  :de, # Deutsch
  :pt, # Portugiesisch
  :en, # Englisch
  :tr, # Türkisch
]
config.i18n.fallbacks = true
# Versions
ruby 2.7.2
rails 5.2.4.4
i18n 1.8.6
rails-i18n 5.1.3

I can't find the reason for that behavior and I can't figure out which update at which time broke this.

How can I fix this?


Solution

  • TL;DR: Update to i18n v1.8.7 or higher with bundle update i18n

    i18n v1.8.6 was broken regarding getting fallbacks from config.i18n.* into Thread variables.

    See i18n issue #546 and changelog for v1.8.7