gettext 2.3.9 → 3.0.0

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.
Files changed (106) hide show
  1. data/.yardopts +1 -0
  2. data/README.rdoc +28 -23
  3. data/Rakefile +29 -21
  4. data/doc/text/news.md +57 -0
  5. data/gettext.gemspec +1 -1
  6. data/lib/gettext.rb +13 -29
  7. data/lib/gettext/cgi.rb +1 -1
  8. data/lib/gettext/{runtime/class_info.rb → class_info.rb} +1 -1
  9. data/lib/gettext/{runtime/locale_path.rb → locale_path.rb} +1 -2
  10. data/lib/gettext/{runtime/mo.rb → mo.rb} +18 -33
  11. data/lib/gettext/{tools/po.rb → po.rb} +1 -1
  12. data/lib/gettext/{tools/po_entry.rb → po_entry.rb} +8 -4
  13. data/lib/gettext/{tools/poparser.rb → po_parser.rb} +41 -44
  14. data/lib/gettext/{runtime/textdomain.rb → text_domain.rb} +6 -16
  15. data/lib/gettext/text_domain_group.rb +26 -0
  16. data/lib/gettext/{runtime/textdomain_manager.rb → text_domain_manager.rb} +40 -40
  17. data/lib/gettext/tools.rb +1 -182
  18. data/lib/gettext/tools/msgfmt.rb +1 -1
  19. data/lib/gettext/tools/msginit.rb +1 -1
  20. data/lib/gettext/tools/msgmerge.rb +2 -221
  21. data/lib/gettext/tools/parser/erb.rb +49 -30
  22. data/lib/gettext/tools/parser/glade.rb +44 -36
  23. data/lib/gettext/tools/parser/ruby.rb +126 -37
  24. data/lib/gettext/tools/task.rb +225 -0
  25. data/lib/gettext/tools/xgettext.rb +25 -28
  26. data/lib/gettext/version.rb +1 -1
  27. data/locale/bg/LC_MESSAGES/gettext.mo +0 -0
  28. data/locale/bs/LC_MESSAGES/gettext.mo +0 -0
  29. data/locale/ca/LC_MESSAGES/gettext.mo +0 -0
  30. data/locale/cs/LC_MESSAGES/gettext.mo +0 -0
  31. data/locale/de/LC_MESSAGES/gettext.mo +0 -0
  32. data/locale/el/LC_MESSAGES/gettext.mo +0 -0
  33. data/locale/eo/LC_MESSAGES/gettext.mo +0 -0
  34. data/locale/es/LC_MESSAGES/gettext.mo +0 -0
  35. data/locale/et/LC_MESSAGES/gettext.mo +0 -0
  36. data/locale/fr/LC_MESSAGES/gettext.mo +0 -0
  37. data/locale/hr/LC_MESSAGES/gettext.mo +0 -0
  38. data/locale/hu/LC_MESSAGES/gettext.mo +0 -0
  39. data/locale/it/LC_MESSAGES/gettext.mo +0 -0
  40. data/locale/ja/LC_MESSAGES/gettext.mo +0 -0
  41. data/locale/ko/LC_MESSAGES/gettext.mo +0 -0
  42. data/locale/lv/LC_MESSAGES/gettext.mo +0 -0
  43. data/locale/nb/LC_MESSAGES/gettext.mo +0 -0
  44. data/locale/nl/LC_MESSAGES/gettext.mo +0 -0
  45. data/locale/pt_BR/LC_MESSAGES/gettext.mo +0 -0
  46. data/locale/ru/LC_MESSAGES/gettext.mo +0 -0
  47. data/locale/sr/LC_MESSAGES/gettext.mo +0 -0
  48. data/locale/sv/LC_MESSAGES/gettext.mo +0 -0
  49. data/locale/uk/LC_MESSAGES/gettext.mo +0 -0
  50. data/locale/vi/LC_MESSAGES/gettext.mo +0 -0
  51. data/locale/zh/LC_MESSAGES/gettext.mo +0 -0
  52. data/locale/zh_TW/LC_MESSAGES/gettext.mo +0 -0
  53. data/po/gettext.pot +171 -97
  54. data/samples/hello.rb +3 -2
  55. data/samples/hello2.rb +2 -1
  56. data/samples/hello_gtk2.rb +4 -1
  57. data/samples/hello_gtk_builder.rb +32 -0
  58. data/samples/hello_gtk_builder.ui +46 -0
  59. data/samples/hello_noop.rb +2 -1
  60. data/samples/hello_plural.rb +2 -1
  61. data/samples/hello_tk.rb +2 -1
  62. data/src/{poparser.ry → po_parser.ry} +31 -35
  63. data/test/fixtures/N_.rb +1 -1
  64. data/test/fixtures/_/double_quote_in_double_quote.rb +32 -0
  65. data/test/fixtures/_/double_quote_in_single_quote.rb +32 -0
  66. data/test/fixtures/_/literal_concatenation_with_continuation_line.rb +36 -0
  67. data/test/fixtures/_/middle_new_line.rb +32 -0
  68. data/test/fixtures/_/multiple_lines_literal.rb +35 -0
  69. data/test/fixtures/_/multiple_messages_in_same_line.rb +32 -0
  70. data/test/fixtures/_/multiple_same_messages.rb +36 -0
  71. data/{lib/gettext/runtime/mofile.rb → test/fixtures/_/one_new_line.rb} +12 -6
  72. data/test/fixtures/{multi_textdomain.rb → multi_text_domain.rb} +1 -1
  73. data/test/fixtures/non_ascii.rb +1 -1
  74. data/test/fixtures/simple.rb +1 -1
  75. data/test/fixtures/untranslated.rb +1 -1
  76. data/test/gettext-test-utils.rb +1 -24
  77. data/test/po/ja/_.po +63 -13
  78. data/test/po/ja/non_ascii.po +2 -3
  79. data/test/po/ja/untranslated.po +1 -1
  80. data/test/test_class_info.rb +2 -2
  81. data/test/test_gettext.rb +11 -11
  82. data/test/test_mo.rb +2 -2
  83. data/test/test_parser.rb +93 -96
  84. data/test/test_po_entry.rb +237 -146
  85. data/test/test_po_parser.rb +107 -98
  86. data/test/test_string.rb +1 -1
  87. data/test/{test_textdomain_bind.rb → test_text_domain_bind.rb} +6 -6
  88. data/test/{test_textdomain_multi.rb → test_text_domain_multi.rb} +5 -5
  89. data/test/{test_textdomain_toplevel.rb → test_text_domain_toplevel.rb} +1 -1
  90. data/test/test_thread.rb +1 -1
  91. data/test/tools/files/simple_translation.rb +1 -1
  92. data/test/{parser → tools/parser}/test_ruby.rb +110 -14
  93. data/test/tools/test_msgmerge.rb +17 -276
  94. data/test/tools/test_po.rb +1 -1
  95. data/test/tools/test_xgettext.rb +175 -144
  96. metadata +59 -33
  97. data/lib/gettext/core_ext/iconv.rb +0 -110
  98. data/lib/gettext/core_ext/string.rb +0 -91
  99. data/lib/gettext/parser/erb.rb +0 -5
  100. data/lib/gettext/parser/glade.rb +0 -5
  101. data/lib/gettext/parser/ruby.rb +0 -172
  102. data/lib/gettext/runtime/textdomain_group.rb +0 -26
  103. data/lib/gettext/task.rb +0 -203
  104. data/lib/gettext/utils.rb +0 -39
  105. data/test/test_po_generation.rb +0 -45
  106. data/test/tools/test_tools.rb +0 -61
data/.yardopts CHANGED
@@ -1,5 +1,6 @@
1
1
  --protected
2
2
  --no-private
3
+ --markup markdown
3
4
  --output doc/reference/en
4
5
  --title "gettext API Reference"
5
6
  -
@@ -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.com/]
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.8.3 or later}[http://www.ruby-lang.org]
57
- * {Rubygems}[http://www.rubygems.org/]
58
- * {locale gem}[http://rubyforge.org/projects/locale/]
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
- * {GNU gettext 0.10.35 or later}[http://www.gnu.org/software/gettext/gettext.html]
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
- poparser_rb_path = "lib/gettext/tools/poparser.rb"
44
- desc "Create #{poparser_rb_path}"
45
- task :poparser => poparser_rb_path
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
- poparser_ry_path = "src/poparser.ry"
52
- file poparser_rb_path => poparser_ry_path do
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-poparser")
55
- ruby(racc, "-g", poparser_ry_path, "-o", tempfile.path)
53
+ tempfile = Tempfile.new("gettext-po-parser")
54
+ ruby(racc, "-g", po_parser_ry_path, "-o", tempfile.path)
56
55
 
57
- File.open(poparser_rb_path, "w") do |poparser_rb|
58
- poparser_rb.puts(<<-EOH)
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
- # poparser.rb - Generate a .mo
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
- poparser_rb.puts(fix_racc_output_indent(tempfile.read))
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"
@@ -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.
@@ -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")
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
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/runtime/textdomain_manager'
19
+ require 'gettext/text_domain_manager'
32
20
 
33
21
  module GetText
34
- # If the textdomain isn't bound when calling GetText.textdomain, this error is raised.
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 textdomain(%{path}/%{locale}/LC_MESSAGES/%{domainname}.mo) to
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 textdomain name.
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 textdomain to a class.
57
+ # Includes GetText module and bind a text domain to a class.
70
58
  # * klass: the target ruby class.
71
- # * domainname: the textdomain name.
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 textdomain to your program.
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 textdomain name.
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 textdomain to a class.
99
- # See textdomain for more detail.
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 textdomain name.
89
+ # * domainname: the text domain name.
102
90
 
103
91
  def textdomain_to(klass, domainname) #:nodoc:
104
- domain = TextDomainManager.textdomain_pool(domainname)
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
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # -*- coding: utf-8 -*-
2
2
 
3
3
  =begin
4
4
  gettext/cgi.rb - GetText for CGI
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # -*- coding: utf-8 -*-
2
2
 
3
3
  require 'locale/util/memoizable'
4
4
 
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # -*- coding: utf-8 -*-
2
2
 
3
3
  =begin
4
4
  locale_path.rb - GetText::LocalePath
@@ -11,7 +11,6 @@
11
11
  =end
12
12
 
13
13
  require 'rbconfig'
14
- require 'gettext/core_ext/string'
15
14
 
16
15
  module GetText
17
16
  # Treats locale-path for mo-files.