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
This commit is contained in:
Jean-Philippe Lang 2011-01-10 18:25:12 +00:00
parent bebde1596c
commit 88727bf070
2 changed files with 16 additions and 0 deletions

View File

@ -1,3 +1,5 @@
I18n.default_locale = 'en' I18n.default_locale = 'en'
# Adds fallback to default locale for untranslated strings
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
require 'redmine' require 'redmine'

View File

@ -109,4 +109,18 @@ class Redmine::I18nTest < ActiveSupport::TestCase
to_test.each {|lang, expected| assert_equal expected, find_language(lang)} to_test.each {|lang, expected| assert_equal expected, find_language(lang)}
end 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 end