gettext 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +128 -0
- data/NEWS +10 -0
- data/README +21 -23
- data/Rakefile +39 -20
- data/bin/rgettext +1 -1
- data/bin/rmsgfmt +1 -1
- data/bin/rmsgmerge +1 -1
- data/data/locale/cs/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/cs/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/de/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/de/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/el/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/el/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/es/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/es/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/fr/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/fr/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/it/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/ja/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/ja/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/ko/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/ko/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/nl/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/nl/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/pt_BR/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/pt_BR/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/sv/LC_MESSAGES/rgettext.mo +0 -0
- data/ext/gettext/extconf.rb +20 -0
- data/ext/gettext/{gettext/_locale.c → locale_system.c} +15 -19
- data/lib/gettext.rb +186 -38
- data/lib/gettext/cgi.rb +35 -69
- data/lib/gettext/container.rb +14 -5
- data/lib/gettext/erb.rb +30 -2
- data/lib/gettext/iconv.rb +19 -4
- data/lib/gettext/locale.rb +188 -39
- data/lib/gettext/locale_cgi.rb +102 -0
- data/lib/gettext/locale_object.rb +131 -0
- data/lib/gettext/locale_posix.rb +50 -0
- data/lib/gettext/locale_table_win32.rb +224 -182
- data/lib/gettext/locale_win32.rb +59 -35
- data/lib/gettext/mo.rb +2 -2
- data/lib/gettext/parser/activerecord.rb +19 -5
- data/lib/gettext/parser/erb.rb +6 -3
- data/lib/gettext/parser/glade.rb +5 -5
- data/lib/gettext/parser/ruby.rb +6 -6
- data/lib/gettext/poparser.rb +7 -6
- data/lib/gettext/rails.rb +122 -44
- data/lib/gettext/rgettext.rb +21 -8
- data/lib/gettext/rmsgfmt.rb +16 -8
- data/lib/gettext/rmsgmerge.rb +172 -50
- data/lib/gettext/string.rb +25 -3
- data/lib/gettext/textdomain.rb +89 -90
- data/lib/gettext/utils.rb +63 -3
- data/lib/gettext/version.rb +2 -2
- data/pkg/ruby-gettext-package-1.2.0/ext/gettext/extconf.rb +20 -0
- data/po/cs/rails.po +28 -28
- data/po/cs/rgettext.po +14 -14
- data/po/de/rails.po +29 -26
- data/po/de/rgettext.po +24 -17
- data/po/el/rails.po +26 -26
- data/po/el/rgettext.po +18 -15
- data/po/es/rails.po +26 -26
- data/po/es/rgettext.po +16 -16
- data/po/fr/rails.po +27 -27
- data/po/fr/rgettext.po +14 -14
- data/po/it/rgettext.po +14 -14
- data/po/ja/rails.po +24 -24
- data/po/ja/rgettext.po +14 -14
- data/po/ko/rails.po +24 -24
- data/po/ko/rgettext.po +17 -18
- data/po/nl/rails.po +27 -27
- data/po/nl/rgettext.po +18 -18
- data/po/pt_BR/rails.po +26 -26
- data/po/pt_BR/rgettext.po +14 -14
- data/po/rails.pot +26 -26
- data/po/rgettext.pot +14 -14
- data/po/sv/rgettext.po +14 -14
- data/post-setup.rb +8 -3
- data/pre-setup.rb +14 -1
- data/samples/cgi/http.rb +2 -1
- data/samples/makemo.rb +1 -1
- data/samples/rails/app/models/article.rb +15 -1
- data/samples/rails/locale/cs/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/cs/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/de/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/de/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/el/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/el/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/en/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/es/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/es/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/fr/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/fr/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/ja/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/ja/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/ko/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/ko/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/nl/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/nl/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/pt_BR/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/pt_BR/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/po/blog.pot +1 -1
- data/samples/rails/po/cs/blog.po +1 -2
- data/samples/rails/po/cs/gettext_plugin.po +1 -1
- data/samples/rails/po/de/blog.po +1 -2
- data/samples/rails/po/de/gettext_plugin.po +1 -1
- data/samples/rails/po/el/blog.po +1 -1
- data/samples/rails/po/el/gettext_plugin.po +1 -1
- data/samples/rails/po/en/blog.po +1 -1
- data/samples/rails/po/es/blog.po +1 -2
- data/samples/rails/po/es/gettext_plugin.po +1 -1
- data/samples/rails/po/fr/blog.po +1 -1
- data/samples/rails/po/fr/gettext_plugin.po +1 -1
- data/samples/rails/po/gettext_plugin.pot +1 -1
- data/samples/rails/po/ja/blog.po +2 -1
- data/samples/rails/po/ja/gettext_plugin.po +1 -1
- data/samples/rails/po/ko/blog.po +1 -2
- data/samples/rails/po/ko/gettext_plugin.po +1 -1
- data/samples/rails/po/nl/blog.po +1 -3
- data/samples/rails/po/nl/gettext_plugin.po +1 -1
- data/samples/rails/po/pt_BR/blog.po +1 -1
- data/samples/rails/po/pt_BR/gettext_plugin.po +1 -1
- data/setup.rb +799 -574
- data/src/poparser.ry +6 -5
- data/test/gettext_runner.rb +3 -1
- data/test/gettext_test.rb +40 -24
- data/test/gettext_test_cgi.rb +60 -6
- data/test/gettext_test_locale.rb +136 -0
- data/test/gettext_test_parser.rb +12 -12
- data/test/locale/la/LC_MESSAGES/plural_error.mo +0 -0
- data/test/po/la/plural_error.po +21 -0
- data/test/test.bat +2 -0
- data/test/test.sh +2 -4
- data/test/{test_rubyparser_n.rb → test_rubyparser_n_.rb} +0 -0
- metadata +17 -12
- data/ext/gettext/gettext/MANIFEST +0 -3
- data/ext/gettext/gettext/extconf.rb +0 -20
- data/lib/gettext/locale_default.rb +0 -35
data/src/poparser.ry
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# You may redistribute it and/or modify it under the same
|
7
7
|
# license terms as Ruby.
|
8
8
|
|
9
|
-
class GetText::PoParser
|
9
|
+
class GetText::PoParser
|
10
10
|
|
11
11
|
token COMMENT MSGID MSGID_PLURAL MSGSTR STRING PLURAL_NUM
|
12
12
|
|
@@ -21,7 +21,7 @@ class GetText::PoParser
|
|
21
21
|
message
|
22
22
|
: MSGID string_list MSGSTR string_list
|
23
23
|
{
|
24
|
-
if @fuzzy
|
24
|
+
if @fuzzy and $ignore_fuzzy
|
25
25
|
if val[1] != ""
|
26
26
|
$stderr.print _("Warning: fuzzy message was ignored.\n")
|
27
27
|
$stderr.print " msgid '#{val[1]}'\n"
|
@@ -36,7 +36,7 @@ class GetText::PoParser
|
|
36
36
|
}
|
37
37
|
| MSGID string_list MSGID_PLURAL string_list msgstr_plural
|
38
38
|
{
|
39
|
-
if @fuzzy
|
39
|
+
if @fuzzy and $ignore_fuzzy
|
40
40
|
if val[1] != ""
|
41
41
|
$stderr.print _("Warning: fuzzy message was ignored.\n")
|
42
42
|
$stderr.print "msgid = '#{val[1]}\n"
|
@@ -98,10 +98,11 @@ end
|
|
98
98
|
ret
|
99
99
|
end
|
100
100
|
|
101
|
-
def parse(str, data)
|
101
|
+
def parse(str, data, ignore_fuzzy = true)
|
102
102
|
@comments = []
|
103
103
|
@data = data
|
104
104
|
@fuzzy = false
|
105
|
+
$ignore_fuzzy = ignore_fuzzy
|
105
106
|
str.strip!
|
106
107
|
@q = []
|
107
108
|
until str.empty? do
|
@@ -158,7 +159,7 @@ end
|
|
158
159
|
|
159
160
|
def on_message(msgid, msgstr)
|
160
161
|
@data[msgid] = msgstr
|
161
|
-
|
162
|
+
|
162
163
|
@data.set_comment(msgid, @comments.join("\n"))
|
163
164
|
@comments.clear
|
164
165
|
end
|
data/test/gettext_runner.rb
CHANGED
@@ -2,6 +2,7 @@ require 'test/unit/testsuite'
|
|
2
2
|
require 'gettext_test'
|
3
3
|
require 'gettext_test_parser'
|
4
4
|
require 'gettext_test_string'
|
5
|
+
require 'gettext_test_locale'
|
5
6
|
|
6
7
|
class GetTextTest
|
7
8
|
def suite
|
@@ -9,11 +10,12 @@ class GetTextTest
|
|
9
10
|
s << TestGetText.suite
|
10
11
|
s << TestGetTextParser.suite
|
11
12
|
s << TestGetTextString.suite
|
13
|
+
s << TestLocale.suite
|
12
14
|
s
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
16
|
-
if RUBY_VERSION >= '1.8.
|
18
|
+
if RUBY_VERSION >= '1.8.3'
|
17
19
|
Test::Unit::AutoRunner.run
|
18
20
|
else
|
19
21
|
Test::Unit::AutoRunner.run(GetTextTest)
|
data/test/gettext_test.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
|
3
3
|
require 'gettext.rb'
|
4
|
-
|
5
4
|
require 'testlib1.rb'
|
6
5
|
require 'testlib2.rb'
|
7
6
|
require 'testlib3.rb'
|
@@ -16,14 +15,12 @@ class TestGetText < Test::Unit::TestCase
|
|
16
15
|
GetText.locale = nil
|
17
16
|
return if /linux/ !~ RUBY_PLATFORM
|
18
17
|
GetText.bindtextdomain("libc")
|
19
|
-
GetText.locale = "ja_JP.eucJP"
|
20
|
-
GetText.charset = "euc-jp"
|
21
18
|
assert_equal("��λ���ޤ���", GetText._("Terminated"))
|
22
19
|
|
23
20
|
GetText.locale = nil
|
24
21
|
GetText.bindtextdomain("test1", "locale")
|
25
|
-
assert_equal("japanese", GetText._("language"))
|
26
22
|
|
23
|
+
assert_equal("japanese", GetText._("language"))
|
27
24
|
GetText.bindtextdomain("libc", "/usr/share/locale")
|
28
25
|
assert_equal("��λ���ޤ���", GetText._("Terminated"))
|
29
26
|
|
@@ -33,10 +30,13 @@ class TestGetText < Test::Unit::TestCase
|
|
33
30
|
GetText.bindtextdomain("libc", "/usr/share/locale/")
|
34
31
|
assert_equal("��λ���ޤ���", GetText._("Terminated"))
|
35
32
|
|
33
|
+
GetText.locale = nil
|
34
|
+
GetText.charset = nil
|
36
35
|
GetText.bindtextdomain("libc", "/usr/share/locale", "de")
|
37
36
|
assert_equal("Beendet", GetText._("Terminated"))
|
38
37
|
|
39
38
|
GetText.bindtextdomain("test1", "locale")
|
39
|
+
|
40
40
|
GetText.locale = "fr"
|
41
41
|
assert_equal("french", GetText._("language"))
|
42
42
|
|
@@ -178,7 +178,10 @@ DDD
|
|
178
178
|
def test_plural_format_invalid
|
179
179
|
setlocale(nil)
|
180
180
|
bindtextdomain("plural_error", "locale", "ja")
|
181
|
+
#If it defines msgstr[0] only, msgstr[0] is used everytime.
|
181
182
|
assert_equal("a", n_("one", "two", 0))
|
183
|
+
assert_equal("a", n_("one", "two", 1))
|
184
|
+
assert_equal("a", n_("one", "two", 2))
|
182
185
|
# Use default(plural = 0)
|
183
186
|
setlocale("fr")
|
184
187
|
assert_equal("fr_one", n_("one", "two", 0))
|
@@ -188,40 +191,53 @@ DDD
|
|
188
191
|
assert_equal("da_one", n_("one", "two", 0))
|
189
192
|
assert_equal("da_one", n_("one", "two", 1))
|
190
193
|
assert_equal("da_one", n_("one", "two", 2))
|
194
|
+
setlocale("la")
|
195
|
+
assert_equal("la_one", n_("one", "two", 0))
|
196
|
+
assert_equal("la_one", n_("one", "two", 1))
|
197
|
+
assert_equal("la_one", n_("one", "two", 2))
|
191
198
|
end
|
192
199
|
|
193
|
-
def
|
200
|
+
def test_plural_array
|
194
201
|
GetText.locale = nil
|
195
|
-
bindtextdomain("
|
196
|
-
assert_equal("
|
197
|
-
|
198
|
-
assert_equal("
|
199
|
-
setlocale("fr")
|
200
|
-
assert_equal("french", _("language"))
|
202
|
+
bindtextdomain("plural", "locale", "da")
|
203
|
+
assert_equal("da_plural", n_(["one", "two"], 0))
|
204
|
+
assert_equal("da_one", n_(["one", "two"], 1))
|
205
|
+
assert_equal("da_plural", n_(["one", "two"], 2))
|
201
206
|
end
|
202
207
|
|
203
|
-
def
|
208
|
+
def test_Nn_
|
204
209
|
GetText.locale = nil
|
205
|
-
|
206
|
-
assert_equal("
|
207
|
-
assert_equal("ja_JP.eucJP", Locale.get)
|
208
|
-
assert_equal("EUC-JP", Locale.codeset)
|
209
|
-
|
210
|
-
loc = Locale.set(Locale::CTYPE, "ja_JP.UTF-8")
|
211
|
-
assert_equal("ja_JP.UTF-8", loc)
|
212
|
-
assert_equal("ja_JP.UTF-8", Locale.get)
|
213
|
-
assert_equal("UTF-8", Locale.codeset)
|
214
|
-
|
215
|
-
Locale.setlocale(Locale::CTYPE, "ja_JP.eucJP")
|
210
|
+
bindtextdomain("plural", "locale", "da")
|
211
|
+
assert_equal(["one", "two"], Nn_("one", "two"))
|
216
212
|
end
|
217
213
|
|
218
214
|
def test_textdomain
|
219
215
|
GetText.locale = nil
|
220
|
-
Locale.
|
216
|
+
Locale.set("ja_JP.eucJP")
|
221
217
|
testlib = TestLib4.new
|
222
218
|
assert_equal("japanese", testlib.test)
|
223
219
|
assert_raises(GetText::NoboundTextDomainError) {
|
224
220
|
GetText.textdomain("nodomainisdefined")
|
225
221
|
}
|
222
|
+
default_locale_dirs = [
|
223
|
+
"#{Config::CONFIG['datadir']}/locale/%{locale}/LC_MESSAGES/%{name}.mo",
|
224
|
+
"#{Config::CONFIG['prefix']}/share/locale/%{locale}/LC_MESSAGES/%{name}.mo",
|
225
|
+
"#{Config::CONFIG['prefix']}/local/share/locale/%{locale}/LC_MESSAGES/%{name}.mo"
|
226
|
+
].uniq
|
227
|
+
assert_equal(default_locale_dirs, GetText::TextDomain::DEFAULT_LOCALE_PATHS)
|
228
|
+
new_path = "/foo/%{locale}/%{name}.mo"
|
229
|
+
GetText::TextDomain.add_default_locale_path(new_path)
|
230
|
+
assert_equal(default_locale_dirs << new_path, GetText::TextDomain::DEFAULT_LOCALE_PATHS)
|
226
231
|
end
|
232
|
+
|
233
|
+
def test_setlocale
|
234
|
+
GetText.locale = nil
|
235
|
+
bindtextdomain("test1", "locale")
|
236
|
+
assert_equal("japanese", _("language"))
|
237
|
+
setlocale("en")
|
238
|
+
assert_equal("language", _("language"))
|
239
|
+
setlocale("fr")
|
240
|
+
assert_equal("french", _("language"))
|
241
|
+
end
|
242
|
+
|
227
243
|
end
|
data/test/gettext_test_cgi.rb
CHANGED
@@ -1,12 +1,66 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
require 'gettext/cgi'
|
3
|
+
require 'stringio'
|
3
4
|
|
4
5
|
class TestGetTextCGI < Test::Unit::TestCase
|
5
|
-
def
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
assert_equal("ja_JP", Locale.normalize("ja-jp"))
|
10
|
-
assert_equal("ja", Locale.normalize("ja"))
|
6
|
+
def setup_cgi(str)
|
7
|
+
$stdin = StringIO.new(str)
|
8
|
+
cgi = CGI.new
|
9
|
+
Locale.cgi = cgi
|
11
10
|
end
|
11
|
+
|
12
|
+
def test_system
|
13
|
+
#query string
|
14
|
+
setup_cgi("lang=ja_JP")
|
15
|
+
assert_equal("ja_JP", Locale.system.to_str)
|
16
|
+
setup_cgi("lang=ja-jp")
|
17
|
+
assert_equal("ja_JP", Locale.system.to_str)
|
18
|
+
assert_equal("ja-JP", Locale.system.to_iso3066)
|
19
|
+
setup_cgi("lang=ja-jp")
|
20
|
+
assert_equal("ja_JP", Locale.system.to_str)
|
21
|
+
assert_equal("ja-JP", Locale.system.to_iso3066)
|
22
|
+
setup_cgi("")
|
23
|
+
ENV["HTTP_ACCEPT_LANGUAGE"] = ""
|
24
|
+
ENV["HTTP_ACCEPT_CHARSET"] = ""
|
25
|
+
assert_equal("en", Locale.system.to_str)
|
26
|
+
assert_equal("en", Locale.system.to_iso3066)
|
27
|
+
|
28
|
+
#cockie
|
29
|
+
setup_cgi("Set-Cookie: lang=en-us")
|
30
|
+
assert_equal("en_US", Locale.system.to_str)
|
31
|
+
|
32
|
+
#accept language
|
33
|
+
setup_cgi("")
|
34
|
+
ENV["HTTP_ACCEPT_LANGUAGE"] = "ja,en-us;q=0.7,en;q=0.3"
|
35
|
+
assert_equal("ja", Locale.system.to_str)
|
36
|
+
assert_equal("ja", Locale.system.to_iso3066)
|
37
|
+
ENV["HTTP_ACCEPT_LANGUAGE"] = "en-us,ja;q=0.7,en;q=0.3"
|
38
|
+
assert_equal("en_US", Locale.system.to_str)
|
39
|
+
assert_equal("en-US", Locale.system.to_iso3066)
|
40
|
+
ENV["HTTP_ACCEPT_LANGUAGE"] = "en"
|
41
|
+
assert_equal("en", Locale.system.to_str)
|
42
|
+
assert_equal("en", Locale.system.to_iso3066)
|
43
|
+
|
44
|
+
#accept charset
|
45
|
+
ENV["HTTP_ACCEPT_CHARSET"] = "Shift_JIS"
|
46
|
+
assert_equal("Shift_JIS", Locale.system.charset)
|
47
|
+
ENV["HTTP_ACCEPT_CHARSET"] = "EUC-JP,*,utf-8"
|
48
|
+
assert_equal("EUC-JP", Locale.system.charset)
|
49
|
+
ENV["HTTP_ACCEPT_CHARSET"] = "*"
|
50
|
+
assert_equal("UTF-8", Locale.system.charset)
|
51
|
+
ENV["HTTP_ACCEPT_CHARSET"] = ""
|
52
|
+
assert_equal("UTF-8", Locale.system.charset)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_default
|
56
|
+
Locale.set_default(nil)
|
57
|
+
Locale.set_default(Locale::Object.new("ja_JP", nil, "EUC-JP"))
|
58
|
+
setup_cgi("")
|
59
|
+
ENV["HTTP_ACCEPT_LANGUAGE"] = ""
|
60
|
+
ENV["HTTP_ACCEPT_CHARSET"] = ""
|
61
|
+
assert_equal("ja_JP", Locale.default.to_str)
|
62
|
+
assert_equal("EUC-JP", Locale.default.charset)
|
63
|
+
Locale.set_default(nil)
|
64
|
+
end
|
65
|
+
|
12
66
|
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'gettext/locale'
|
3
|
+
|
4
|
+
class TestLocale < Test::Unit::TestCase
|
5
|
+
def test_locale_object
|
6
|
+
obj = Locale::Object.new("ja", "JP", "eucJP")
|
7
|
+
assert_equal("ja", obj.language)
|
8
|
+
assert_equal("JP", obj.country)
|
9
|
+
assert_equal("eucJP", obj.charset)
|
10
|
+
assert_equal("ja_JP", obj.to_posix)
|
11
|
+
assert_equal("ja_JP", obj.to_str)
|
12
|
+
assert_equal("ja-JP", obj.to_iso3066)
|
13
|
+
assert_equal(["ja", "JP", "eucJP", nil, nil, nil], obj.to_a)
|
14
|
+
|
15
|
+
obj = Locale::Object.new("ja", "JP")
|
16
|
+
assert_equal("ja", obj.language)
|
17
|
+
assert_equal("JP", obj.country)
|
18
|
+
assert_equal(nil, obj.charset)
|
19
|
+
assert_equal(nil, obj.script)
|
20
|
+
assert_equal(nil, obj.sort_order)
|
21
|
+
assert_equal(nil, obj.modifier)
|
22
|
+
assert_equal(["ja", "JP", nil, nil, nil, nil], obj.to_a)
|
23
|
+
|
24
|
+
obj = Locale::Object.new("ja")
|
25
|
+
assert_equal("ja", obj.language)
|
26
|
+
assert_equal(nil, obj.country)
|
27
|
+
assert_equal(nil, obj.charset)
|
28
|
+
assert_equal(nil, obj.script)
|
29
|
+
assert_equal(nil, obj.sort_order)
|
30
|
+
assert_equal(nil, obj.modifier)
|
31
|
+
assert_equal(["ja", nil, nil, nil, nil, nil], obj.to_a)
|
32
|
+
|
33
|
+
obj = Locale::Object.new("ja_JP.eucJP", nil, "UTF-8")
|
34
|
+
assert_equal("ja", obj.language)
|
35
|
+
assert_equal("JP", obj.country)
|
36
|
+
assert_equal("UTF-8", obj.charset)
|
37
|
+
assert_equal(nil, obj.script)
|
38
|
+
assert_equal(nil, obj.sort_order)
|
39
|
+
assert_equal(nil, obj.modifier)
|
40
|
+
assert_equal(["ja", "JP", "UTF-8", nil, nil, nil], obj.to_a)
|
41
|
+
|
42
|
+
obj = Locale::Object.new("en-US.iso8859-1", "CA")
|
43
|
+
assert_equal("en", obj.language)
|
44
|
+
assert_equal("CA", obj.country)
|
45
|
+
assert_equal("iso8859-1", obj.charset)
|
46
|
+
assert_equal(nil, obj.script)
|
47
|
+
assert_equal(nil, obj.sort_order)
|
48
|
+
assert_equal(nil, obj.modifier)
|
49
|
+
assert_equal(["en", "CA", "iso8859-1", nil, nil, nil], obj.to_a)
|
50
|
+
|
51
|
+
obj = Locale::Object.new("uz@Latn")
|
52
|
+
assert_equal("uz", obj.language)
|
53
|
+
assert_equal(nil, obj.country)
|
54
|
+
assert_equal(nil, obj.charset)
|
55
|
+
assert_equal(nil, obj.script)
|
56
|
+
assert_equal(nil, obj.sort_order)
|
57
|
+
assert_equal("Latn", obj.modifier)
|
58
|
+
assert_equal(["uz", nil, nil, nil, nil, "Latn"], obj.to_a)
|
59
|
+
|
60
|
+
obj = Locale::Object.new("zh_CN.GB2312@test")
|
61
|
+
assert_equal("zh", obj.language)
|
62
|
+
assert_equal("CN", obj.country)
|
63
|
+
assert_equal("GB2312", obj.charset)
|
64
|
+
assert_equal(nil, obj.script)
|
65
|
+
assert_equal(nil, obj.sort_order)
|
66
|
+
assert_equal("test", obj.modifier)
|
67
|
+
assert_equal(["zh", "CN", "GB2312", nil, nil, "test"], obj.to_a)
|
68
|
+
|
69
|
+
obj = Locale::Object.new("wa_BE.iso885915@euro")
|
70
|
+
assert_equal("wa", obj.language)
|
71
|
+
assert_equal("BE", obj.country)
|
72
|
+
assert_equal("iso885915", obj.charset)
|
73
|
+
assert_equal(nil, obj.script)
|
74
|
+
assert_equal(nil, obj.sort_order)
|
75
|
+
assert_equal("euro", obj.modifier)
|
76
|
+
assert_equal(["wa", "BE", "iso885915", nil, nil, "euro"], obj.to_a)
|
77
|
+
|
78
|
+
obj = Locale::Object.new("uz-uz-latn")
|
79
|
+
assert_equal("uz", obj.language)
|
80
|
+
assert_equal("UZ", obj.country)
|
81
|
+
assert_equal(nil, obj.charset)
|
82
|
+
assert_equal("Latn", obj.script)
|
83
|
+
assert_equal(nil, obj.sort_order)
|
84
|
+
assert_equal(nil, obj.modifier)
|
85
|
+
assert_equal(["uz", "UZ", nil, "Latn", nil, nil], obj.to_a)
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_locale
|
89
|
+
loc = Locale.clear
|
90
|
+
if /win32|cygwin|mingw/ =~ RUBY_PLATFORM
|
91
|
+
Locale.set("ja-jp")
|
92
|
+
assert_equal("ja_JP", Locale.get.to_str)
|
93
|
+
assert_equal("CP932", Locale.get.charset)
|
94
|
+
Locale.clear
|
95
|
+
Locale.set("C")
|
96
|
+
assert_equal("C", Locale.get.to_str)
|
97
|
+
assert_equal("CP1252", Locale.get.charset)
|
98
|
+
Locale.set_current("as-IN")
|
99
|
+
assert_equal("as_IN", Locale.get.to_str)
|
100
|
+
assert_equal("UNICODE", Locale.get.charset)
|
101
|
+
Locale.set_current("az_AZ-Latn")
|
102
|
+
assert_equal("az-AZ", Locale.get.to_iso3066)
|
103
|
+
assert_equal("az-AZ-Latn", Locale.get.to_win)
|
104
|
+
assert_equal("CP1254", Locale.get.charset)
|
105
|
+
Locale.set_current("iu-CA-Cans")
|
106
|
+
assert_equal("iu-CA", Locale.get.to_iso3066)
|
107
|
+
assert_equal("iu-CA-Cans", Locale.get.to_win)
|
108
|
+
assert_equal("UNICODE", Locale.get.charset)
|
109
|
+
else
|
110
|
+
loc = Locale.get
|
111
|
+
assert_equal("ja_JP", Locale.get.to_str)
|
112
|
+
assert_equal("EUC-JP", Locale.codeset)
|
113
|
+
|
114
|
+
loc = Locale.set("ja_JP")
|
115
|
+
assert_equal("ja_JP", loc.to_str)
|
116
|
+
assert_equal("ja_JP", Locale.get.to_str)
|
117
|
+
assert_equal("EUC-JP", Locale.codeset)
|
118
|
+
end
|
119
|
+
|
120
|
+
=begin
|
121
|
+
# Deprecated
|
122
|
+
loc = Locale.set(Locale::CTYPE, "ja_JP.eucJP")
|
123
|
+
assert_equal("ja_JP", loc.to_str)
|
124
|
+
assert_equal("ja_JP", Locale.get.to_str)
|
125
|
+
assert_equal("eucJP", Locale.codeset)
|
126
|
+
|
127
|
+
# Deprecated
|
128
|
+
loc = Locale.set(Locale::CTYPE, "ja_JP.UTF-8")
|
129
|
+
assert_equal("ja_JP", loc.to_str)
|
130
|
+
assert_equal("ja_JP", Locale.get.to_str)
|
131
|
+
assert_equal("UTF-8", Locale.codeset)
|
132
|
+
=end
|
133
|
+
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
data/test/gettext_test_parser.rb
CHANGED
@@ -46,18 +46,18 @@ class TestGetTextParser < Test::Unit::TestCase
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def test_ruby_n
|
49
|
-
ary = GetText::RubyParser.parse('
|
50
|
-
assert_equal(["aaa\000aaa2", '
|
51
|
-
assert_equal(["bbb\\n\000ccc2\\nccc2", '
|
52
|
-
assert_equal(["ddd\\nddd\000ddd2\\nddd2", '
|
53
|
-
assert_equal(["eee\\neee\\n\000eee2\\neee2\\n", '
|
54
|
-
assert_equal(["ddd\\neee\\n\000ddd\\neee2", '
|
55
|
-
assert_equal(["fff\000fff2", '
|
56
|
-
assert_equal(["ggg\000ggg2", '
|
57
|
-
assert_equal(["ggghhhiii\000jjjkkklll", '
|
58
|
-
# assert_equal(["a"b"c"\000a"b"c"2", '
|
59
|
-
assert_equal(["mmmmmm\000mmm2mmm2", '
|
60
|
-
assert_equal(["nnn\000nnn2", '
|
49
|
+
ary = GetText::RubyParser.parse('test_rubyparser_n_.rb')
|
50
|
+
assert_equal(["aaa\000aaa2", 'test_rubyparser_n_.rb:8'], ary[0])
|
51
|
+
assert_equal(["bbb\\n\000ccc2\\nccc2", 'test_rubyparser_n_.rb:12'], ary[1])
|
52
|
+
assert_equal(["ddd\\nddd\000ddd2\\nddd2", 'test_rubyparser_n_.rb:16'], ary[2])
|
53
|
+
assert_equal(["eee\\neee\\n\000eee2\\neee2\\n", 'test_rubyparser_n_.rb:21'], ary[3])
|
54
|
+
assert_equal(["ddd\\neee\\n\000ddd\\neee2", 'test_rubyparser_n_.rb:27'], ary[4])
|
55
|
+
assert_equal(["fff\000fff2", 'test_rubyparser_n_.rb:34', 'test_rubyparser_n_.rb:38'], ary[5])
|
56
|
+
assert_equal(["ggg\000ggg2", 'test_rubyparser_n_.rb:38'], ary[6])
|
57
|
+
assert_equal(["ggghhhiii\000jjjkkklll", 'test_rubyparser_n_.rb:42'], ary[7])
|
58
|
+
# assert_equal(["a"b"c"\000a"b"c"2", 'test_rubyparser_n_.rb:51'], ary[8])
|
59
|
+
assert_equal(["mmmmmm\000mmm2mmm2", 'test_rubyparser_n_.rb:59'], ary[10])
|
60
|
+
assert_equal(["nnn\000nnn2", 'test_rubyparser_n_.rb:60'], ary[11])
|
61
61
|
end
|
62
62
|
|
63
63
|
def test_glade
|
Binary file
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# SOME DESCRIPTIVE TITLE.
|
2
|
+
# Copyright (C) YEAR ORGANIZATION
|
3
|
+
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
4
|
+
#
|
5
|
+
#, fuzzy
|
6
|
+
msgid ""
|
7
|
+
msgstr ""
|
8
|
+
"Project-Id-Version: PACKAGE VERSION\n"
|
9
|
+
"POT-Creation-Date: 2002-10-21 15:32:15+0900\n"
|
10
|
+
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
11
|
+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
12
|
+
"Language-Team: LANGUAGE <LL@li.org>\n"
|
13
|
+
"MIME-Version: 1.0\n"
|
14
|
+
"Content-Type: text/plain; charset=US-ASCII\n"
|
15
|
+
"Content-Transfer-Encoding: ENCODING\n"
|
16
|
+
"Plural-Forms: nplurals=2; plural= n != 1;\n"
|
17
|
+
|
18
|
+
#: hello_plural.rb:11
|
19
|
+
msgid "one"
|
20
|
+
msgid_plural "two"
|
21
|
+
msgstr[0] "la_one"
|