diff --git a/config/initializers/alaveteli.rb b/config/initializers/alaveteli.rb index 8d88ca1725..13f79e8589 100644 --- a/config/initializers/alaveteli.rb +++ b/config/initializers/alaveteli.rb @@ -10,7 +10,7 @@ load "util.rb" # Application version -ALAVETELI_VERSION = '0.40.0.1' +ALAVETELI_VERSION = '0.40.1.0' # Add new inflection rules using the following format # (all these examples are active by default): diff --git a/doc/CHANGES.md b/doc/CHANGES.md index 7d70e0362d..53e853ef9f 100644 --- a/doc/CHANGES.md +++ b/doc/CHANGES.md @@ -1,3 +1,10 @@ +# 0.40.1.0 + +## Highlighted Features + +* Fixes issue loading translated fields when using locales with underscores + (e.g. `en_RW` or `nl_BE`) (Graeme Porteous) + # 0.40.0.1 ## Highlighted Features diff --git a/lib/alaveteli_localization/railtie.rb b/lib/alaveteli_localization/railtie.rb index 280a19c829..8825fe981a 100644 --- a/lib/alaveteli_localization/railtie.rb +++ b/lib/alaveteli_localization/railtie.rb @@ -23,6 +23,30 @@ class Railtie < Rails::Railtie AlaveteliConfiguration.include_default_locale_in_urls ) + if Rails.version < '7.0.0' && Rails.env.development? + ## + # Ideally the following would only be called in the `after_initialize` + # hook but this leads to an error when booting Rails 6.1 in development + # mode. (As config.cache_classes = false) + # + # This due Alaveteli not yet using the new Zeitwork autoloading feature + # and Rails attempts to render a deprecation warning which happens to + # includes an I18n translation so requires the default locale to be + # setup. + # + # Once we support Zeitwork (which is needed for Rails 7) then this can + # be removed. + # + # See: https://github.com/mysociety/alaveteli/issues/5382 + # + AlaveteliLocalization.set_locales( + AlaveteliConfiguration.available_locales, + AlaveteliConfiguration.default_locale + ) + end + end + + config.after_initialize do AlaveteliLocalization.set_locales( AlaveteliConfiguration.available_locales, AlaveteliConfiguration.default_locale