fix that diff outputs become ??? in some non ASCII words (#12641)

Contributed by Filou Centrinov.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11549 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2013-03-07 10:36:06 +00:00
parent 72539451aa
commit d3de07a17c
4 changed files with 73 additions and 0 deletions

View File

@ -199,10 +199,16 @@ module Redmine
while starting < max && line_left[starting] == line_right[starting] while starting < max && line_left[starting] == line_right[starting]
starting += 1 starting += 1
end end
while line_left[starting].ord.between?(128, 191) && starting > 0
starting -= 1
end
ending = -1 ending = -1
while ending >= -(max - starting) && line_left[ending] == line_right[ending] while ending >= -(max - starting) && line_left[ending] == line_right[ending]
ending -= 1 ending -= 1
end end
while line_left[ending].ord.between?(128, 191) && ending > -1
ending -= 1
end
unless starting == 0 && ending == -1 unless starting == 0 && ending == -1
[starting, ending] [starting, ending]
end end

25
test/fixtures/diffs/issue-12641-ja.diff vendored Normal file
View File

@ -0,0 +1,25 @@
# HG changeset patch
# User tmaruyama
# Date 1362559296 0
# Node ID ee54942e0289c30bea1b1973750b698b1ee7c466
# Parent 738777832f379f6f099c25251593fc57bc17f586
fix some Japanese "issue" translations (#13350)
Contributed by Go MAEDA.
diff --git a/config/locales/ja.yml b/config/locales/ja.yml
--- a/config/locales/ja.yml
+++ b/config/locales/ja.yml
@@ -904,9 +904,9 @@ ja:
text_journal_set_to: "%{label} を %{value} にセット"
text_journal_deleted: "%{label} を削除 (%{old})"
text_journal_added: "%{label} %{value} を追加"
- text_tip_issue_begin_day: この日に開始するタスク
- text_tip_issue_end_day: この日に終了するタスク
- text_tip_issue_begin_end_day: この日のうちに開始して終了するタスク
+ text_tip_issue_begin_day: この日に開始するチケット
+ text_tip_issue_end_day: この日に終了するチケット
+ text_tip_issue_begin_end_day: この日に開始・終了するチケット
text_caracters_maximum: "最大%{count}文字です。"
text_caracters_minimum: "最低%{count}文字の長さが必要です"
text_length_between: "長さは%{min}から%{max}文字までです。"

19
test/fixtures/diffs/issue-12641-ru.diff vendored Normal file
View File

@ -0,0 +1,19 @@
# HG changeset patch
# User tmaruyama
# Date 1355872765 0
# Node ID 8a13ebed1779c2e85fa644ecdd0de81996c969c4
# Parent 5c3c5f917ae92f278fe42c6978366996595b0796
Russian "about_x_hours" translation changed by Mikhail Velkin (#12640)
diff --git a/config/locales/ru.yml b/config/locales/ru.yml
--- a/config/locales/ru.yml
+++ b/config/locales/ru.yml
@@ -115,7 +115,7 @@ ru:
one: "около %{count} часа"
few: "около %{count} часов"
many: "около %{count} часов"
- other: "около %{count} часа"
+ other: "около %{count} часов"
x_hours:
one: "1 час"
other: "%{count} часов"

View File

@ -221,6 +221,29 @@ DIFF
assert_equal "test02.txt", diff[0].file_name assert_equal "test02.txt", diff[0].file_name
end end
def test_utf8_ja
ja = " text_tip_issue_end_day: "
ja += "\xe3\x81\x93\xe3\x81\xae\xe6\x97\xa5\xe3\x81\xab\xe7\xb5\x82\xe4\xba\x86\xe3\x81\x99\xe3\x82\x8b<span>\xe3\x82\xbf\xe3\x82\xb9\xe3\x82\xaf</span>"
ja.force_encoding('UTF-8') if ja.respond_to?(:force_encoding)
with_settings :repositories_encodings => '' do
diff = Redmine::UnifiedDiff.new(read_diff_fixture('issue-12641-ja.diff'), :type => 'inline')
assert_equal 1, diff.size
assert_equal 12, diff.first.size
assert_equal ja, diff.first[4].html_line_left
end
end
def test_utf8_ru
ru = " other: &quot;\xd0\xbe\xd0\xba\xd0\xbe\xd0\xbb\xd0\xbe %{count} \xd1\x87\xd0\xb0\xd1\x81<span>\xd0\xb0</span>&quot;"
ru.force_encoding('UTF-8') if ru.respond_to?(:force_encoding)
with_settings :repositories_encodings => '' do
diff = Redmine::UnifiedDiff.new(read_diff_fixture('issue-12641-ru.diff'), :type => 'inline')
assert_equal 1, diff.size
assert_equal 8, diff.first.size
assert_equal ru, diff.first[3].html_line_left
end
end
private private
def read_diff_fixture(filename) def read_diff_fixture(filename)