gettext 2.3.9 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +1 -0
- data/README.rdoc +28 -23
- data/Rakefile +29 -21
- data/doc/text/news.md +57 -0
- data/gettext.gemspec +1 -1
- data/lib/gettext.rb +13 -29
- data/lib/gettext/cgi.rb +1 -1
- data/lib/gettext/{runtime/class_info.rb → class_info.rb} +1 -1
- data/lib/gettext/{runtime/locale_path.rb → locale_path.rb} +1 -2
- data/lib/gettext/{runtime/mo.rb → mo.rb} +18 -33
- data/lib/gettext/{tools/po.rb → po.rb} +1 -1
- data/lib/gettext/{tools/po_entry.rb → po_entry.rb} +8 -4
- data/lib/gettext/{tools/poparser.rb → po_parser.rb} +41 -44
- data/lib/gettext/{runtime/textdomain.rb → text_domain.rb} +6 -16
- data/lib/gettext/text_domain_group.rb +26 -0
- data/lib/gettext/{runtime/textdomain_manager.rb → text_domain_manager.rb} +40 -40
- data/lib/gettext/tools.rb +1 -182
- data/lib/gettext/tools/msgfmt.rb +1 -1
- data/lib/gettext/tools/msginit.rb +1 -1
- data/lib/gettext/tools/msgmerge.rb +2 -221
- data/lib/gettext/tools/parser/erb.rb +49 -30
- data/lib/gettext/tools/parser/glade.rb +44 -36
- data/lib/gettext/tools/parser/ruby.rb +126 -37
- data/lib/gettext/tools/task.rb +225 -0
- data/lib/gettext/tools/xgettext.rb +25 -28
- data/lib/gettext/version.rb +1 -1
- data/locale/bg/LC_MESSAGES/gettext.mo +0 -0
- data/locale/bs/LC_MESSAGES/gettext.mo +0 -0
- data/locale/ca/LC_MESSAGES/gettext.mo +0 -0
- data/locale/cs/LC_MESSAGES/gettext.mo +0 -0
- data/locale/de/LC_MESSAGES/gettext.mo +0 -0
- data/locale/el/LC_MESSAGES/gettext.mo +0 -0
- data/locale/eo/LC_MESSAGES/gettext.mo +0 -0
- data/locale/es/LC_MESSAGES/gettext.mo +0 -0
- data/locale/et/LC_MESSAGES/gettext.mo +0 -0
- data/locale/fr/LC_MESSAGES/gettext.mo +0 -0
- data/locale/hr/LC_MESSAGES/gettext.mo +0 -0
- data/locale/hu/LC_MESSAGES/gettext.mo +0 -0
- data/locale/it/LC_MESSAGES/gettext.mo +0 -0
- data/locale/ja/LC_MESSAGES/gettext.mo +0 -0
- data/locale/ko/LC_MESSAGES/gettext.mo +0 -0
- data/locale/lv/LC_MESSAGES/gettext.mo +0 -0
- data/locale/nb/LC_MESSAGES/gettext.mo +0 -0
- data/locale/nl/LC_MESSAGES/gettext.mo +0 -0
- data/locale/pt_BR/LC_MESSAGES/gettext.mo +0 -0
- data/locale/ru/LC_MESSAGES/gettext.mo +0 -0
- data/locale/sr/LC_MESSAGES/gettext.mo +0 -0
- data/locale/sv/LC_MESSAGES/gettext.mo +0 -0
- data/locale/uk/LC_MESSAGES/gettext.mo +0 -0
- data/locale/vi/LC_MESSAGES/gettext.mo +0 -0
- data/locale/zh/LC_MESSAGES/gettext.mo +0 -0
- data/locale/zh_TW/LC_MESSAGES/gettext.mo +0 -0
- data/po/gettext.pot +171 -97
- data/samples/hello.rb +3 -2
- data/samples/hello2.rb +2 -1
- data/samples/hello_gtk2.rb +4 -1
- data/samples/hello_gtk_builder.rb +32 -0
- data/samples/hello_gtk_builder.ui +46 -0
- data/samples/hello_noop.rb +2 -1
- data/samples/hello_plural.rb +2 -1
- data/samples/hello_tk.rb +2 -1
- data/src/{poparser.ry → po_parser.ry} +31 -35
- data/test/fixtures/N_.rb +1 -1
- data/test/fixtures/_/double_quote_in_double_quote.rb +32 -0
- data/test/fixtures/_/double_quote_in_single_quote.rb +32 -0
- data/test/fixtures/_/literal_concatenation_with_continuation_line.rb +36 -0
- data/test/fixtures/_/middle_new_line.rb +32 -0
- data/test/fixtures/_/multiple_lines_literal.rb +35 -0
- data/test/fixtures/_/multiple_messages_in_same_line.rb +32 -0
- data/test/fixtures/_/multiple_same_messages.rb +36 -0
- data/{lib/gettext/runtime/mofile.rb → test/fixtures/_/one_new_line.rb} +12 -6
- data/test/fixtures/{multi_textdomain.rb → multi_text_domain.rb} +1 -1
- data/test/fixtures/non_ascii.rb +1 -1
- data/test/fixtures/simple.rb +1 -1
- data/test/fixtures/untranslated.rb +1 -1
- data/test/gettext-test-utils.rb +1 -24
- data/test/po/ja/_.po +63 -13
- data/test/po/ja/non_ascii.po +2 -3
- data/test/po/ja/untranslated.po +1 -1
- data/test/test_class_info.rb +2 -2
- data/test/test_gettext.rb +11 -11
- data/test/test_mo.rb +2 -2
- data/test/test_parser.rb +93 -96
- data/test/test_po_entry.rb +237 -146
- data/test/test_po_parser.rb +107 -98
- data/test/test_string.rb +1 -1
- data/test/{test_textdomain_bind.rb → test_text_domain_bind.rb} +6 -6
- data/test/{test_textdomain_multi.rb → test_text_domain_multi.rb} +5 -5
- data/test/{test_textdomain_toplevel.rb → test_text_domain_toplevel.rb} +1 -1
- data/test/test_thread.rb +1 -1
- data/test/tools/files/simple_translation.rb +1 -1
- data/test/{parser → tools/parser}/test_ruby.rb +110 -14
- data/test/tools/test_msgmerge.rb +17 -276
- data/test/tools/test_po.rb +1 -1
- data/test/tools/test_xgettext.rb +175 -144
- metadata +59 -33
- data/lib/gettext/core_ext/iconv.rb +0 -110
- data/lib/gettext/core_ext/string.rb +0 -91
- data/lib/gettext/parser/erb.rb +0 -5
- data/lib/gettext/parser/glade.rb +0 -5
- data/lib/gettext/parser/ruby.rb +0 -172
- data/lib/gettext/runtime/textdomain_group.rb +0 -26
- data/lib/gettext/task.rb +0 -203
- data/lib/gettext/utils.rb +0 -39
- data/test/test_po_generation.rb +0 -45
- data/test/tools/test_tools.rb +0 -61
data/.yardopts
CHANGED
data/README.rdoc
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
= gettext - gettext for Ruby
|
2
2
|
|
3
|
+
NOTE: Gettext gem 3.0.0 removed many deprecated APIs and improves
|
4
|
+
internal APIs. We want to keep backward compatibility as much as
|
5
|
+
possible but some existing codes may be broken by gettext gem API
|
6
|
+
change. If your code breaks by gettext gem 3.0.0, please report your
|
7
|
+
problem. We will fix the problem and release a new version.
|
8
|
+
|
9
|
+
https://github.com/ruby-gettext/gettext is the official gettext gem
|
10
|
+
repository. It is moved from https://github.com/mutoh/gettext . Mutoh
|
11
|
+
agreed with the move.
|
12
|
+
|
3
13
|
Gettext gem is a pure Ruby Localization(L10n) library and tool
|
4
14
|
which is modeled after the GNU gettext package.
|
5
15
|
|
@@ -7,30 +17,29 @@ This library was called as "Ruby-GetText-Package". Since 2.3.0, this
|
|
7
17
|
library is called just "gettext". You can call this library as
|
8
18
|
"gettext gem" or "Ruby gettext" to distinguish from GNU gettext.
|
9
19
|
|
10
|
-
This library translates original messages to localized
|
11
|
-
messages using client-side locale information(environment
|
20
|
+
This library translates original messages to localized
|
21
|
+
messages using client-side locale information(environment
|
12
22
|
variable or CGI variable).
|
13
23
|
|
14
|
-
The tools for developers support creating, useing, and modifying
|
24
|
+
The tools for developers support creating, useing, and modifying
|
15
25
|
localized message files(message catalogs).
|
16
26
|
|
17
27
|
((*Rails*))
|
18
|
-
Rails support has been removed.
|
19
|
-
Rails / ActiveRecord specific code now lives in locale_rails[http://github.com/mutoh/locale_rails/tree/master], gettext_rails[http://github.com/mutoh/gettext_rails/tree/master] and gettext_activerecord[http://github.com/mutoh/gettext_activerecord/tree/master].
|
28
|
+
Rails support has been removed.
|
20
29
|
|
21
30
|
== Website
|
22
|
-
* homepage[http://ruby-gettext.github.
|
31
|
+
* homepage[http://ruby-gettext.github.io/]
|
23
32
|
* on github[http://github.com/ruby-gettext/gettext]
|
24
33
|
|
25
34
|
== Features
|
26
35
|
* Translate singular/plural messages with simple APIs(similar to GNU gettext)
|
27
36
|
|
28
|
-
* Thread safety. Message resources are shared from all threads, but
|
37
|
+
* Thread safety. Message resources are shared from all threads, but
|
29
38
|
returns translated messages of the current thread's locale.
|
30
39
|
|
31
40
|
* Tools to find message IDs
|
32
41
|
* Extract message IDs to po-files using rxgettext from
|
33
|
-
* ruby scripts
|
42
|
+
* ruby scripts
|
34
43
|
* glade-2 XML file(.glade)
|
35
44
|
* ERB file(.rhtml, .erb)
|
36
45
|
* Anything (with your own parsers)
|
@@ -49,17 +58,13 @@ Rails / ActiveRecord specific code now lives in locale_rails[http://github.com/m
|
|
49
58
|
* Locale is retrieved from client informations using Ruby-Locale.
|
50
59
|
(HTTP_ACCEPT_LANGUAGE, HTTP_ACCEPT_CHARSET, QUERY_STRING(lang), Cookies(lang)).
|
51
60
|
|
52
|
-
* String%() is extended to use named argument such as <tt>%{foo}" %{:foo => 1}</tt>.
|
53
|
-
Notes that Ruby-1.9.x supports this format by itself.
|
54
|
-
|
55
61
|
== Requirements
|
56
|
-
* {Ruby 1.
|
57
|
-
* {
|
58
|
-
* {locale gem}[http://
|
62
|
+
* {Ruby 1.9.3 or later}[http://www.ruby-lang.org]
|
63
|
+
* {RubyGems}[http://www.rubygems.org/]
|
64
|
+
* {locale gem}[http://ruby-gettext.github.io/]
|
59
65
|
* $ gem install locale
|
60
66
|
* (for development only)
|
61
|
-
* {
|
62
|
-
* {Racc-1.4.3 or later}[http://www.ruby-lang.org/raa/list.rhtml?name=racc]
|
67
|
+
* {Racc-1.4.3 or later}[http://rubygems.org/gems/racc]
|
63
68
|
* (for compiling src/rmsgfmt.ry only)
|
64
69
|
|
65
70
|
== Install
|
@@ -68,7 +73,7 @@ Rails / ActiveRecord specific code now lives in locale_rails[http://github.com/m
|
|
68
73
|
gem uninstall gettext
|
69
74
|
|
70
75
|
* gem
|
71
|
-
#from rubyforge
|
76
|
+
#from rubyforge
|
72
77
|
(sudo/su on POSIX system)
|
73
78
|
gem install gettext
|
74
79
|
|
@@ -77,7 +82,7 @@ Rails / ActiveRecord specific code now lives in locale_rails[http://github.com/m
|
|
77
82
|
(sudo/su on POSIX system)
|
78
83
|
ruby setup.rb
|
79
84
|
|
80
|
-
You can also install files in your favorite directory by
|
85
|
+
You can also install files in your favorite directory by
|
81
86
|
supplying setup.rb some options. Try <tt>ruby setup.rb --help</tt>.
|
82
87
|
|
83
88
|
== Usage
|
@@ -121,7 +126,7 @@ The gettext methods comes in 3 combinable flavors
|
|
121
126
|
|
122
127
|
=== Bind textdomains to the classes.
|
123
128
|
A textdomain has a translation file in each language.
|
124
|
-
A module/class can have multi textdomains. This means the
|
129
|
+
A module/class can have multi textdomains. This means the
|
125
130
|
libraries/applications can have their own textdomains.
|
126
131
|
|
127
132
|
class Foo
|
@@ -199,7 +204,7 @@ LGPL(Lesser General Public License: doc/text/lgpl-3.0.txt or http://www.gnu.org/
|
|
199
204
|
* Korean(ko) - Gyoung-Yoon Noh <nohmad at gmail.com>
|
200
205
|
* Latvian(lv) - Aivars Akots <aivars.akots at gmail.com>
|
201
206
|
* Norwegian(nb) - Runar Ingebrigtsen <runar at mopo.no>
|
202
|
-
* Portuguese(Brazil)(pt_BR)
|
207
|
+
* Portuguese(Brazil)(pt_BR)
|
203
208
|
* Antonio S. de A. Terceiro <terceiro at softwarelivre.org> (current)
|
204
209
|
* Joao Pedrosa <joaopedrosa at gmail.com>
|
205
210
|
* Russian(ru) - Yuri Kozlov <kozlov.y at gmail.com>
|
@@ -223,14 +228,14 @@ LGPL(Lesser General Public License: doc/text/lgpl-3.0.txt or http://www.gnu.org/
|
|
223
228
|
* English(default) - 2.1.0
|
224
229
|
* Esperanto(eo) - 2.0.1
|
225
230
|
* Estonian(et) - 2.0.1
|
226
|
-
* French(fr) - 2.0.1
|
231
|
+
* French(fr) - 2.0.1
|
227
232
|
* German(de) - 2.0.1
|
228
|
-
* Greek(el) - 2.0.1
|
233
|
+
* Greek(el) - 2.0.1
|
229
234
|
* Hungarian(hu) - 2.0.1
|
230
235
|
* Italian(it) - 1.6.0 (old)
|
231
236
|
* Japanese(ja) - 2.1.0
|
232
237
|
* Korean(ko) - 1.9.0 (old)
|
233
|
-
* Latvian(lv) - 2.0.1
|
238
|
+
* Latvian(lv) - 2.0.1
|
234
239
|
* Norwegian(nb) - 2.0.1
|
235
240
|
* Portuguese(Brazil)(pt_BR) - 2.0.1
|
236
241
|
* Russian(ru) - 2.0.1
|
data/Rakefile
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
# You don't need to use this file directly.
|
9
9
|
#
|
10
10
|
# Copyright(c) 2005-2009 Masao Mutoh
|
11
|
-
# Copyright(c) 2012 Kouhei Sutou <kou@clear-code.com>
|
11
|
+
# Copyright(c) 2012-2013 Kouhei Sutou <kou@clear-code.com>
|
12
12
|
# Copyright(c) 2012 Haruka Yoshihara <yoshihara@clear-code.com>
|
13
13
|
# This program is licenced under the same licence as Ruby.
|
14
14
|
|
@@ -20,8 +20,7 @@ require "rake"
|
|
20
20
|
require "rubygems"
|
21
21
|
require "yard"
|
22
22
|
require "gettext/version"
|
23
|
-
require "gettext/tools"
|
24
|
-
require "gettext/task"
|
23
|
+
require "gettext/tools/task"
|
25
24
|
require "bundler/gem_helper"
|
26
25
|
|
27
26
|
class Bundler::GemHelper
|
@@ -40,25 +39,25 @@ task :default => :test
|
|
40
39
|
############################################################
|
41
40
|
# GetText tasks for developing
|
42
41
|
############################################################
|
43
|
-
|
44
|
-
desc "Create #{
|
45
|
-
task :
|
42
|
+
po_parser_rb_path = "lib/gettext/po_parser.rb"
|
43
|
+
desc "Create #{po_parser_rb_path}"
|
44
|
+
task :po_parser => po_parser_rb_path
|
46
45
|
|
47
46
|
def fix_racc_output_indent(racc_output)
|
48
47
|
racc_output.gsub(/^ (end\s*\# module GetText)$/, '\1')
|
49
48
|
end
|
50
49
|
|
51
|
-
|
52
|
-
file
|
50
|
+
po_parser_ry_path = "src/po_parser.ry"
|
51
|
+
file po_parser_rb_path => po_parser_ry_path do
|
53
52
|
racc = File.join(Gem.bindir, "racc")
|
54
|
-
tempfile = Tempfile.new("gettext-
|
55
|
-
ruby(racc, "-g",
|
53
|
+
tempfile = Tempfile.new("gettext-po-parser")
|
54
|
+
ruby(racc, "-g", po_parser_ry_path, "-o", tempfile.path)
|
56
55
|
|
57
|
-
File.open(
|
58
|
-
|
56
|
+
File.open(po_parser_rb_path, "w") do |po_parser_rb|
|
57
|
+
po_parser_rb.puts(<<-EOH)
|
59
58
|
# -*- coding: utf-8 -*-
|
60
59
|
#
|
61
|
-
#
|
60
|
+
# po_parser.rb - Generate a .mo
|
62
61
|
#
|
63
62
|
# Copyright (C) 2003-2009 Masao Mutoh <mutomasa at gmail.com>
|
64
63
|
# Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
|
@@ -68,7 +67,7 @@ file poparser_rb_path => poparser_ry_path do
|
|
68
67
|
|
69
68
|
EOH
|
70
69
|
|
71
|
-
|
70
|
+
po_parser_rb.puts(fix_racc_output_indent(tempfile.read))
|
72
71
|
end
|
73
72
|
end
|
74
73
|
|
@@ -80,13 +79,18 @@ end
|
|
80
79
|
|
81
80
|
namespace :test do
|
82
81
|
desc "Prepare test environment"
|
83
|
-
task :prepare => ["test:gettext", "samples:gettext"]
|
82
|
+
task :prepare => [:po_parser, "test:gettext", "samples:gettext"]
|
83
|
+
end
|
84
|
+
|
85
|
+
xgettext_options = ["--add-comments=TRANSLATORS:"]
|
86
|
+
GetText::Tools::Task.new(spec) do |task|
|
87
|
+
task.xgettext_options.concat(xgettext_options)
|
84
88
|
end
|
85
89
|
|
86
|
-
GetText::Task.new(spec)
|
87
90
|
Dir.glob("samples/*.rb") do |target|
|
88
91
|
domain = File.basename(target, ".*")
|
89
|
-
GetText::Task.new(spec) do |task|
|
92
|
+
GetText::Tools::Task.new(spec) do |task|
|
93
|
+
task.xgettext_options.concat(xgettext_options)
|
90
94
|
task.domain = domain
|
91
95
|
task.namespace_prefix = "samples:#{domain}"
|
92
96
|
task.po_base_directory = "samples/po"
|
@@ -104,7 +108,8 @@ task "samples:gettext"
|
|
104
108
|
["helloerb2", Dir.glob("samples/cgi/helloerb2.cgi")],
|
105
109
|
["hellolib", Dir.glob("samples/cgi/hellolib.rb")],
|
106
110
|
].each do |domain, files|
|
107
|
-
GetText::Task.new(spec) do |task|
|
111
|
+
GetText::Tools::Task.new(spec) do |task|
|
112
|
+
task.xgettext_options.concat(xgettext_options)
|
108
113
|
task.domain = domain
|
109
114
|
task.namespace_prefix = "samples:cgi:#{domain}"
|
110
115
|
task.po_base_directory = "samples/cgi/po"
|
@@ -119,7 +124,8 @@ task "samples:cgi:gettext"
|
|
119
124
|
task "samples:gettext" => "samples:cgi:gettext"
|
120
125
|
|
121
126
|
["untranslated", "backslash", "non_ascii", "np_", "p_"].each do |domain|
|
122
|
-
GetText::Task.new(spec) do |task|
|
127
|
+
GetText::Tools::Task.new(spec) do |task|
|
128
|
+
task.xgettext_options.concat(xgettext_options)
|
123
129
|
task.domain = domain
|
124
130
|
task.namespace_prefix = "test:#{domain}"
|
125
131
|
task.po_base_directory = "test/po"
|
@@ -131,7 +137,8 @@ task "samples:gettext" => "samples:cgi:gettext"
|
|
131
137
|
end
|
132
138
|
|
133
139
|
["_", "s_", "ns_"].each do |domain|
|
134
|
-
GetText::Task.new(spec) do |task|
|
140
|
+
GetText::Tools::Task.new(spec) do |task|
|
141
|
+
task.xgettext_options.concat(xgettext_options)
|
135
142
|
task.domain = domain
|
136
143
|
task.namespace_prefix = "test:#{domain}"
|
137
144
|
task.po_base_directory = "test/po"
|
@@ -147,7 +154,8 @@ po_only_domains = [
|
|
147
154
|
"plural", "plural_error", "rubyparser", "test1", "test2", "test3"
|
148
155
|
]
|
149
156
|
po_only_domains.each do |domain|
|
150
|
-
GetText::Task.new(spec) do |task|
|
157
|
+
GetText::Tools::Task.new(spec) do |task|
|
158
|
+
task.xgettext_options.concat(xgettext_options)
|
151
159
|
task.domain = domain
|
152
160
|
task.namespace_prefix = "test:#{domain}"
|
153
161
|
task.po_base_directory = "test/po"
|
data/doc/text/news.md
CHANGED
@@ -1,5 +1,62 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
+
## <a id="3-0-0">3.0.0</a>: 2013-08-31
|
4
|
+
|
5
|
+
This is a new major version up release!
|
6
|
+
|
7
|
+
This release removes many deprecated APIs and improves internal
|
8
|
+
APIs. We want to keep backward compatibility as much as possible but
|
9
|
+
some existing codes may be broken by gettext gem API change. If your
|
10
|
+
code breaks by gettext gem 3.0.0, please report your problem. We will
|
11
|
+
fix the problem and release a new version.
|
12
|
+
|
13
|
+
### Improvements
|
14
|
+
|
15
|
+
* Removed deprecated APIs
|
16
|
+
* `require "gettext/parser/erb"`.
|
17
|
+
Use `require "gettext/tools/parser/erb"` instead.
|
18
|
+
* `require "gettext/parser/glade"`.
|
19
|
+
Use `require "gettext/tools/parser/glade"` instead.
|
20
|
+
* `require "gettext/parser/ruby"`.
|
21
|
+
Use `require "gettext/tools/parser/ruby"` instead.
|
22
|
+
* `require "gettext/utils"`.
|
23
|
+
Use `require "gettext/tools"` instead.
|
24
|
+
* `GetText.msgmerge`. Use `GetText::Tools::MsgMerge.run` instead.
|
25
|
+
* `GetText.create_mofiles`. Use `GetText::Tools::Task` instead.
|
26
|
+
* `GetText::PoParser`. Use `GetText::POParser` instead.
|
27
|
+
* `require "gettext/tools/poparser"`.
|
28
|
+
Use `require "gettext/po_parser"` instead.
|
29
|
+
* `require "gettext/runtime/mofile"`.
|
30
|
+
Use `require "gettext/mo"` instead.
|
31
|
+
* `GetText::MoFile`. Use `GetText::MO` instead.
|
32
|
+
* `GetText::Task`. Use `GetText::Tools::Task` instead.
|
33
|
+
* `GetText.set_locale_all`. Use `GetText.set_locale` instead.
|
34
|
+
* `GetText.setlocale`. Use `GetText.set_locale` instead.
|
35
|
+
* `GetText::Tools::MsgMerge::PoData`. Use `GetText::POEntry` instead.
|
36
|
+
* Removed Ruby 1.8 support.
|
37
|
+
* Supported Rake 10.1.0.
|
38
|
+
* Stopped to remove `TRANSLATORS:` tag because GNU gettext doesn't
|
39
|
+
remove it.
|
40
|
+
* Stopped to use `TRANSLATORS:` as comment tag. It is GNU gettext
|
41
|
+
compatible behavior.
|
42
|
+
* rxgettext: Added `--add-comments[=TAG]` option that exists in
|
43
|
+
xgettext. [GitHub #16] [Reported by Ladislav Slezák]
|
44
|
+
* Supported escaping tab character as `\t`.
|
45
|
+
|
46
|
+
### Fixes
|
47
|
+
|
48
|
+
* po: Added a missing new line for multiple extracted comments.
|
49
|
+
[GitHub #17] [Patch by Ladislav Slezák]
|
50
|
+
* Fixed a bug that encoding may not be set.
|
51
|
+
* Fixed a bug that `\n` is escaped as `\\n`.
|
52
|
+
[GitHub #18] [Debian #716916] [Reported by Ladislav Slezák]
|
53
|
+
[Reported by Francesco Poli]
|
54
|
+
|
55
|
+
### Thanks
|
56
|
+
|
57
|
+
* Ladislav Slezák
|
58
|
+
* Francesco Poli
|
59
|
+
|
3
60
|
## <a id="2-3-9">2.3.9</a>: 2013-04-21
|
4
61
|
|
5
62
|
This is a msgmerge updated release.
|
data/gettext.gemspec
CHANGED
@@ -28,7 +28,7 @@ So you can use GNU gettext tools for maintaining.
|
|
28
28
|
s.test_files = Dir.glob("test/test_*.rb")
|
29
29
|
end
|
30
30
|
|
31
|
-
s.add_runtime_dependency("locale")
|
31
|
+
s.add_runtime_dependency("locale", ">= 2.0.5")
|
32
32
|
s.add_runtime_dependency("text")
|
33
33
|
s.add_development_dependency("rake")
|
34
34
|
s.add_development_dependency("racc")
|
data/lib/gettext.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
=begin
|
4
4
|
gettext.rb - GetText module
|
@@ -13,25 +13,13 @@
|
|
13
13
|
license terms as Ruby or LGPL.
|
14
14
|
=end
|
15
15
|
|
16
|
-
if Object.constants.include? "Gem"
|
17
|
-
begin
|
18
|
-
begin
|
19
|
-
gem 'locale', '>=2.0.5'
|
20
|
-
rescue Gem::LoadError
|
21
|
-
end
|
22
|
-
rescue NoMethodError
|
23
|
-
else LoadError
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
16
|
require 'locale'
|
28
|
-
raise "Install locale as gem or uninstall old gettext" unless Locale.respond_to? :candidates
|
29
17
|
|
30
18
|
require 'gettext/version'
|
31
|
-
require 'gettext/
|
19
|
+
require 'gettext/text_domain_manager'
|
32
20
|
|
33
21
|
module GetText
|
34
|
-
# If the
|
22
|
+
# If the text domain isn't bound when calling GetText.textdomain, this error is raised.
|
35
23
|
class NoboundTextDomainError < RuntimeError
|
36
24
|
def initialize(domainname)
|
37
25
|
@domainname = domainname
|
@@ -49,12 +37,12 @@ module GetText
|
|
49
37
|
|
50
38
|
# bindtextdomain(domainname, options = {})
|
51
39
|
#
|
52
|
-
# Bind a
|
40
|
+
# Bind a text domain(%{path}/%{locale}/LC_MESSAGES/%{domainname}.mo) to
|
53
41
|
# your program.
|
54
42
|
# Normally, the texdomain scope becomes the class/module(and parent
|
55
43
|
# classes/included modules).
|
56
44
|
#
|
57
|
-
# * domainname: the
|
45
|
+
# * domainname: the text domain name.
|
58
46
|
# * options: options as an Hash.
|
59
47
|
# * :path - the path to the mo-files. When the value is nil, it will search default paths such as
|
60
48
|
# /usr/share/locale, /usr/local/share/locale)
|
@@ -66,9 +54,9 @@ module GetText
|
|
66
54
|
bindtextdomain_to(self, domainname, *options)
|
67
55
|
end
|
68
56
|
|
69
|
-
# Includes GetText module and bind a
|
57
|
+
# Includes GetText module and bind a text domain to a class.
|
70
58
|
# * klass: the target ruby class.
|
71
|
-
# * domainname: the
|
59
|
+
# * domainname: the text domain name.
|
72
60
|
# * options: options as an Hash. See GetText.bindtextdomain.
|
73
61
|
def bindtextdomain_to(klass, domainname, *options)
|
74
62
|
if options[0].kind_of? Hash
|
@@ -85,23 +73,23 @@ module GetText
|
|
85
73
|
TextDomainManager.bind_to(klass, domainname, opts)
|
86
74
|
end
|
87
75
|
|
88
|
-
# Binds a existed
|
76
|
+
# Binds a existed text domain to your program.
|
89
77
|
# This is the same function with GetText.bindtextdomain but simpler(and faster) than bindtextdomain.
|
90
78
|
# Note that you need to call GetText.bindtextdomain first. If the domainname hasn't bound yet,
|
91
79
|
# raises GetText::NoboundTextDomainError.
|
92
|
-
# * domainname: a
|
80
|
+
# * domainname: a text domain name.
|
93
81
|
# * Returns: the GetText::TextDomainManager.
|
94
82
|
def textdomain(domainname) #:nodoc:
|
95
83
|
textdomain_to(self, domainname)
|
96
84
|
end
|
97
85
|
|
98
|
-
# Includes GetText module and bind an exsited
|
99
|
-
# See
|
86
|
+
# Includes GetText module and bind an exsited text domain to a class.
|
87
|
+
# See text domain for more detail.
|
100
88
|
# * klass: the target ruby class.
|
101
|
-
# * domainname: the
|
89
|
+
# * domainname: the text domain name.
|
102
90
|
|
103
91
|
def textdomain_to(klass, domainname) #:nodoc:
|
104
|
-
domain = TextDomainManager.
|
92
|
+
domain = TextDomainManager.text_domain_pool(domainname)
|
105
93
|
raise NoboundTextDomainError.new(domainname) unless domain
|
106
94
|
bindtextdomain_to(klass, domainname)
|
107
95
|
end
|
@@ -305,8 +293,4 @@ unless defined? XX
|
|
305
293
|
# http://rubyforge.org/projects/codeforpeople/
|
306
294
|
alias :p_ :pgettext #:nodoc:
|
307
295
|
end
|
308
|
-
|
309
|
-
# for backward compatibility
|
310
|
-
alias :set_locale_all :set_locale #:nodoc:
|
311
|
-
alias :setlocale :set_locale #:nodoc:
|
312
296
|
end
|
data/lib/gettext/cgi.rb
CHANGED