OSDN Git Service

Adds fallback to 'en' locale for untranslated strings (#5518).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 10 Jan 2011 18:25:12 +0000 (18:25 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 10 Jan 2011 18:25:12 +0000 (18:25 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4679 e93f8b46-1217-0410-a6f0-8f06a7374b81

config/initializers/30-redmine.rb
test/unit/lib/redmine/i18n_test.rb

index cd5b20b..708dcd6 100644 (file)
@@ -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'
index 80e0b50..5bb69c9 100644 (file)
@@ -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