Skip to content

Commit e643699

Browse files
committed
Constrain French punctuation l10n to before space: #5
1 parent 03ead38 commit e643699

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

lib/isodoc/i18n.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,14 @@ def l10n_zh_remove_space(text)
144144
end
145145

146146
def l10n_fr1(text, locale)
147-
text = text.gsub(/(?<=\p{Alnum})([»›;?!])/, "\u202f\\1")
147+
text = text.gsub(/(?<=\p{Alnum})([»›;?!])(?=\s)/, "\u202f\\1")
148+
text = text.gsub(/(?<=\p{Alnum})([»›;?!])$/, "\u202f\\1")
148149
text = text.gsub(/^([»›;?!])/, "\u202f\\1")
149150
text = text.gsub(/([«‹])/, "\\1\u202f")
150151
colonsp = locale == "CH" ? "\u202f" : "\u00a0"
151-
text = text.gsub(/(?<=\p{Alnum})(:)/, "#{colonsp}\\1")
152-
text.gsub(/^(:)/, "#{colonsp}\\1")
152+
text = text.gsub(/(?<=\p{Alnum})(:)(?=\s)/, "#{colonsp}\\1")
153+
text = text.gsub(/(?<=\p{Alnum})(:)$/, "#{colonsp}\\1")
154+
text.gsub(/^(:\s)/, "#{colonsp}\\1")
153155
end
154156

155157
def boolean_conj(list, conn)

lib/isodoc/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module IsoDoc
22
class I18n
3-
VERSION = "1.1.0".freeze
3+
VERSION = "1.1.1".freeze
44
end
55
end

spec/isodoc/base_spec.rb

+2
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@
103103
expect(e.encode(c.l10n("Code; «code» and: code!"), :hexadecimal))
104104
.to be_equivalent_to "Code&#x202f;; &#xab;&#x202f;code&#x202f;&#xbb; "\
105105
"and&#x202f;: code&#x202f;!"
106+
expect(e.encode(c.l10n("http://xyz a;b"), :hexadecimal))
107+
.to be_equivalent_to "http://xyz a;b"
106108
end
107109

108110
it "does boolean conjunctions" do

0 commit comments

Comments
 (0)