Skip to content

Commit

Permalink
Fix ruby-i18n#81. Prevent splitting string on new line in Fallbacks b…
Browse files Browse the repository at this point in the history
…ackend
  • Loading branch information
knapo committed Feb 24, 2011
1 parent a4be202 commit 1c53c5d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/i18n/backend/fallbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def translate(locale, key, options = {})
end

def extract_string_or_lambda_default!(options)
defaults = Array(options[:default])
defaults = [options[:default]].flatten
if index = find_first_string_or_lambda_default(defaults)
options[:default] = defaults[0, index]
defaults[index]
Expand Down
4 changes: 4 additions & 0 deletions test/backend/fallbacks_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ def setup
assert_raise(I18n::MissingTranslationData) { I18n.t(:faa, :locale => :en, :raise => true) }
assert_raise(I18n::MissingTranslationData) { I18n.t(:faa, :locale => :de, :raise => true) }
end

test "should ensure that default is not splitted on new line char" do
assert_equal "Default \n Bar", I18n.t(:missing_bar, :default => "Default \n Bar")
end
end

class I18nBackendFallbacksLocalizeTest < Test::Unit::TestCase
Expand Down

0 comments on commit 1c53c5d

Please sign in to comment.