gettext 2.0.4 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/COPYING +9 -8
  2. data/ChangeLog +21 -0
  3. data/README.rdoc +7 -13
  4. data/Rakefile +7 -5
  5. data/benchmark/1.93.0.txt +8 -0
  6. data/benchmark/2.0.0.txt +8 -0
  7. data/benchmark/2.0.4.txt +11 -0
  8. data/benchmark/2.1.0.txt +11 -0
  9. data/benchmark/benchmark.rb +68 -0
  10. data/benchmark/test.rb +28 -0
  11. data/bin/rgettext +1 -2
  12. data/bin/rmsgfmt +1 -3
  13. data/bin/rmsgmerge +0 -2
  14. data/data/locale/bg/LC_MESSAGES/rgettext.mo +0 -0
  15. data/data/locale/bs/LC_MESSAGES/rgettext.mo +0 -0
  16. data/data/locale/ca/LC_MESSAGES/rgettext.mo +0 -0
  17. data/data/locale/cs/LC_MESSAGES/rgettext.mo +0 -0
  18. data/data/locale/de/LC_MESSAGES/rgettext.mo +0 -0
  19. data/data/locale/el/LC_MESSAGES/rgettext.mo +0 -0
  20. data/data/locale/eo/LC_MESSAGES/rgettext.mo +0 -0
  21. data/data/locale/es/LC_MESSAGES/rgettext.mo +0 -0
  22. data/data/locale/et/LC_MESSAGES/rgettext.mo +0 -0
  23. data/data/locale/fr/LC_MESSAGES/rgettext.mo +0 -0
  24. data/data/locale/hr/LC_MESSAGES/rgettext.mo +0 -0
  25. data/data/locale/hu/LC_MESSAGES/rgettext.mo +0 -0
  26. data/data/locale/it/LC_MESSAGES/rgettext.mo +0 -0
  27. data/data/locale/ja/LC_MESSAGES/rgettext.mo +0 -0
  28. data/data/locale/ko/LC_MESSAGES/rgettext.mo +0 -0
  29. data/data/locale/lv/LC_MESSAGES/rgettext.mo +0 -0
  30. data/data/locale/nb/LC_MESSAGES/rgettext.mo +0 -0
  31. data/data/locale/nl/LC_MESSAGES/rgettext.mo +0 -0
  32. data/data/locale/pt_BR/LC_MESSAGES/rgettext.mo +0 -0
  33. data/data/locale/ru/LC_MESSAGES/rgettext.mo +0 -0
  34. data/data/locale/sr/LC_MESSAGES/rgettext.mo +0 -0
  35. data/data/locale/sv/LC_MESSAGES/rgettext.mo +0 -0
  36. data/data/locale/ua/LC_MESSAGES/rgettext.mo +0 -0
  37. data/data/locale/vi/LC_MESSAGES/rgettext.mo +0 -0
  38. data/data/locale/zh/LC_MESSAGES/rgettext.mo +0 -0
  39. data/data/locale/zh_TW/LC_MESSAGES/rgettext.mo +0 -0
  40. data/lib/gettext.rb +4 -6
  41. data/lib/gettext/cgi.rb +1 -3
  42. data/lib/gettext/core_ext/iconv.rb +2 -4
  43. data/lib/gettext/core_ext/string.rb +3 -3
  44. data/lib/gettext/parser/erb.rb +2 -53
  45. data/lib/gettext/parser/glade.rb +2 -99
  46. data/lib/gettext/parser/ruby.rb +7 -5
  47. data/lib/gettext/{class_info.rb → runtime/class_info.rb} +2 -1
  48. data/lib/gettext/{locale_path.rb → runtime/locale_path.rb} +1 -2
  49. data/lib/gettext/{mofile.rb → runtime/mofile.rb} +0 -0
  50. data/lib/gettext/{textdomain.rb → runtime/textdomain.rb} +3 -5
  51. data/lib/gettext/{textdomain_group.rb → runtime/textdomain_group.rb} +1 -1
  52. data/lib/gettext/{textdomain_manager.rb → runtime/textdomain_manager.rb} +11 -5
  53. data/lib/gettext/tools.rb +2 -2
  54. data/lib/gettext/tools/parser/erb.rb +52 -0
  55. data/lib/gettext/tools/parser/glade.rb +98 -0
  56. data/lib/gettext/tools/parser/ruby.rb +226 -0
  57. data/lib/gettext/tools/pomessage.rb +197 -0
  58. data/lib/gettext/{poparser.rb → tools/poparser.rb} +128 -122
  59. data/lib/gettext/tools/rgettext.rb +47 -92
  60. data/lib/gettext/tools/rmsgfmt.rb +2 -2
  61. data/lib/gettext/tools/rmsgmerge.rb +2 -2
  62. data/lib/gettext/utils.rb +1 -1
  63. data/lib/gettext/version.rb +2 -2
  64. data/po/bg/rgettext.po +68 -64
  65. data/po/bs/rgettext.po +69 -65
  66. data/po/ca/rgettext.po +67 -64
  67. data/po/cs/rgettext.po +73 -70
  68. data/po/de/rgettext.po +69 -65
  69. data/po/el/rgettext.po +67 -64
  70. data/po/eo/rgettext.po +67 -63
  71. data/po/es/rgettext.po +67 -63
  72. data/po/et/rgettext.po +66 -63
  73. data/po/fr/rgettext.po +69 -66
  74. data/po/hr/rgettext.po +77 -73
  75. data/po/hu/rgettext.po +68 -65
  76. data/po/it/rgettext.po +69 -65
  77. data/po/ja/rgettext.po +69 -65
  78. data/po/ko/rgettext.po +73 -70
  79. data/po/lv/rgettext.po +68 -65
  80. data/po/nb/rgettext.po +68 -65
  81. data/po/nl/rgettext.po +74 -70
  82. data/po/pt_BR/rgettext.po +69 -66
  83. data/po/rgettext.pot +52 -48
  84. data/po/ru/rgettext.po +69 -66
  85. data/po/sr/rgettext.po +68 -64
  86. data/po/sv/rgettext.po +59 -55
  87. data/po/ua/rgettext.po +69 -66
  88. data/po/vi/rgettext.po +67 -63
  89. data/po/zh/rgettext.po +65 -62
  90. data/po/zh_TW/rgettext.po +65 -62
  91. data/replace.rb +8 -0
  92. data/samples/cgi/hellolib.rb +1 -3
  93. data/samples/cgi/http.rb +2 -4
  94. data/samples/cgi/locale/bg/LC_MESSAGES/main.mo +0 -0
  95. data/samples/cgi/po/bg/#main.po# +84 -0
  96. data/samples/cgi/po/bg/main.po +1 -1
  97. data/samples/hello.rb +1 -1
  98. data/src/poparser.ry +2 -1
  99. data/test.rb +33 -0
  100. data/test/test_class_info.rb +1 -1
  101. data/test/test_gettext.rb +1 -0
  102. data/test/test_parser.rb +120 -75
  103. data/test/test_po_generation.rb +20 -0
  104. data/test/test_pomessage.rb +99 -0
  105. data/test/test_string.rb +8 -0
  106. data/test/testlib/gettext.rb +17 -0
  107. data/test/testlib/ngettext.rb +6 -1
  108. data/test/testlib/pgettext.rb +5 -0
  109. metadata +726 -985
data/COPYING CHANGED
@@ -1,5 +1,6 @@
1
- You can redistribute this program and/or modify it under either the terms of
2
- the LGPL (see the file LGPL), or the conditions below:
1
+ Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
2
+ You can redistribute it and/or modify it under either the terms of the GPL
3
+ version 2 (see the file GPL), or the conditions below:
3
4
 
4
5
  1. You may make and give away verbatim copies of the source form of the
5
6
  software without restriction, provided that you duplicate all of the
@@ -16,22 +17,22 @@ the LGPL (see the file LGPL), or the conditions below:
16
17
  b) use the modified software only within your corporation or
17
18
  organization.
18
19
 
19
- c) rename any non-standard executables so the names do not conflict
20
- with standard executables, which must also be provided.
20
+ c) give non-standard binaries non-standard names, with
21
+ instructions on where to get the original software distribution.
21
22
 
22
23
  d) make other distribution arrangements with the author.
23
24
 
24
- 3. You may distribute the software in object code or executable
25
- form, provided that you do at least ONE of the following:
25
+ 3. You may distribute the software in object code or binary form,
26
+ provided that you do at least ONE of the following:
26
27
 
27
- a) distribute the executables and library files of the software,
28
+ a) distribute the binaries and library files of the software,
28
29
  together with instructions (in the manual page or equivalent)
29
30
  on where to get the original distribution.
30
31
 
31
32
  b) accompany the distribution with the machine-readable source of
32
33
  the software.
33
34
 
34
- c) give non-standard executables non-standard names, with
35
+ c) give non-standard binaries non-standard names, with
35
36
  instructions on where to get the original software distribution.
36
37
 
37
38
  d) make other distribution arrangements with the author.
data/ChangeLog CHANGED
@@ -1,3 +1,24 @@
1
+ = Ruby-GetText-Package-2.1.0 (2009-11-11)
2
+ * Implemented parsing of translator comments (GNU gettext feature)
3
+ [by Vladimir Dobriakov]
4
+ * Refactor the directory structure.
5
+ * Move files for runtime to lib/gettext/runtime/*.
6
+ * Move files for development(rgettext/rmsgfmt) to
7
+ lib/gettext/tools/*.
8
+ * Refactor parsers for po. po-message object is defined as GetText::PoMessage
9
+ class. [by Vladimir Dobriakov, Masao Mutoh]
10
+ * Speed up when lots of objects are created to share the textdomain in each
11
+ objects. [Reported by Gaël Séchaud.]
12
+ * Fix "%{foo.bar}" %{"foo.bar".to_sym => "a"} doesn't work.
13
+ [Bug#26663, Reported by Danilo Castilho]
14
+ * lib/gettext.rb: Fixed to work unless gem. [Reported by Vladimir Dobriakov]
15
+ * Fixed a wrong String literal in a CGI sample.
16
+ [Bug #26531, by Eugene Mikhailov]
17
+ * Update license information(explicit to use ruby's or LGPL).
18
+ [Pointed out by Masateru Yoshikawa]
19
+ * Code cleanup.
20
+ * Update minor version.
21
+
1
22
  = Ruby-GetText-Package-2.0.4 (2009-05-23)
2
23
  * Fix String#% return nil when the string have no place holders. [by okkez]
3
24
  * Update pofiles and remove old messages.
@@ -65,14 +65,8 @@ Rails / ActiveRecord specific code now lives in locale_rails[http://github.com/m
65
65
  gem uninstall gettext
66
66
 
67
67
  * gem
68
- #from github (edge/unstable)
68
+ #from rubyforge
69
69
  (sudo/su on POSIX system)
70
- gem install locale
71
- gem install mutoh-gettext -s http://gems.github.com/
72
-
73
- #from rubyforge (stable)
74
- (sudo/su on POSIX system)
75
- gem install locale
76
70
  gem install gettext
77
71
 
78
72
  * download tar-ball
@@ -150,8 +144,8 @@ For more details and options, have a look at the samples folder or
150
144
  consult the tutorial[http://www.yotabanana.com/hiki/ruby-gettext-howto.html].
151
145
 
152
146
  == License
153
- This program is licenced under the same licence as Ruby.
154
- (See the file 'COPYING'.)
147
+ This program is licenced under the same licence as Ruby(See COPYING) or
148
+ LGPL(Lesser General Public License: http://www.gnu.org/licenses/lgpl-3.0.txt).
155
149
 
156
150
  * mofile.rb
157
151
  * Copyright (C) 2001-2009 Masao Mutoh <mutoh at highwhay.ne.jp>
@@ -227,21 +221,21 @@ This program is licenced under the same licence as Ruby.
227
221
  * Chinese(zh_TW) - 2.0.1
228
222
  * Czech(cs) - 1.9.0 (old)
229
223
  * Dutch(nl) - 1.90.0 (old)
230
- * English(default) - 1.90.0 (old)
224
+ * English(default) - 2.1.0
231
225
  * Esperanto(eo) - 2.0.1
232
226
  * Estonian(et) - 2.0.1
233
- * French(fr) - 2.0.1
227
+ * French(fr) - 2.0.1
234
228
  * German(de) - 2.0.1
235
229
  * Greek(el) - 2.0.1
236
230
  * Hungarian(hu) - 2.0.1
237
231
  * Italian(it) - 1.6.0 (old)
238
- * Japanese(ja) - 2.0.1
232
+ * Japanese(ja) - 2.1.0
239
233
  * Korean(ko) - 1.9.0 (old)
240
234
  * Latvian(lv) - 2.0.1
241
235
  * Norwegian(nb) - 2.0.1
242
236
  * Portuguese(Brazil)(pt_BR) - 2.0.1
243
237
  * Russian(ru) - 2.0.1
244
- * Serbian(sr) - 1.91.0 (old)
238
+ * Serbian(sr) - 2.0.1
245
239
  * Spanish(es) - 2.0.1
246
240
  * Swedish(sv) - 0.8.0 (too much old)
247
241
  * Ukrainian(ua) - 2.0.1
data/Rakefile CHANGED
@@ -25,9 +25,9 @@ PKG_VERSION = GetText::VERSION
25
25
  ############################################################
26
26
  # GetText tasks for developing
27
27
  ############################################################
28
- desc "Create lib/gettext/poparser.rb"
28
+ desc "Create lib/gettext/tools/poparser.rb"
29
29
  task :poparser do
30
- poparser_path = "lib/gettext/poparser.rb"
30
+ poparser_path = "lib/gettext/tools/poparser.rb"
31
31
  racc = File.join(Config::CONFIG['bindir'], "racc")
32
32
  if ! FileTest.exist?(racc)
33
33
  puts "racc was not found: #{racc}"
@@ -81,10 +81,10 @@ desc "Update pot/po files to match new version."
81
81
  task :updatepo do
82
82
  begin
83
83
  require 'gettext'
84
- require 'gettext/poparser'
84
+ require 'gettext/tools/poparser'
85
85
  require 'gettext/tools'
86
86
  rescue LoadError
87
- puts "gettext/poparser was not found."
87
+ puts "gettext/tools/poparser was not found."
88
88
  end
89
89
 
90
90
  #lib/gettext/*.rb -> rgettext.po
@@ -166,7 +166,7 @@ spec = Gem::Specification.new do |s|
166
166
  s.require_path = 'lib'
167
167
  s.executables = Dir.entries('bin').delete_if {|item| /^\.|CVS|~$/ =~ item }
168
168
  s.bindir = 'bin'
169
- s.add_dependency('locale', '>= 2.0.4')
169
+ s.add_dependency('locale', '>= 2.0.5')
170
170
  s.has_rdoc = true
171
171
  s.description = <<-EOF
172
172
  Ruby-GetText-Package is a GNU GetText-like program for Ruby.
@@ -187,6 +187,8 @@ Rake::GemPackageTask.new(spec) do |p|
187
187
  p.need_zip = false
188
188
  end
189
189
 
190
+ task :package => [:makemo]
191
+
190
192
  ############################################################
191
193
  # Misc tasks
192
194
  ############################################################
@@ -0,0 +1,8 @@
1
+ "1.93.0"
2
+ user system total real
3
+ bindtextdomain 2.580000 0.620000 3.200000 ( 3.237802)
4
+ set_locale 18.920000 2.540000 21.460000 ( 21.950700)
5
+ gettext ja 1.870000 0.780000 2.650000 ( 2.696046)
6
+ gettext en (not found) 1.830000 0.820000 2.650000 ( 2.697443)
7
+ ngettext ja 4.260000 1.280000 5.540000 ( 5.689135)
8
+ ngettext en (not found) 5.300000 1.430000 6.730000 ( 6.889310)
@@ -0,0 +1,8 @@
1
+ "2.0.0"
2
+ user system total real
3
+ bindtextdomain 2.350000 0.490000 2.840000 ( 2.837863)
4
+ set_locale 2.700000 0.630000 3.330000 ( 3.330341)
5
+ gettext ja 74.160000 8.680000 82.840000 ( 82.886468)
6
+ gettext en (not found) 62.030000 8.910000 70.940000 ( 70.976801)
7
+ ngettext ja 75.610000 8.660000 84.270000 ( 84.316501)
8
+ ngettext en (not found) 68.940000 9.630000 78.570000 ( 78.630459)
@@ -0,0 +1,11 @@
1
+ "2.0.4"
2
+ user system total real
3
+ bindtextdomain 1.960000 0.440000 2.400000 ( 2.439888)
4
+ set_locale 5.970000 2.070000 8.040000 ( 8.050040)
5
+ gettext ja 1.210000 0.390000 1.600000 ( 1.604350)
6
+ gettext en (not found) 1.220000 0.370000 1.590000 ( 1.593880)
7
+ ngettext ja 2.200000 0.500000 2.700000 ( 2.699904)
8
+ ngettext en (not found) 1.850000 0.450000 2.300000 ( 2.318696)
9
+ create object ja 168.840000 26.220000 195.060000 (195.235649)
10
+ create object en 222.410000 32.830000 255.240000 (255.385031)
11
+ 190140K
@@ -0,0 +1,11 @@
1
+ "2.1.0"
2
+ user system total real
3
+ bindtextdomain 1.320000 0.000000 1.320000 ( 1.348555)
4
+ set_locale 3.990000 0.000000 3.990000 ( 4.073860)
5
+ gettext ja 1.130000 0.000000 1.130000 ( 1.144062)
6
+ gettext en (not found) 1.130000 0.000000 1.130000 ( 1.141781)
7
+ ngettext ja 1.950000 0.000000 1.950000 ( 1.991278)
8
+ ngettext en (not found) 1.650000 0.000000 1.650000 ( 1.676332)
9
+ create object ja 1.210000 0.000000 1.210000 ( 1.224649)
10
+ create object en 1.220000 0.000000 1.220000 ( 1.234247)
11
+ 104K
@@ -0,0 +1,68 @@
1
+ $:.unshift "../../locale/lib"
2
+ $:.unshift "../../gettext/lib"
3
+
4
+ #require 'rubygems'
5
+ require 'benchmark'
6
+ require 'gettext'
7
+
8
+ num = 100000
9
+
10
+ def memory
11
+ pid = Process.pid
12
+ map = `pmap -d #{pid}`
13
+ map.split("\n").last.strip.squeeze(' ').split(' ')[3].to_i
14
+ end
15
+
16
+ curr_mem = memory
17
+
18
+ class Test
19
+ include GetText
20
+ bindtextdomain("test1", :path => "../test/locale")
21
+ def test
22
+ _("language")
23
+ end
24
+ end
25
+
26
+ p GetText::VERSION
27
+ Benchmark.bm(25){|x|
28
+ x.report("bindtextdomain"){ num.times{|i|
29
+ GetText.bindtextdomain("test1", :path => "../test/locale")
30
+ #GetText.bindtextdomain("test1", "../test/locale")
31
+ } }
32
+ x.report("set_locale"){ num.times{|i|
33
+ GetText.locale = "ja"
34
+ } }
35
+ GetText.locale = "ja"
36
+ x.report("gettext ja"){ num.times{|i|
37
+ GetText._("language")
38
+ } }
39
+ GetText.locale = "en"
40
+ x.report("gettext en (not found)"){ num.times{|i|
41
+ GetText._("language")
42
+ } }
43
+
44
+ GetText.bindtextdomain("plural", :path => "../test/locale")
45
+ #GetText.bindtextdomain("plural", "../test/locale")
46
+ GetText.locale = "ja"
47
+ x.report("ngettext ja"){ (num / 2).times{|i|
48
+ GetText.n_("single", "plural", 1)
49
+ GetText.n_("single", "plural", 2)
50
+ } }
51
+ GetText.locale = "en"
52
+ x.report("ngettext en (not found)"){ (num / 2).times{|i|
53
+ GetText.n_("single", "plural", 1)
54
+ GetText.n_("single", "plural", 2)
55
+ } }
56
+
57
+ GetText.locale = "ja"
58
+ x.report("create object ja"){ num.times{|i|
59
+ Test.new.test
60
+ } }
61
+ GetText.locale = "en"
62
+ x.report("create object en"){ num.times{|i|
63
+ Test.new.test
64
+ } }
65
+ }
66
+
67
+ GC.start
68
+ puts "#{memory - curr_mem}K "
@@ -0,0 +1,28 @@
1
+ require 'benchmark'
2
+
3
+ def test(s)
4
+ ret = ""
5
+ if s =~ /^\#<|^$/ or s == "GetText"
6
+ #if s.size == 0 or s[0..1] = "#<" or s == "GetText"
7
+ ret = Object
8
+ end
9
+ ret
10
+ end
11
+
12
+ num = 100000
13
+
14
+ Benchmark.bm(25){|x|
15
+ x.report("test matched"){ num.times{|i|
16
+ test("#<foo>")
17
+ } }
18
+ x.report("test matched nodata"){ num.times{|i|
19
+ test("")
20
+ } }
21
+ x.report("test matched GetText"){ num.times{|i|
22
+ test("GetText")
23
+ } }
24
+ x.report("test not matched"){ num.times{|i|
25
+ test("FooBar")
26
+ } }
27
+
28
+ }
@@ -2,12 +2,11 @@
2
2
  =begin
3
3
  rgettext - ruby version of xgettext
4
4
 
5
- Copyright (C) 2005 Masao Mutoh
5
+ Copyright (C) 2005-2009 Masao Mutoh
6
6
 
7
7
  You may redistribute it and/or modify it under the same
8
8
  license terms as Ruby.
9
9
 
10
- $Id: rgettext,v 1.15 2008/07/24 17:17:48 mutoh Exp $
11
10
  =end
12
11
 
13
12
  begin
@@ -2,12 +2,10 @@
2
2
  =begin
3
3
  rgettext - ruby version of xgettext
4
4
 
5
- Copyright (C) 2005 Masao Mutoh
5
+ Copyright (C) 2005-2009 Masao Mutoh
6
6
 
7
7
  You may redistribute it and/or modify it under the same
8
8
  license terms as Ruby.
9
-
10
- $Id: rmsgfmt,v 1.14 2008/07/24 17:17:48 mutoh Exp $
11
9
  =end
12
10
 
13
11
  begin
@@ -6,8 +6,6 @@
6
6
 
7
7
  You may redistribute it and/or modify it under the same
8
8
  license terms as Ruby.
9
-
10
- $Id: rmsgmerge,v 1.13 2008/07/24 17:17:48 mutoh Exp $
11
9
  =end
12
10
 
13
11
  begin
@@ -8,15 +8,13 @@
8
8
  Masahiro Sakai <s01397ms@sfc.keio.ac.jp>
9
9
 
10
10
  You may redistribute it and/or modify it under the same
11
- license terms as Ruby.
12
-
13
- $Id: gettext.rb,v 1.46 2008/09/13 18:23:55 mutoh Exp $
11
+ license terms as Ruby or LGPL.
14
12
  =end
15
13
 
16
- if respond_to? :gem
14
+ if Object.constants.include? "Gem"
17
15
  begin
18
16
  begin
19
- gem 'locale', '>=2.0'
17
+ gem 'locale', '>=2.0.4'
20
18
  rescue Gem::LoadError
21
19
  end
22
20
  rescue NoMethodError
@@ -28,7 +26,7 @@ require 'locale'
28
26
  raise "Install locale as gem or uninstall old gettext" unless Locale.respond_to? :candidates
29
27
 
30
28
  require 'gettext/version'
31
- require 'gettext/textdomain_manager'
29
+ require 'gettext/runtime/textdomain_manager'
32
30
 
33
31
  module GetText
34
32
  # If the textdomain isn't bound when calling GetText.textdomain, this error is raised.
@@ -4,9 +4,7 @@
4
4
  Copyright (C) 2005-2009 Masao Mutoh
5
5
 
6
6
  You may redistribute it and/or modify it under the same
7
- license terms as Ruby.
8
-
9
- $Id$
7
+ license terms as Ruby or LGPL.
10
8
  =end
11
9
 
12
10
  require 'cgi'
@@ -8,12 +8,10 @@
8
8
  For JRuby:
9
9
  Use Java String class to convert strings.
10
10
 
11
- Copyright (C) 2004-2007 Masao Mutoh
11
+ Copyright (C) 2004-2009 Masao Mutoh
12
12
 
13
13
  You may redistribute it and/or modify it under the same
14
- license terms as Ruby.
15
-
16
- $Id: iconv.rb,v 1.6 2007/11/08 14:21:22 mutoh Exp $
14
+ license terms as Ruby or LGPL.
17
15
  =end
18
16
 
19
17
  begin