From 88727bf070ed11b73c75a2510143c15c685254a0 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 10 Jan 2011 18:25:12 +0000 Subject: [PATCH] Adds fallback to 'en' locale for untranslated strings (#5518). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4679 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- config/initializers/30-redmine.rb | 2 ++ test/unit/lib/redmine/i18n_test.rb | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/config/initializers/30-redmine.rb b/config/initializers/30-redmine.rb index cd5b20b70..708dcd655 100644 --- a/config/initializers/30-redmine.rb +++ b/config/initializers/30-redmine.rb @@ -1,3 +1,5 @@ I18n.default_locale = 'en' +# Adds fallback to default locale for untranslated strings +I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks) require 'redmine' diff --git a/test/unit/lib/redmine/i18n_test.rb b/test/unit/lib/redmine/i18n_test.rb index 80e0b509f..5bb69c9a5 100644 --- a/test/unit/lib/redmine/i18n_test.rb +++ b/test/unit/lib/redmine/i18n_test.rb @@ -109,4 +109,18 @@ class Redmine::I18nTest < ActiveSupport::TestCase to_test.each {|lang, expected| assert_equal expected, find_language(lang)} end + + def test_fallback + ::I18n.backend.store_translations(:en, {:untranslated => "Untranslated string"}) + ::I18n.locale = 'en' + assert_equal "Untranslated string", l(:untranslated) + ::I18n.locale = 'fr' + assert_equal "Untranslated string", l(:untranslated) + + ::I18n.backend.store_translations(:fr, {:untranslated => "Pas de traduction"}) + ::I18n.locale = 'en' + assert_equal "Untranslated string", l(:untranslated) + ::I18n.locale = 'fr' + assert_equal "Pas de traduction", l(:untranslated) + end end