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.
- 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
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gettext
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.0.0
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2013-
|
|
13
|
+
date: 2013-08-31 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: locale
|
|
@@ -19,7 +19,7 @@ dependencies:
|
|
|
19
19
|
requirements:
|
|
20
20
|
- - ! '>='
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
|
-
version:
|
|
22
|
+
version: 2.0.5
|
|
23
23
|
type: :runtime
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -27,7 +27,7 @@ dependencies:
|
|
|
27
27
|
requirements:
|
|
28
28
|
- - ! '>='
|
|
29
29
|
- !ruby/object:Gem::Version
|
|
30
|
-
version:
|
|
30
|
+
version: 2.0.5
|
|
31
31
|
- !ruby/object:Gem::Dependency
|
|
32
32
|
name: text
|
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -174,6 +174,32 @@ executables:
|
|
|
174
174
|
extensions: []
|
|
175
175
|
extra_rdoc_files: []
|
|
176
176
|
files:
|
|
177
|
+
- locale/ko/LC_MESSAGES/gettext.mo
|
|
178
|
+
- locale/nb/LC_MESSAGES/gettext.mo
|
|
179
|
+
- locale/ru/LC_MESSAGES/gettext.mo
|
|
180
|
+
- locale/hu/LC_MESSAGES/gettext.mo
|
|
181
|
+
- locale/ca/LC_MESSAGES/gettext.mo
|
|
182
|
+
- locale/fr/LC_MESSAGES/gettext.mo
|
|
183
|
+
- locale/it/LC_MESSAGES/gettext.mo
|
|
184
|
+
- locale/pt_BR/LC_MESSAGES/gettext.mo
|
|
185
|
+
- locale/es/LC_MESSAGES/gettext.mo
|
|
186
|
+
- locale/uk/LC_MESSAGES/gettext.mo
|
|
187
|
+
- locale/lv/LC_MESSAGES/gettext.mo
|
|
188
|
+
- locale/el/LC_MESSAGES/gettext.mo
|
|
189
|
+
- locale/hr/LC_MESSAGES/gettext.mo
|
|
190
|
+
- locale/bg/LC_MESSAGES/gettext.mo
|
|
191
|
+
- locale/bs/LC_MESSAGES/gettext.mo
|
|
192
|
+
- locale/eo/LC_MESSAGES/gettext.mo
|
|
193
|
+
- locale/zh_TW/LC_MESSAGES/gettext.mo
|
|
194
|
+
- locale/vi/LC_MESSAGES/gettext.mo
|
|
195
|
+
- locale/ja/LC_MESSAGES/gettext.mo
|
|
196
|
+
- locale/et/LC_MESSAGES/gettext.mo
|
|
197
|
+
- locale/sv/LC_MESSAGES/gettext.mo
|
|
198
|
+
- locale/cs/LC_MESSAGES/gettext.mo
|
|
199
|
+
- locale/sr/LC_MESSAGES/gettext.mo
|
|
200
|
+
- locale/nl/LC_MESSAGES/gettext.mo
|
|
201
|
+
- locale/zh/LC_MESSAGES/gettext.mo
|
|
202
|
+
- locale/de/LC_MESSAGES/gettext.mo
|
|
177
203
|
- bin/rmsgmerge
|
|
178
204
|
- bin/rmsgfmt
|
|
179
205
|
- bin/rxgettext
|
|
@@ -183,33 +209,26 @@ files:
|
|
|
183
209
|
- doc/text/ruby-license.txt
|
|
184
210
|
- doc/text/gpl-2.0.txt
|
|
185
211
|
- lib/gettext.rb
|
|
212
|
+
- lib/gettext/text_domain_manager.rb
|
|
186
213
|
- lib/gettext/version.rb
|
|
187
214
|
- lib/gettext/cgi.rb
|
|
188
|
-
- lib/gettext/
|
|
215
|
+
- lib/gettext/text_domain.rb
|
|
216
|
+
- lib/gettext/po_parser.rb
|
|
189
217
|
- lib/gettext/tools/msgfmt.rb
|
|
190
218
|
- lib/gettext/tools/msgmerge.rb
|
|
191
219
|
- lib/gettext/tools/msginit.rb
|
|
192
|
-
- lib/gettext/tools/po_entry.rb
|
|
193
220
|
- lib/gettext/tools/xgettext.rb
|
|
221
|
+
- lib/gettext/tools/task.rb
|
|
194
222
|
- lib/gettext/tools/parser/glade.rb
|
|
195
223
|
- lib/gettext/tools/parser/erb.rb
|
|
196
224
|
- lib/gettext/tools/parser/ruby.rb
|
|
197
|
-
- lib/gettext/
|
|
198
|
-
- lib/gettext/
|
|
199
|
-
- lib/gettext/
|
|
200
|
-
- lib/gettext/
|
|
201
|
-
- lib/gettext/
|
|
202
|
-
- lib/gettext/runtime/locale_path.rb
|
|
203
|
-
- lib/gettext/runtime/class_info.rb
|
|
204
|
-
- lib/gettext/runtime/mo.rb
|
|
205
|
-
- lib/gettext/runtime/textdomain_manager.rb
|
|
225
|
+
- lib/gettext/text_domain_group.rb
|
|
226
|
+
- lib/gettext/locale_path.rb
|
|
227
|
+
- lib/gettext/po_entry.rb
|
|
228
|
+
- lib/gettext/class_info.rb
|
|
229
|
+
- lib/gettext/mo.rb
|
|
206
230
|
- lib/gettext/tools.rb
|
|
207
|
-
- lib/gettext/
|
|
208
|
-
- lib/gettext/core_ext/string.rb
|
|
209
|
-
- lib/gettext/core_ext/iconv.rb
|
|
210
|
-
- lib/gettext/parser/glade.rb
|
|
211
|
-
- lib/gettext/parser/erb.rb
|
|
212
|
-
- lib/gettext/parser/ruby.rb
|
|
231
|
+
- lib/gettext/po.rb
|
|
213
232
|
- po/ko/gettext.po
|
|
214
233
|
- po/nb/gettext.po
|
|
215
234
|
- po/ru/gettext.po
|
|
@@ -414,6 +433,7 @@ files:
|
|
|
414
433
|
- samples/po/de/hello_plural.po
|
|
415
434
|
- samples/hello_glade2.rb
|
|
416
435
|
- samples/README
|
|
436
|
+
- samples/hello_gtk_builder.rb
|
|
417
437
|
- samples/hello_gtk2.rb
|
|
418
438
|
- samples/hello_tk.rb
|
|
419
439
|
- samples/cgi/po/ko/helloerb2.po
|
|
@@ -530,9 +550,10 @@ files:
|
|
|
530
550
|
- samples/hello_noop.rb
|
|
531
551
|
- samples/hello_plural.rb
|
|
532
552
|
- samples/hello.rb
|
|
553
|
+
- samples/hello_gtk_builder.ui
|
|
533
554
|
- samples/hello_glade2.glade
|
|
534
555
|
- samples/hello2.rb
|
|
535
|
-
- src/
|
|
556
|
+
- src/po_parser.ry
|
|
536
557
|
- test/po/sl/plural.po
|
|
537
558
|
- test/po/po/plural.po
|
|
538
559
|
- test/po/cr/plural.po
|
|
@@ -561,15 +582,16 @@ files:
|
|
|
561
582
|
- test/po/ja/s_.po
|
|
562
583
|
- test/po/ja/plural.po
|
|
563
584
|
- test/po/ja/plural_error.po
|
|
585
|
+
- test/test_text_domain_multi.rb
|
|
564
586
|
- test/test_parser.rb
|
|
565
|
-
- test/test_textdomain_toplevel.rb
|
|
566
587
|
- test/test_po_entry.rb
|
|
588
|
+
- test/test_text_domain_toplevel.rb
|
|
589
|
+
- test/test_text_domain_bind.rb
|
|
567
590
|
- test/test_po_parser.rb
|
|
568
591
|
- test/test_string.rb
|
|
569
592
|
- test/tools/test_po.rb
|
|
570
593
|
- test/tools/test_msginit.rb
|
|
571
594
|
- test/tools/test_msgmerge.rb
|
|
572
|
-
- test/tools/test_tools.rb
|
|
573
595
|
- test/tools/files/simple_2.po
|
|
574
596
|
- test/tools/files/simple_translation.rb
|
|
575
597
|
- test/tools/files/version.po
|
|
@@ -580,18 +602,25 @@ files:
|
|
|
580
602
|
- test/tools/files/de/app.po
|
|
581
603
|
- test/tools/test.pot
|
|
582
604
|
- test/tools/test_xgettext.rb
|
|
605
|
+
- test/tools/parser/test_ruby.rb
|
|
583
606
|
- test/gettext-test-utils.rb
|
|
584
607
|
- test/test_gettext.rb
|
|
585
|
-
- test/test_textdomain_bind.rb
|
|
586
608
|
- test/test_thread.rb
|
|
587
|
-
- test/test_textdomain_multi.rb
|
|
588
609
|
- test/run-test.rb
|
|
589
610
|
- test/test_locale_path.rb
|
|
590
611
|
- test/test_class_info.rb
|
|
591
612
|
- test/fixtures/ns_/custom.rb
|
|
592
613
|
- test/fixtures/s_/custom.rb
|
|
593
614
|
- test/fixtures/n_.rb
|
|
615
|
+
- test/fixtures/_/double_quote_in_double_quote.rb
|
|
616
|
+
- test/fixtures/_/multiple_same_messages.rb
|
|
617
|
+
- test/fixtures/_/double_quote_in_single_quote.rb
|
|
618
|
+
- test/fixtures/_/multiple_messages_in_same_line.rb
|
|
619
|
+
- test/fixtures/_/multiple_lines_literal.rb
|
|
620
|
+
- test/fixtures/_/literal_concatenation_with_continuation_line.rb
|
|
621
|
+
- test/fixtures/_/middle_new_line.rb
|
|
594
622
|
- test/fixtures/_/one_line.rb
|
|
623
|
+
- test/fixtures/_/one_new_line.rb
|
|
595
624
|
- test/fixtures/backslash.rb
|
|
596
625
|
- test/fixtures/s_.rb
|
|
597
626
|
- test/fixtures/erb/ascii.rhtml
|
|
@@ -603,13 +632,11 @@ files:
|
|
|
603
632
|
- test/fixtures/N_.rb
|
|
604
633
|
- test/fixtures/gladeparser.glade
|
|
605
634
|
- test/fixtures/_.rb
|
|
635
|
+
- test/fixtures/multi_text_domain.rb
|
|
606
636
|
- test/fixtures/ns_.rb
|
|
607
|
-
- test/fixtures/multi_textdomain.rb
|
|
608
637
|
- test/fixtures/p_.rb
|
|
609
638
|
- test/fixtures/non_ascii.rb
|
|
610
|
-
- test/test_po_generation.rb
|
|
611
639
|
- test/test_mo.rb
|
|
612
|
-
- test/parser/test_ruby.rb
|
|
613
640
|
- README.rdoc
|
|
614
641
|
- Rakefile
|
|
615
642
|
- gettext.gemspec
|
|
@@ -640,17 +667,16 @@ signing_key:
|
|
|
640
667
|
specification_version: 3
|
|
641
668
|
summary: Gettext is a pure Ruby libary and tools to localize messages.
|
|
642
669
|
test_files:
|
|
670
|
+
- test/test_text_domain_multi.rb
|
|
643
671
|
- test/test_parser.rb
|
|
644
|
-
- test/test_textdomain_toplevel.rb
|
|
645
672
|
- test/test_po_entry.rb
|
|
673
|
+
- test/test_text_domain_toplevel.rb
|
|
674
|
+
- test/test_text_domain_bind.rb
|
|
646
675
|
- test/test_po_parser.rb
|
|
647
676
|
- test/test_string.rb
|
|
648
677
|
- test/test_gettext.rb
|
|
649
|
-
- test/test_textdomain_bind.rb
|
|
650
678
|
- test/test_thread.rb
|
|
651
|
-
- test/test_textdomain_multi.rb
|
|
652
679
|
- test/test_locale_path.rb
|
|
653
680
|
- test/test_class_info.rb
|
|
654
|
-
- test/test_po_generation.rb
|
|
655
681
|
- test/test_mo.rb
|
|
656
682
|
has_rdoc:
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
=begin
|
|
3
|
-
iconv.rb - Pseudo Iconv class. Supports Iconv.iconv, Iconv.conv.
|
|
4
|
-
|
|
5
|
-
For Matz Ruby:
|
|
6
|
-
If you don't have iconv but glib2, this library uses glib2 iconv functions.
|
|
7
|
-
|
|
8
|
-
For JRuby:
|
|
9
|
-
Use Java String class to convert strings.
|
|
10
|
-
|
|
11
|
-
Copyright (C) 2004-2009 Masao Mutoh
|
|
12
|
-
|
|
13
|
-
You may redistribute it and/or modify it under the same
|
|
14
|
-
license terms as Ruby or LGPL.
|
|
15
|
-
=end
|
|
16
|
-
|
|
17
|
-
begin
|
|
18
|
-
require 'iconv.so'
|
|
19
|
-
rescue LoadError
|
|
20
|
-
# Pseudo Iconv class
|
|
21
|
-
#
|
|
22
|
-
# ==== For Matz Ruby:
|
|
23
|
-
# If you don't have iconv but Ruby/GLib2, this library uses Ruby/GLib2's
|
|
24
|
-
# iconv functions.
|
|
25
|
-
#
|
|
26
|
-
# Ruby/GLib is a module which is provided from Ruby-GNOME2 Project.
|
|
27
|
-
# You can get binaries for Win32(One-Click Ruby Installer).
|
|
28
|
-
# <URL: http://ruby-gnome2.sourceforge.jp/>
|
|
29
|
-
# ==== For JRuby:
|
|
30
|
-
# Use Java String class to convert strings.
|
|
31
|
-
class Iconv
|
|
32
|
-
module Failure; end
|
|
33
|
-
class InvalidEncoding < ArgumentError; include Failure; end
|
|
34
|
-
class IllegalSequence < ArgumentError; include Failure; end
|
|
35
|
-
class InvalidCharacter < ArgumentError; include Failure; end
|
|
36
|
-
|
|
37
|
-
if RUBY_PLATFORM =~ /java/
|
|
38
|
-
def self.conv(to, from, str)
|
|
39
|
-
raise InvalidCharacter, "the 3rd argument is nil" unless str
|
|
40
|
-
begin
|
|
41
|
-
str = java.lang.String.new(str.unpack("C*").to_java(:byte), from)
|
|
42
|
-
str.getBytes(to).to_ary.pack("C*")
|
|
43
|
-
rescue java.io.UnsupportedEncodingException
|
|
44
|
-
raise InvalidEncoding
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
else
|
|
48
|
-
begin
|
|
49
|
-
require 'glib2'
|
|
50
|
-
|
|
51
|
-
def self.check_glib_version?(major, minor, micro) # :nodoc:
|
|
52
|
-
(GLib::BINDING_VERSION[0] > major ||
|
|
53
|
-
(GLib::BINDING_VERSION[0] == major &&
|
|
54
|
-
GLib::BINDING_VERSION[1] > minor) ||
|
|
55
|
-
(GLib::BINDING_VERSION[0] == major &&
|
|
56
|
-
GLib::BINDING_VERSION[1] == minor &&
|
|
57
|
-
GLib::BINDING_VERSION[2] >= micro))
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
if check_glib_version?(0, 11, 0)
|
|
61
|
-
# This is a function equivalent of Iconv.iconv.
|
|
62
|
-
# * to: encoding name for destination
|
|
63
|
-
# * from: encoding name for source
|
|
64
|
-
# * str: strings to be converted
|
|
65
|
-
# * Returns: Returns an Array of converted strings.
|
|
66
|
-
def self.conv(to, from, str)
|
|
67
|
-
begin
|
|
68
|
-
GLib.convert(str, to, from)
|
|
69
|
-
rescue GLib::ConvertError => e
|
|
70
|
-
case e.code
|
|
71
|
-
when GLib::ConvertError::NO_CONVERSION
|
|
72
|
-
raise InvalidEncoding.new(str)
|
|
73
|
-
when GLib::ConvertError::ILLEGAL_SEQUENCE
|
|
74
|
-
raise IllegalSequence.new(str)
|
|
75
|
-
else
|
|
76
|
-
raise InvalidCharacter.new(str)
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
else
|
|
81
|
-
def self.conv(to, from, str) # :nodoc:
|
|
82
|
-
begin
|
|
83
|
-
GLib.convert(str, to, from)
|
|
84
|
-
rescue
|
|
85
|
-
raise IllegalSequence.new(str)
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
rescue LoadError
|
|
90
|
-
def self.conv(to, from, str) # :nodoc:
|
|
91
|
-
warn "Iconv was not found." if $DEBUG
|
|
92
|
-
str
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
def self.iconv(to, from, str)
|
|
97
|
-
conv(to, from, str).split(//)
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
if __FILE__ == $0
|
|
103
|
-
puts Iconv.iconv("EUC-JP", "UTF-8", "ほげ").join
|
|
104
|
-
begin
|
|
105
|
-
puts Iconv.iconv("EUC-JP", "EUC-JP", "ほげ").join
|
|
106
|
-
rescue Iconv::Failure
|
|
107
|
-
puts $!
|
|
108
|
-
puts $!.class
|
|
109
|
-
end
|
|
110
|
-
end
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
=begin
|
|
4
|
-
string.rb - Extension for String.
|
|
5
|
-
|
|
6
|
-
Copyright (C) 2005-2009 Masao Mutoh
|
|
7
|
-
|
|
8
|
-
You may redistribute it and/or modify it under the same
|
|
9
|
-
license terms as Ruby or LGPL.
|
|
10
|
-
=end
|
|
11
|
-
|
|
12
|
-
# Extension for String class. This feature is included in Ruby 1.9 or later but not occur TypeError.
|
|
13
|
-
#
|
|
14
|
-
# String#% method which accept "named argument". The translator can know
|
|
15
|
-
# the meaning of the msgids using "named argument" instead of %s/%d style.
|
|
16
|
-
class String
|
|
17
|
-
|
|
18
|
-
unless instance_methods.find {|m| m.to_s == 'bytesize'}
|
|
19
|
-
# For older ruby (such as ruby-1.8.5)
|
|
20
|
-
alias :bytesize :size
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
begin
|
|
24
|
-
formatted = "%{key}" % {:key => "value"}
|
|
25
|
-
raise ArgumentError if formatted != "value"
|
|
26
|
-
rescue ArgumentError
|
|
27
|
-
alias :_old_format_m :% # :nodoc:
|
|
28
|
-
|
|
29
|
-
PERCENT_MATCH_RE = Regexp.union(
|
|
30
|
-
/%%/,
|
|
31
|
-
/%\{(.+?)\}/,
|
|
32
|
-
/%<(.+?)>(.*?\d*\.?\d*[bBdiouxXeEfgGcps])/
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
# call-seq:
|
|
36
|
-
# %(arg)
|
|
37
|
-
# %(hash)
|
|
38
|
-
#
|
|
39
|
-
# Format - Uses str as a format specification, and returns the result of applying it to arg.
|
|
40
|
-
# If the format specification contains more than one substitution, then arg must be
|
|
41
|
-
# an Array containing the values to be substituted. See Kernel::sprintf for details of the
|
|
42
|
-
# format string. This is the default behavior of the String class.
|
|
43
|
-
# * arg: an Array or other class except Hash.
|
|
44
|
-
# * Returns: formatted String
|
|
45
|
-
#
|
|
46
|
-
# (e.g.) "%s, %s" % ["Masao", "Mutoh"]
|
|
47
|
-
#
|
|
48
|
-
# Also you can use a Hash as the "named argument". This is recommanded way for Ruby-GetText
|
|
49
|
-
# because the translators can understand the meanings of the msgids easily.
|
|
50
|
-
# * hash: {:key1 => value1, :key2 => value2, ... }
|
|
51
|
-
# * Returns: formatted String
|
|
52
|
-
#
|
|
53
|
-
# (e.g.)
|
|
54
|
-
# For strings.
|
|
55
|
-
# "%{firstname}, %{familyname}" % {:firstname => "Masao", :familyname => "Mutoh"}
|
|
56
|
-
#
|
|
57
|
-
# With field type to specify format such as d(decimal), f(float),...
|
|
58
|
-
# "%<age>d, %<weight>.1f" % {:age => 10, :weight => 43.4}
|
|
59
|
-
def %(args)
|
|
60
|
-
if args.kind_of?(Hash)
|
|
61
|
-
ret = dup
|
|
62
|
-
ret.gsub!(PERCENT_MATCH_RE) {|match|
|
|
63
|
-
if match == '%%'
|
|
64
|
-
'%'
|
|
65
|
-
elsif $1
|
|
66
|
-
key = $1.to_sym
|
|
67
|
-
args.has_key?(key) ? args[key] : match
|
|
68
|
-
elsif $2
|
|
69
|
-
key = $2.to_sym
|
|
70
|
-
args.has_key?(key) ? sprintf("%#{$3}", args[key]) : match
|
|
71
|
-
end
|
|
72
|
-
}
|
|
73
|
-
ret
|
|
74
|
-
else
|
|
75
|
-
ret = gsub(/%([{<])/, '%%\1')
|
|
76
|
-
begin
|
|
77
|
-
ret._old_format_m(args)
|
|
78
|
-
rescue ArgumentError => e
|
|
79
|
-
if $DEBUG
|
|
80
|
-
$stderr.puts " The string:#{ret}"
|
|
81
|
-
$stderr.puts " args:#{args.inspect}"
|
|
82
|
-
puts e.backtrace
|
|
83
|
-
else
|
|
84
|
-
raise ArgumentError, e.message
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
|
data/lib/gettext/parser/erb.rb
DELETED
data/lib/gettext/parser/glade.rb
DELETED
data/lib/gettext/parser/ruby.rb
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/ruby
|
|
2
|
-
=begin
|
|
3
|
-
parser/ruby.rb - parser for ruby script
|
|
4
|
-
|
|
5
|
-
Copyright (C) 2003-2005 Masao Mutoh
|
|
6
|
-
Copyright (C) 2005 speakillof
|
|
7
|
-
Copyright (C) 2001,2002 Yasushi Shoji, Masao Mutoh
|
|
8
|
-
|
|
9
|
-
You may redistribute it and/or modify it under the same
|
|
10
|
-
license terms as Ruby.
|
|
11
|
-
|
|
12
|
-
=end
|
|
13
|
-
|
|
14
|
-
require 'irb/ruby-lex.rb'
|
|
15
|
-
require 'stringio'
|
|
16
|
-
warn "DEPRECATED: Use 'gettext/tools/parser/ruby' instead."
|
|
17
|
-
|
|
18
|
-
class RubyLexX < RubyLex # :nodoc: all
|
|
19
|
-
# Parser#parse resemlbes RubyLex#lex
|
|
20
|
-
def parse
|
|
21
|
-
until ( (tk = token).kind_of?(RubyToken::TkEND_OF_SCRIPT) && !@continue or tk.nil? )
|
|
22
|
-
s = get_readed
|
|
23
|
-
if RubyToken::TkSTRING === tk
|
|
24
|
-
def tk.value
|
|
25
|
-
@value
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def tk.value=(s)
|
|
29
|
-
@value = s
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
if @here_header
|
|
33
|
-
s = s.sub(/\A.*?\n/, '').sub(/^.*\n\Z/, '')
|
|
34
|
-
else
|
|
35
|
-
begin
|
|
36
|
-
s = eval(s)
|
|
37
|
-
rescue Exception
|
|
38
|
-
# Do nothing.
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
tk.value = s
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
if $DEBUG
|
|
46
|
-
if tk.is_a? TkSTRING
|
|
47
|
-
$stderr.puts("#{tk}: #{tk.value}")
|
|
48
|
-
elsif tk.is_a? TkIDENTIFIER
|
|
49
|
-
$stderr.puts("#{tk}: #{tk.name}")
|
|
50
|
-
else
|
|
51
|
-
$stderr.puts(tk)
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
yield tk
|
|
56
|
-
end
|
|
57
|
-
return nil
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
module GetText
|
|
63
|
-
module RubyParser
|
|
64
|
-
extend self
|
|
65
|
-
|
|
66
|
-
unless defined? ID
|
|
67
|
-
ID = ['gettext', '_', 'N_', 'sgettext', 's_']
|
|
68
|
-
PLURAL_ID = ['ngettext', 'n_', 'Nn_', 'ns_', 'nsgettext']
|
|
69
|
-
MSGCTXT_ID = ['pgettext', 'p_']
|
|
70
|
-
MSGCTXT_PLURAL_ID = ['npgettext', 'np_']
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def parse(file, targets = []) # :nodoc:
|
|
74
|
-
lines = IO.readlines(file)
|
|
75
|
-
parse_lines(file, lines, targets)
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def parse_lines(file_name, lines, targets) # :nodoc:
|
|
79
|
-
file = StringIO.new(lines.join + "\n")
|
|
80
|
-
rl = RubyLexX.new
|
|
81
|
-
rl.set_input(file)
|
|
82
|
-
rl.skip_space = true
|
|
83
|
-
#rl.readed_auto_clean_up = true
|
|
84
|
-
|
|
85
|
-
target = nil
|
|
86
|
-
msgid = nil
|
|
87
|
-
line_no = nil
|
|
88
|
-
rl.parse do |tk|
|
|
89
|
-
begin
|
|
90
|
-
case tk
|
|
91
|
-
when RubyToken::TkIDENTIFIER, RubyToken::TkCONSTANT
|
|
92
|
-
if ID.include?(tk.name)
|
|
93
|
-
target = :normal
|
|
94
|
-
elsif PLURAL_ID.include?(tk.name)
|
|
95
|
-
target = :plural
|
|
96
|
-
elsif MSGCTXT_ID.include?(tk.name)
|
|
97
|
-
target = :msgctxt
|
|
98
|
-
elsif MSGCTXT_PLURAL_ID.include?(tk.name)
|
|
99
|
-
target = :msgctxt_plural
|
|
100
|
-
else
|
|
101
|
-
target = nil
|
|
102
|
-
end
|
|
103
|
-
line_no = tk.line_no.to_s
|
|
104
|
-
when RubyToken::TkSTRING
|
|
105
|
-
if target
|
|
106
|
-
if msgid
|
|
107
|
-
msgid += tk.value
|
|
108
|
-
else
|
|
109
|
-
msgid = tk.value
|
|
110
|
-
end
|
|
111
|
-
end
|
|
112
|
-
when RubyToken::TkPLUS, RubyToken::TkNL
|
|
113
|
-
#do nothing
|
|
114
|
-
when RubyToken::TkCOMMA
|
|
115
|
-
if msgid
|
|
116
|
-
case target
|
|
117
|
-
when :plural
|
|
118
|
-
msgid += "\000"
|
|
119
|
-
target = :normal
|
|
120
|
-
when :msgctxt
|
|
121
|
-
msgid += "\004"
|
|
122
|
-
target = :normal
|
|
123
|
-
when :msgctxt_plural
|
|
124
|
-
msgid += "\004"
|
|
125
|
-
target = :plural
|
|
126
|
-
else
|
|
127
|
-
target = :normal
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
|
-
else
|
|
131
|
-
if msgid
|
|
132
|
-
key_existed = targets.assoc(msgid.gsub(/\n/, '\n'))
|
|
133
|
-
if key_existed
|
|
134
|
-
targets[targets.index(key_existed)] = key_existed <<
|
|
135
|
-
file_name + ":" + line_no
|
|
136
|
-
else
|
|
137
|
-
targets << [msgid.gsub(/\n/, '\n'), file_name + ":" + line_no]
|
|
138
|
-
end
|
|
139
|
-
msgid = nil
|
|
140
|
-
target = nil
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
targets
|
|
144
|
-
rescue
|
|
145
|
-
$stderr.print "\n\nError: #{$!.inspect} "
|
|
146
|
-
$stderr.print " in #{file_name}:#{tk.line_no}\n\t #{lines[tk.line_no - 1]}" if tk
|
|
147
|
-
$stderr.print "\n"
|
|
148
|
-
exit 1
|
|
149
|
-
end
|
|
150
|
-
end
|
|
151
|
-
targets
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
def target?(file) # :nodoc:
|
|
155
|
-
true # always true, as default parser.
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if __FILE__ == $0
|
|
163
|
-
require 'pp'
|
|
164
|
-
ARGV.each do |file|
|
|
165
|
-
pp GetText::RubyParser.parse(file)
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
#rl = RubyLexX.new; rl.set_input(ARGF)
|
|
169
|
-
#rl.parse do |tk|
|
|
170
|
-
#p tk
|
|
171
|
-
#end
|
|
172
|
-
end
|