From fc5e909929de23b5eba766c7adfc52ea97e713e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20B=C4=82LTEANU?= Date: Mon, 2 Jun 2025 22:55:08 +0300 Subject: [PATCH 2/2] Drop @Redmine::I18n::Backend.new@ custom backend. --- config/application.rb | 1 + config/initializers/30-redmine.rb | 4 +--- lib/redmine/i18n.rb | 17 ----------------- 3 files changed, 2 insertions(+), 20 deletions(-) diff --git a/config/application.rb b/config/application.rb index 1beeb2db2..96c6f9fb4 100644 --- a/config/application.rb +++ b/config/application.rb @@ -59,6 +59,7 @@ module RedmineApp config.i18n.enforce_available_locales = true config.i18n.fallbacks = true config.i18n.default_locale = 'en' + config.i18n.available_locales = Dir[Rails.root / 'config' / 'locales' / '*.yml'].map { |f| File.basename(f, '.yml').to_sym } # Configure the default encoding used in templates for Ruby 1.9. config.encoding = "utf-8" diff --git a/config/initializers/30-redmine.rb b/config/initializers/30-redmine.rb index cf13cab20..2ededf564 100644 --- a/config/initializers/30-redmine.rb +++ b/config/initializers/30-redmine.rb @@ -4,9 +4,7 @@ require 'redmine/configuration' require 'redmine/plugin_loader' Rails.application.config.to_prepare do - I18n.backend = Redmine::I18n::Backend.new - # Forces I18n to load available locales from the backend - I18n.config.available_locales = nil + I18n::Backend::Simple.include(I18n::Backend::Pluralization) # Use Nokogiri as XML backend instead of Rexml ActiveSupport::XmlMini.backend = 'Nokogiri' diff --git a/lib/redmine/i18n.rb b/lib/redmine/i18n.rb index c2beafefb..0b31cb235 100644 --- a/lib/redmine/i18n.rb +++ b/lib/redmine/i18n.rb @@ -173,22 +173,5 @@ module Redmine def current_language ::I18n.locale end - - # Custom backend based on I18n::Backend::Simple with the following changes: - # * available_locales are determined by looking at translation file names - class Backend < ::I18n::Backend::Simple - # Get available locales from the translations filenames - def available_locales - @available_locales ||= begin - redmine_locales = Dir[Rails.root / 'config' / 'locales' / '*.yml'].map { |f| File.basename(f, '.yml').to_sym } - super & redmine_locales - end - end - - # Adds custom pluralization rules - include ::I18n::Backend::Pluralization - # Adds fallback to default locale for untranslated strings - include ::I18n::Backend::Fallbacks - end end end -- 2.39.5 (Apple Git-154)