locale 2.1.1 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/doc/text/news.md +12 -0
- data/lib/locale/driver/env.rb +1 -0
- data/lib/locale/version.rb +2 -2
- data/test/test_detect_general.rb +121 -44
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 530d2db4f5bc7f68d06654f0a8ec730479e79860
|
4
|
+
data.tar.gz: 72a52587e7410335944d6ac1ab1a769633598c58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f3cf2b1775cd5245c7e72ac837e2ec81af7db1b89abeb6771d74393bddde9d28ca4c1d0f73d2a615a474325c726ba37edebcce9551ba84d08b1c97941b244c2
|
7
|
+
data.tar.gz: c2c19cd4920438188f0f9cb7dff4cff07e1e87b8a15c3feb07bd49e9e3c7a4badfc6e950d5477f85e75a8a4134dc24a929782b4a2449d1f7b174dde471b8aef8
|
data/doc/text/news.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
+
## <a id="2-1-2">2.1.2</a>: 2015-09-15
|
4
|
+
|
5
|
+
### Improvements
|
6
|
+
|
7
|
+
* Improved GNU gettext compatibility: Ignored `LANGUAGE` environment
|
8
|
+
variable when either `LC_ALL`, `LC_MESSAGES` or `LANG` is C.
|
9
|
+
[GitHub#6] [Reported by Hleb Valoshka]
|
10
|
+
|
11
|
+
### Thanks
|
12
|
+
|
13
|
+
* Hleb Valoshka
|
14
|
+
|
3
15
|
## <a id="2-1-1">2.1.1</a>: 2015-05-16
|
4
16
|
|
5
17
|
### Improvements
|
data/lib/locale/driver/env.rb
CHANGED
@@ -57,6 +57,7 @@ module Locale
|
|
57
57
|
# Gets the locales from environment variables. (LANGUAGE > LC_ALL > LC_MESSAGES > LANG)
|
58
58
|
# * Returns: an Array of the locale as Locale::Tag::Posix or nil.
|
59
59
|
def locales
|
60
|
+
return nil if (ENV["LC_ALL"] || ENV["LC_MESSAGES"] || ENV["LANG"]) == "C"
|
60
61
|
locales = ENV["LANGUAGE"]
|
61
62
|
if (locales != nil and locales.size > 0)
|
62
63
|
locs = locales.split(/:/).collect{|v| Locale::Tag::Posix.parse(v)}.compact
|
data/lib/locale/version.rb
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
version - version information of Ruby-Locale
|
3
3
|
|
4
4
|
Copyright (C) 2008 Masao Mutoh
|
5
|
-
Copyright (C) 2013 Kouhei Sutou <kou@clear-code.com>
|
5
|
+
Copyright (C) 2013-2015 Kouhei Sutou <kou@clear-code.com>
|
6
6
|
|
7
7
|
You may redistribute it and/or modify it under the same
|
8
8
|
license terms as Ruby.
|
9
9
|
=end
|
10
10
|
module Locale
|
11
|
-
VERSION = "2.1.
|
11
|
+
VERSION = "2.1.2"
|
12
12
|
end
|
13
13
|
|
data/test/test_detect_general.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
|
3
|
+
# Copyright (C) 2012-2015 Kouhei Sutou <kou@clear-code.com>
|
4
4
|
# Copyright (C) 2012 Hleb Valoshka
|
5
5
|
# Copyright (C) 2009-2010 Masao Mutoh
|
6
6
|
#
|
@@ -137,59 +137,136 @@ class TestDetectGeneral < Test::Unit::TestCase
|
|
137
137
|
assert_equal "UTF-8", Locale.charset
|
138
138
|
end
|
139
139
|
|
140
|
-
|
141
|
-
|
142
|
-
|
140
|
+
sub_test_case "#language" do
|
141
|
+
test "LC_ALL" do
|
142
|
+
ENV["LC_ALL"] = "ja_JP.Shift_JIS"
|
143
|
+
ENV["LANGUAGE"] = "zh_CN.UTF-8:ja_JP"
|
143
144
|
|
144
|
-
|
145
|
-
|
146
|
-
|
145
|
+
tags = Locale.current
|
146
|
+
assert_equal Locale::Tag::Posix, tags[0].class
|
147
|
+
assert_equal Locale::Tag::Posix, tags[1].class
|
147
148
|
|
148
|
-
|
149
|
-
|
150
|
-
|
149
|
+
assert_equal "zh", tags.language
|
150
|
+
assert_equal "CN", tags.region
|
151
|
+
assert_equal "UTF-8", tags.charset
|
151
152
|
|
152
|
-
|
153
|
-
|
154
|
-
|
153
|
+
assert_equal "zh", tags[0].language
|
154
|
+
assert_equal "CN", tags[0].region
|
155
|
+
assert_equal "UTF-8", tags[0].charset
|
155
156
|
|
156
|
-
|
157
|
-
|
158
|
-
|
157
|
+
assert_equal "ja", tags[1].language
|
158
|
+
assert_equal "JP", tags[1].region
|
159
|
+
assert_equal nil, tags[1].charset
|
159
160
|
|
160
|
-
|
161
|
-
|
161
|
+
assert_equal Locale::TagList.new([Locale::Tag::Posix.new("zh", "CN", "UTF-8"),
|
162
|
+
Locale::Tag::Posix.new("ja", "JP")]), tags
|
162
163
|
|
163
|
-
|
164
|
-
|
164
|
+
assert_equal "Shift_JIS", Locale.charset
|
165
|
+
end
|
165
166
|
|
166
|
-
|
167
|
-
|
168
|
-
|
167
|
+
test "LC_ALL=C" do
|
168
|
+
ENV["LC_ALL"] = "C"
|
169
|
+
ENV["LANGUAGE"] = "zh_CN.UTF-8:ja_JP" # ignored
|
169
170
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
assert_equal "ja", tags.language
|
174
|
-
assert_equal "ja", tags[0].language
|
175
|
-
Locale.clear
|
176
|
-
ENV["LANGUAGE"] = ""
|
171
|
+
assert_equal([Locale::Tag::Simple.new("en")],
|
172
|
+
Locale.current)
|
173
|
+
end
|
177
174
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
175
|
+
test "LC_MESSAGES=C" do
|
176
|
+
ENV["LC_MESSAGES"] = "C"
|
177
|
+
ENV["LANGUAGE"] = "zh_CN.UTF-8:ja_JP" # ignored
|
178
|
+
|
179
|
+
assert_equal([Locale::Tag::Simple.new("en")],
|
180
|
+
Locale.current)
|
181
|
+
end
|
182
|
+
|
183
|
+
test "LANG=C" do
|
184
|
+
ENV["LANG"] = "C"
|
185
|
+
ENV["LANGUAGE"] = "zh_CN.UTF-8:ja_JP" # ignored
|
186
|
+
|
187
|
+
assert_equal([Locale::Tag::Simple.new("en")],
|
188
|
+
Locale.current)
|
189
|
+
end
|
190
|
+
|
191
|
+
test "LC_ALL and LC_MESSAGES=C" do
|
192
|
+
ENV["LC_ALL"] = "ja_JP.Shift_JIS"
|
193
|
+
ENV["LC_MESSAGES"] = "C"
|
194
|
+
ENV["LANGUAGE"] = "zh_CN.UTF-8:ja_JP"
|
185
195
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
196
|
+
assert_equal([
|
197
|
+
Locale::Tag::Posix.new("zh", "CN", "UTF-8"),
|
198
|
+
Locale::Tag::Posix.new("ja", "JP"),
|
199
|
+
],
|
200
|
+
Locale.current)
|
201
|
+
end
|
202
|
+
|
203
|
+
test "LC_ALL and LANG=C" do
|
204
|
+
ENV["LC_ALL"] = "ja_JP.Shift_JIS"
|
205
|
+
ENV["LANG"] = "C"
|
206
|
+
ENV["LANGUAGE"] = "zh_CN.UTF-8:ja_JP"
|
207
|
+
|
208
|
+
assert_equal([
|
209
|
+
Locale::Tag::Posix.new("zh", "CN", "UTF-8"),
|
210
|
+
Locale::Tag::Posix.new("ja", "JP"),
|
211
|
+
],
|
212
|
+
Locale.current)
|
213
|
+
end
|
214
|
+
|
215
|
+
test "LC_ALL=C and LC_MESSAGES" do
|
216
|
+
ENV["LC_ALL"] = "C"
|
217
|
+
ENV["LC_MESSAGES"] = "ja_JP.Shift_JIS"
|
218
|
+
ENV["LANGUAGE"] = "zh_CN.UTF-8:ja_JP" # ignored
|
219
|
+
|
220
|
+
assert_equal([Locale::Tag::Simple.new("en")],
|
221
|
+
Locale.current)
|
222
|
+
end
|
223
|
+
|
224
|
+
test "LC_ALL=C and LANG" do
|
225
|
+
ENV["LC_ALL"] = "C"
|
226
|
+
ENV["LANG"] = "ja_JP.Shift_JIS"
|
227
|
+
ENV["LANGUAGE"] = "zh_CN.UTF-8:ja_JP" # ignored
|
228
|
+
|
229
|
+
assert_equal([Locale::Tag::Simple.new("en")],
|
230
|
+
Locale.current)
|
231
|
+
end
|
232
|
+
|
233
|
+
test "LC_MESSAGES=C and LANG" do
|
234
|
+
ENV["LC_MESSAGES"] = "C"
|
235
|
+
ENV["LANG"] = "ja_JP.Shift_JIS"
|
236
|
+
ENV["LANGUAGE"] = "zh_CN.UTF-8:ja_JP" # ignored
|
237
|
+
|
238
|
+
assert_equal([Locale::Tag::Simple.new("en")],
|
239
|
+
Locale.current)
|
240
|
+
end
|
241
|
+
|
242
|
+
test "strip" do
|
243
|
+
ENV["LC_ALL"] = "ja_JP.Shift_JIS"
|
244
|
+
ENV["LANGUAGE"] = nil
|
245
|
+
|
246
|
+
tags = Locale.current
|
247
|
+
assert_equal 1, tags.size
|
248
|
+
assert_equal Locale::Tag::Posix, tags[0].class
|
249
|
+
assert_equal "ja", tags.language
|
250
|
+
assert_equal "ja", tags[0].language
|
251
|
+
Locale.clear
|
252
|
+
ENV["LANGUAGE"] = ""
|
253
|
+
|
254
|
+
tags = Locale.current
|
255
|
+
assert_equal 1, tags.size
|
256
|
+
assert_equal Locale::Tag::Posix, tags[0].class
|
257
|
+
assert_equal "ja", tags.language
|
258
|
+
assert_equal "ja", tags[0].language
|
259
|
+
Locale.clear
|
260
|
+
ENV["LANGUAGE"] = "zh_CN.UTF-8:ja_JP"
|
261
|
+
|
262
|
+
tags = Locale.current
|
263
|
+
assert_equal 2, tags.size
|
264
|
+
assert_equal Locale::Tag::Posix, tags[0].class
|
265
|
+
assert_equal Locale::Tag::Posix, tags[1].class
|
266
|
+
assert_equal "zh", tags.language
|
267
|
+
assert_equal "zh", tags[0].language
|
268
|
+
assert_equal "ja", tags[1].language
|
269
|
+
end
|
193
270
|
end
|
194
271
|
|
195
272
|
def test_no_charset
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: locale
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-09-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|