gettext 1.6.0-mswin32 → 1.7.0-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +65 -0
- data/NEWS +20 -0
- data/README +9 -9
- data/Rakefile +4 -4
- 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/rails.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/ru/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/ru/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/sv/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/zh/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/zh/LC_MESSAGES/rgettext.mo +0 -0
- data/ext/gettext/Makefile +178 -0
- data/ext/gettext/locale_system-i386-mswin32.def +2 -0
- data/ext/gettext/locale_system-i386-mswin32.exp +0 -0
- data/ext/gettext/locale_system-i386-mswin32.lib +0 -0
- data/ext/gettext/locale_system-i386-mswin32.pdb +0 -0
- data/ext/gettext/locale_system.obj +0 -0
- data/ext/gettext/locale_system.so +0 -0
- data/ext/gettext/mkmf.log +16 -0
- data/ext/gettext/vc70.pdb +0 -0
- data/lib/gettext.rb +38 -12
- data/lib/gettext/container.rb +2 -2
- data/lib/gettext/iconv.rb +2 -2
- data/lib/gettext/locale_cgi.rb +3 -2
- data/lib/gettext/locale_object.rb +8 -8
- data/lib/gettext/locale_posix.rb +2 -2
- data/lib/gettext/locale_table_win32.rb +3 -3
- data/lib/gettext/locale_win32.rb +2 -2
- data/lib/gettext/mo.rb +5 -2
- data/lib/gettext/parser/activerecord.rb +27 -17
- data/lib/gettext/parser/glade.rb +7 -11
- data/lib/gettext/parser/ruby.rb +2 -3
- data/lib/gettext/poparser.rb +298 -298
- data/lib/gettext/rails.rb +220 -85
- data/lib/gettext/rgettext.rb +2 -2
- data/lib/gettext/rmsgfmt.rb +3 -3
- data/lib/gettext/rmsgmerge.rb +2 -2
- data/lib/gettext/string.rb +2 -1
- data/lib/gettext/textdomain.rb +5 -2
- data/lib/gettext/textdomainmanager.rb +3 -3
- data/lib/gettext/version.rb +1 -1
- data/lib/locale_system.so +0 -0
- data/po/cs/rails.po +63 -22
- data/po/cs/rgettext.po +71 -37
- data/po/de/rails.po +54 -16
- data/po/de/rgettext.po +56 -22
- data/po/el/rails.po +54 -16
- data/po/el/rgettext.po +56 -22
- data/po/es/rails.po +57 -20
- data/po/es/rgettext.po +70 -30
- data/po/fr/rails.po +57 -19
- data/po/fr/rgettext.po +61 -25
- data/po/it/rails.po +54 -16
- data/po/it/rgettext.po +56 -22
- data/po/ja/rails.po +55 -18
- data/po/ja/rgettext.po +58 -24
- data/po/ko/rails.po +68 -33
- data/po/ko/rgettext.po +77 -37
- data/po/nl/rails.po +61 -22
- data/po/nl/rgettext.po +72 -36
- data/po/pt_BR/rails.po +54 -16
- data/po/pt_BR/rgettext.po +56 -22
- data/po/rails.pot +54 -16
- data/po/rgettext.pot +55 -21
- data/po/ru/rails.po +68 -26
- data/po/ru/rgettext.po +70 -30
- data/po/sv/rgettext.po +55 -21
- data/po/zh/rails.po +51 -16
- data/po/zh/rgettext.po +59 -23
- data/samples/rails/app/controllers/application.rb +7 -1
- data/samples/rails/app/models/article.rb +0 -6
- data/samples/rails/locale/cs/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/de/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/el/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/es/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/fr/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/ja/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/ko/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/nl/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/pt_BR/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/ru/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/src/poparser.ry +1 -1
- data/test/gettext_test.rb +1 -1
- data/test/gettext_test_parser.rb +0 -1
- data/test/test_rubyparser.rb +0 -11
- metadata +21 -7
data/lib/gettext/container.rb
CHANGED
@@ -6,12 +6,12 @@
|
|
6
6
|
You may redistribute it and/or modify it under the same
|
7
7
|
license terms as Ruby.
|
8
8
|
|
9
|
-
$Id: container.rb,v 1.
|
9
|
+
$Id: container.rb,v 1.6 2006/06/11 15:36:20 mutoh Exp $
|
10
10
|
=end
|
11
11
|
|
12
12
|
require 'gettext'
|
13
13
|
|
14
|
-
module GetText
|
14
|
+
module GetText
|
15
15
|
# Deprecated. You don't need this. Use GetText instead.
|
16
16
|
module Container
|
17
17
|
include GetText
|
data/lib/gettext/iconv.rb
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
You may redistribute it and/or modify it under the same
|
10
10
|
license terms as Ruby.
|
11
11
|
|
12
|
-
$Id: iconv.rb,v 1.
|
12
|
+
$Id: iconv.rb,v 1.3 2006/06/11 15:36:20 mutoh Exp $
|
13
13
|
=end
|
14
14
|
|
15
15
|
begin
|
@@ -17,7 +17,7 @@ begin
|
|
17
17
|
rescue LoadError
|
18
18
|
begin
|
19
19
|
require 'glib2'
|
20
|
-
#
|
20
|
+
# Pseudo Iconv module
|
21
21
|
#
|
22
22
|
# Provides Iconv.iconv which uses Ruby/GLib(1) functions. This library also required from 'gettext'.
|
23
23
|
# If you require 'gettext/iconv', Iconv.iconv try to call Ruby/GLib function
|
data/lib/gettext/locale_cgi.rb
CHANGED
@@ -6,11 +6,11 @@
|
|
6
6
|
You may redistribute it and/or modify it under the same
|
7
7
|
license terms as Ruby.
|
8
8
|
|
9
|
-
$Id: locale_cgi.rb,v 1.
|
9
|
+
$Id: locale_cgi.rb,v 1.4 2006/06/11 15:36:20 mutoh Exp $
|
10
10
|
=end
|
11
11
|
|
12
12
|
|
13
|
-
module Locale
|
13
|
+
module Locale
|
14
14
|
# Locale::System module for Default OS (Unix)
|
15
15
|
# This is low-level class. Application shouldn't use this directly.
|
16
16
|
module SystemCGI
|
@@ -21,6 +21,7 @@ module Locale # :nodoc:
|
|
21
21
|
# Gets the default locale using setlocale and nl_langinfo.
|
22
22
|
# * Returns the system locale (Locale::Object).
|
23
23
|
def system
|
24
|
+
return @@default_locale unless @@cgi
|
24
25
|
cgi_ = cgi
|
25
26
|
if ret = cgi_["lang"] and ret.size > 0
|
26
27
|
elsif ret = cgi_.cookies["lang"][0]
|
@@ -6,11 +6,11 @@
|
|
6
6
|
You may redistribute it and/or modify it under the same
|
7
7
|
license terms as Ruby.
|
8
8
|
|
9
|
-
$Id: locale_object.rb,v 1.
|
9
|
+
$Id: locale_object.rb,v 1.8 2006/06/11 15:36:20 mutoh Exp $
|
10
10
|
=end
|
11
11
|
|
12
12
|
|
13
|
-
module Locale
|
13
|
+
module Locale
|
14
14
|
class Object
|
15
15
|
attr_accessor :language, :country, :charset, :script, :variant, :modifier, :orig_str
|
16
16
|
|
@@ -19,16 +19,16 @@ module Locale # :nodoc:
|
|
19
19
|
# * locale_name: locale name as String
|
20
20
|
#
|
21
21
|
# * Basic POSIX format: <language>_<COUNTRY>.<charset>@<modifier>
|
22
|
-
#
|
22
|
+
# * Both of POSIX and C are converted to "en".
|
23
23
|
# * Basic RFC3066 format: <language>-<COUNTRY>
|
24
24
|
# * Win32 format: <language>-<COUNTRY>-<Script>_<sort order>
|
25
25
|
# * CLDR format: <language>_<Script>_<COUNTRY>_<variant>@<modifier>
|
26
26
|
# * Some broken format: <language>_<country>_<script> # Don't use this.
|
27
27
|
# * The max locale format is below:
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
28
|
+
# * <language>-<COUNTRY>-<Script>_<sort order>.<charset>@<modifier>
|
29
|
+
# * format: <language>_<Script>_<COUNTRY>_<variant>@<modifier>
|
30
|
+
# * both of '-' and '_' are separators.
|
31
|
+
# * each elements are omittable.
|
32
32
|
#
|
33
33
|
# (e.g.) uz-UZ-Latn, ja_JP.eucJP, wa_BE.iso885915@euro
|
34
34
|
# * Returns: [language, country, charset, script, modifier]
|
@@ -39,7 +39,7 @@ module Locale # :nodoc:
|
|
39
39
|
# * variant: variant value in CLDR or sort order in Win32.
|
40
40
|
# * modifier: (no standard)
|
41
41
|
#
|
42
|
-
#
|
42
|
+
# (e.g.)
|
43
43
|
# "ja_JP.eucJP" => ["ja", "JP", "eucJP", nil, nil]
|
44
44
|
# "ja-jp.utf-8" => ["ja", "JP", "utf-8", nil, nil]
|
45
45
|
# "ja-jp" => ["ja", "JP", nil, nil, nil]
|
data/lib/gettext/locale_posix.rb
CHANGED
@@ -6,11 +6,11 @@
|
|
6
6
|
You may redistribute it and/or modify it under the same
|
7
7
|
license terms as Ruby.
|
8
8
|
|
9
|
-
$Id: locale_posix.rb,v 1.
|
9
|
+
$Id: locale_posix.rb,v 1.4 2006/06/11 15:36:20 mutoh Exp $
|
10
10
|
=end
|
11
11
|
|
12
12
|
|
13
|
-
module Locale
|
13
|
+
module Locale
|
14
14
|
# Locale::SystemPosix module for Posix OS (Unix)
|
15
15
|
# This is low-level class. Application shouldn't use this directly.
|
16
16
|
module SystemPosix
|
@@ -6,11 +6,11 @@
|
|
6
6
|
You may redistribute it and/or modify it under the same
|
7
7
|
license terms as Ruby.
|
8
8
|
|
9
|
-
$Id: locale_table_win32.rb,v 1.
|
9
|
+
$Id: locale_table_win32.rb,v 1.5 2006/06/11 15:36:20 mutoh Exp $
|
10
10
|
=end
|
11
11
|
|
12
|
-
module Locale
|
13
|
-
module SystemWin32
|
12
|
+
module Locale
|
13
|
+
module SystemWin32
|
14
14
|
#LangID, locale name, code page
|
15
15
|
LocaleTable = [
|
16
16
|
[0x0000, "en", "CP1252"],
|
data/lib/gettext/locale_win32.rb
CHANGED
@@ -6,12 +6,12 @@
|
|
6
6
|
You may redistribute it and/or modify it under the same
|
7
7
|
license terms as Ruby.
|
8
8
|
|
9
|
-
$Id: locale_win32.rb,v 1.
|
9
|
+
$Id: locale_win32.rb,v 1.14 2006/06/11 15:36:20 mutoh Exp $
|
10
10
|
=end
|
11
11
|
|
12
12
|
require 'gettext/locale_table_win32'
|
13
13
|
|
14
|
-
module Locale
|
14
|
+
module Locale
|
15
15
|
# Locale::SystemWin32 module for win32.
|
16
16
|
module SystemWin32
|
17
17
|
extend Locale::System
|
data/lib/gettext/mo.rb
CHANGED
@@ -12,14 +12,16 @@
|
|
12
12
|
of Ruby. License of Ruby is included with Ruby distribution in
|
13
13
|
the file "README".
|
14
14
|
|
15
|
-
$Id: mo.rb,v 1.
|
15
|
+
$Id: mo.rb,v 1.7 2006/06/11 15:36:20 mutoh Exp $
|
16
16
|
=end
|
17
17
|
|
18
18
|
require 'gettext/iconv'
|
19
19
|
|
20
|
-
class MOFile < Hash
|
20
|
+
class MOFile < Hash
|
21
21
|
class InvalidFormat < RuntimeError; end;
|
22
22
|
|
23
|
+
attr_reader :filename
|
24
|
+
|
23
25
|
Header = Struct.new(:magic,
|
24
26
|
:revision,
|
25
27
|
:nstrings,
|
@@ -249,6 +251,7 @@ class MOFile < Hash #:nodoc:
|
|
249
251
|
end
|
250
252
|
|
251
253
|
def load_from_file(filename)
|
254
|
+
@filename = filename
|
252
255
|
File.open(filename, 'rb'){|f| load_from_stream(f)}
|
253
256
|
end
|
254
257
|
|
@@ -7,7 +7,7 @@
|
|
7
7
|
You may redistribute it and/or modify it under the same
|
8
8
|
license terms as Ruby.
|
9
9
|
|
10
|
-
$Id: activerecord.rb,v 1.
|
10
|
+
$Id: activerecord.rb,v 1.11 2006/07/13 18:22:09 mutoh Exp $
|
11
11
|
=end
|
12
12
|
|
13
13
|
require 'gettext'
|
@@ -25,6 +25,7 @@ module GetText
|
|
25
25
|
:db_yml => "config/database.yml",
|
26
26
|
:db_mode => "development",
|
27
27
|
:activerecord_classes => ["ActiveRecord::Base"],
|
28
|
+
:untranslate_columns => ["id"],
|
28
29
|
:use_classname => true,
|
29
30
|
}
|
30
31
|
|
@@ -42,10 +43,11 @@ module GetText
|
|
42
43
|
# Sets some preferences to parse ActiveRecord files.
|
43
44
|
#
|
44
45
|
# * config: a Hash of the config. It can takes some values below:
|
45
|
-
# * :use_classname
|
46
|
-
# * :db_yml
|
47
|
-
# * :db_mode
|
48
|
-
# * :activerecord_classes
|
46
|
+
# * :use_classname - If true, the msgids of ActiveRecord become "ClassName|FieldName" (e.g. "Article|Title"). Otherwise the ClassName is not used (e.g. "Title"). Default is true.
|
47
|
+
# * :db_yml - the path of database.yml. Default is "config/database.yml".
|
48
|
+
# * :db_mode - the mode of the database. Default is "development"
|
49
|
+
# * :activerecord_classes - an Array of the superclass of the models. The classes should be String value. Default is ["ActiveRecord::Base"]
|
50
|
+
# * :untranslate_columns - an Array of the column names which is ignored as the msgid.
|
49
51
|
#
|
50
52
|
# "ClassName|FieldName" uses GetText.sgettext. So you don't need to translate the left-side of "|".
|
51
53
|
# See <Documents for Translators for more details(http://www.yotabanana.com/hiki/ruby-gettext-translate.html)>.
|
@@ -58,6 +60,10 @@ module GetText
|
|
58
60
|
@ar_re = /class.*(#{@config[:activerecord_classes].join("|")})/
|
59
61
|
end
|
60
62
|
|
63
|
+
def untranslate_column?(klass, columnname)
|
64
|
+
klass.untranslate?(columnname) || @config[:untranslate_columns].include?(columnname)
|
65
|
+
end
|
66
|
+
|
61
67
|
def parse(file, targets = []) # :nodoc:
|
62
68
|
old_constants = constants
|
63
69
|
begin
|
@@ -70,20 +76,24 @@ module GetText
|
|
70
76
|
loaded_constants.each do |classname|
|
71
77
|
klass = eval(classname)
|
72
78
|
if klass < ActiveRecord::Base
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
79
|
+
unless klass.untranslate_all?
|
80
|
+
add_target(targets, file, ::Inflector.singularize(klass.table_name.gsub(/_/, " ")))
|
81
|
+
tablename = klass.class_name
|
82
|
+
begin
|
83
|
+
klass.columns.each do |column|
|
84
|
+
unless untranslate_column?(klass, column.name)
|
85
|
+
if @config[:use_classname]
|
86
|
+
msgid = tablename + "|" + klass.human_attribute_name(column.name)
|
87
|
+
else
|
88
|
+
msgid = klass.human_attribute_name(column.name)
|
89
|
+
end
|
90
|
+
add_target(targets, file, msgid)
|
91
|
+
end
|
81
92
|
end
|
82
|
-
|
93
|
+
rescue
|
94
|
+
$stderr.puts _("No database is available.")
|
95
|
+
$stderr.puts $!
|
83
96
|
end
|
84
|
-
rescue
|
85
|
-
$stderr.puts _("No database is available.")
|
86
|
-
$stderr.puts $!
|
87
97
|
end
|
88
98
|
end
|
89
99
|
end
|
data/lib/gettext/parser/glade.rb
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
|
-
$Id: glade.rb,v 1.
|
9
|
+
$Id: glade.rb,v 1.5 2006/06/11 15:36:20 mutoh Exp $
|
10
10
|
=end
|
11
11
|
|
12
12
|
require 'cgi'
|
@@ -67,17 +67,13 @@ module GetText
|
|
67
67
|
|
68
68
|
def target?(file) # :nodoc:
|
69
69
|
data = IO.readlines(file)
|
70
|
-
if XML_RE =~ data[0]
|
71
|
-
|
72
|
-
return true
|
73
|
-
else
|
74
|
-
if File.extname(file) == '.glade'
|
75
|
-
raise _("%s is not glade-2.0 format.") % [file]
|
76
|
-
end
|
77
|
-
return false
|
78
|
-
end
|
70
|
+
if XML_RE =~ data[0] and GLADE_RE =~ data[1]
|
71
|
+
true
|
79
72
|
else
|
80
|
-
|
73
|
+
if File.extname(file) == '.glade'
|
74
|
+
raise _("`%{file}' is not glade-2.0 format.") % {:file => file}
|
75
|
+
end
|
76
|
+
false
|
81
77
|
end
|
82
78
|
end
|
83
79
|
|
data/lib/gettext/parser/ruby.rb
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
You may redistribute it and/or modify it under the same
|
10
10
|
license terms as Ruby.
|
11
11
|
|
12
|
-
$Id: ruby.rb,v 1.
|
12
|
+
$Id: ruby.rb,v 1.7 2006/06/11 15:36:20 mutoh Exp $
|
13
13
|
=end
|
14
14
|
|
15
15
|
require 'irb/ruby-lex.rb'
|
@@ -171,7 +171,7 @@ module GetText
|
|
171
171
|
end
|
172
172
|
else
|
173
173
|
if msgid
|
174
|
-
key_existed = targets.assoc(msgid)
|
174
|
+
key_existed = targets.assoc(msgid.gsub(/\n/, '\n'))
|
175
175
|
if key_existed
|
176
176
|
targets[targets.index(key_existed)] = key_existed <<
|
177
177
|
file_name + ":" + line_no
|
@@ -184,7 +184,6 @@ module GetText
|
|
184
184
|
end
|
185
185
|
targets
|
186
186
|
end
|
187
|
-
|
188
187
|
targets
|
189
188
|
end
|
190
189
|
|
data/lib/gettext/poparser.rb
CHANGED
@@ -1,298 +1,298 @@
|
|
1
|
-
=begin
|
2
|
-
poparser.rb - Generate a .mo
|
3
|
-
|
4
|
-
Copyright (C) 2003-2005 Masao Mutoh <mutoh@highway.ne.jp>
|
5
|
-
|
6
|
-
You may redistribute it and/or modify it under the same
|
7
|
-
license terms as Ruby.
|
8
|
-
=end
|
9
|
-
|
10
|
-
#
|
11
|
-
# DO NOT MODIFY!!!!
|
12
|
-
# This file is automatically generated by racc 1.4.
|
13
|
-
# from racc grammer file "src/poparser.ry".
|
14
|
-
#
|
15
|
-
|
16
|
-
require 'racc/parser'
|
17
|
-
|
18
|
-
|
19
|
-
module GetText
|
20
|
-
|
21
|
-
class PoParser < Racc::Parser
|
22
|
-
|
23
|
-
module_eval <<'..end src/poparser.ry modeval..
|
24
|
-
include GetText
|
25
|
-
GetText.bindtextdomain("rgettext")
|
26
|
-
|
27
|
-
def unescape(orig)
|
28
|
-
ret = orig.gsub(/\\n/, "\n")
|
29
|
-
ret.gsub!(/\\t/, "\t")
|
30
|
-
ret.gsub!(/\\r/, "\r")
|
31
|
-
ret.gsub!(/\\"/, "\"")
|
32
|
-
ret
|
33
|
-
end
|
34
|
-
|
35
|
-
def parse(str, data, ignore_fuzzy = true)
|
36
|
-
@comments = []
|
37
|
-
@data = data
|
38
|
-
@fuzzy = false
|
39
|
-
$ignore_fuzzy = ignore_fuzzy
|
40
|
-
str.strip!
|
41
|
-
@q = []
|
42
|
-
until str.empty? do
|
43
|
-
case str
|
44
|
-
when /\A\s+/
|
45
|
-
str = $'
|
46
|
-
when /\Amsgid_plural/
|
47
|
-
@q.push [:MSGID_PLURAL, $&]
|
48
|
-
str = $'
|
49
|
-
when /\Amsgid/
|
50
|
-
@q.push [:MSGID, $&]
|
51
|
-
str = $'
|
52
|
-
when /\Amsgstr/
|
53
|
-
@q.push [:MSGSTR, $&]
|
54
|
-
str = $'
|
55
|
-
when /\A\[(\d+)\]/
|
56
|
-
@q.push [:PLURAL_NUM, $1]
|
57
|
-
str = $'
|
58
|
-
when /\A\#~(.*)/
|
59
|
-
$stderr.print _("Warning: obsolete msgid is existed.\n")
|
60
|
-
$stderr.print " #{$&}\n"
|
61
|
-
@q.push [:COMMENT, $&]
|
62
|
-
str = $'
|
63
|
-
when /\A\#(.*)/
|
64
|
-
@q.push [:COMMENT, $&]
|
65
|
-
str = $'
|
66
|
-
when /\A\"(.*)\"/
|
67
|
-
@q.push [:STRING, $1]
|
68
|
-
str = $'
|
69
|
-
else
|
70
|
-
#c = str[0,1]
|
71
|
-
#@q.push [:STRING, c]
|
72
|
-
str = str[1..-1]
|
73
|
-
end
|
74
|
-
end
|
75
|
-
@q.push [false, '$end']
|
76
|
-
if $DEBUG
|
77
|
-
@q.each do |a,b|
|
78
|
-
puts "[#{a}, #{b}]"
|
79
|
-
end
|
80
|
-
end
|
81
|
-
@yydebug = true if $DEBUG
|
82
|
-
do_parse
|
83
|
-
|
84
|
-
if @comments.size > 0
|
85
|
-
@data.set_comment(:last, @comments.join("\n"))
|
86
|
-
end
|
87
|
-
@data
|
88
|
-
end
|
89
|
-
|
90
|
-
def next_token
|
91
|
-
@q.shift
|
92
|
-
end
|
93
|
-
|
94
|
-
def on_message(msgid, msgstr)
|
95
|
-
@data[msgid] = msgstr
|
96
|
-
|
97
|
-
@data.set_comment(msgid, @comments.join("\n"))
|
98
|
-
@comments.clear
|
99
|
-
end
|
100
|
-
|
101
|
-
def on_comment(comment)
|
102
|
-
@fuzzy = true if (/fuzzy/ =~ comment)
|
103
|
-
@comments << comment
|
104
|
-
end
|
105
|
-
|
106
|
-
..end src/poparser.ry modeval..
|
107
|
-
|
108
|
-
##### racc 1.4.
|
109
|
-
|
110
|
-
racc_reduce_table = [
|
111
|
-
0, 0, :racc_error,
|
112
|
-
0, 9, :_reduce_none,
|
113
|
-
2, 9, :_reduce_none,
|
114
|
-
2, 9, :_reduce_none,
|
115
|
-
4, 11, :_reduce_4,
|
116
|
-
5, 11, :_reduce_5,
|
117
|
-
2, 13, :_reduce_6,
|
118
|
-
1, 13, :_reduce_none,
|
119
|
-
3, 14, :_reduce_8,
|
120
|
-
1, 10, :_reduce_9,
|
121
|
-
2, 12, :_reduce_10,
|
122
|
-
1, 12, :_reduce_11 ]
|
123
|
-
|
124
|
-
racc_reduce_n = 12
|
125
|
-
|
126
|
-
racc_shift_n = 21
|
127
|
-
|
128
|
-
racc_action_table = [
|
129
|
-
3, 9, 4, 5, 10, 11, 12, 17, 12, 9,
|
130
|
-
9, 7, 12, 17, 19, 9, 12 ]
|
131
|
-
|
132
|
-
racc_action_check = [
|
133
|
-
1, 5, 1, 1, 8, 8, 8, 13, 13, 10,
|
134
|
-
11, 3, 14, 15, 17, 19, 20 ]
|
135
|
-
|
136
|
-
racc_action_pointer = [
|
137
|
-
nil, 0, nil, 11, nil, -5, nil, nil, 0, nil,
|
138
|
-
3, 4, nil, 2, 6, 8, nil, 7, nil, 9,
|
139
|
-
10 ]
|
140
|
-
|
141
|
-
racc_action_default = [
|
142
|
-
-1, -12, -3, -12, -9, -12, -2, 21, -12, -11,
|
143
|
-
-12, -12, -10, -12, -4, -5, -7, -12, -6, -12,
|
144
|
-
-8 ]
|
145
|
-
|
146
|
-
racc_goto_table = [
|
147
|
-
8, 16, 2, 18, 6, 13, 14, 15, 1, nil,
|
148
|
-
nil, nil, nil, nil, 20 ]
|
149
|
-
|
150
|
-
racc_goto_check = [
|
151
|
-
4, 6, 3, 6, 2, 4, 4, 5, 1, nil,
|
152
|
-
nil, nil, nil, nil, 4 ]
|
153
|
-
|
154
|
-
racc_goto_pointer = [
|
155
|
-
nil, 8, 3, 1, -5, -6, -12 ]
|
156
|
-
|
157
|
-
racc_goto_default = [
|
158
|
-
nil, nil, nil, nil, nil, nil, nil ]
|
159
|
-
|
160
|
-
racc_token_table = {
|
161
|
-
false => 0,
|
162
|
-
Object.new => 1,
|
163
|
-
:COMMENT => 2,
|
164
|
-
:MSGID => 3,
|
165
|
-
:MSGID_PLURAL => 4,
|
166
|
-
:MSGSTR => 5,
|
167
|
-
:STRING => 6,
|
168
|
-
:PLURAL_NUM => 7 }
|
169
|
-
|
170
|
-
racc_use_result_var = true
|
171
|
-
|
172
|
-
racc_nt_base = 8
|
173
|
-
|
174
|
-
Racc_arg = [
|
175
|
-
racc_action_table,
|
176
|
-
racc_action_check,
|
177
|
-
racc_action_default,
|
178
|
-
racc_action_pointer,
|
179
|
-
racc_goto_table,
|
180
|
-
racc_goto_check,
|
181
|
-
racc_goto_default,
|
182
|
-
racc_goto_pointer,
|
183
|
-
racc_nt_base,
|
184
|
-
racc_reduce_table,
|
185
|
-
racc_token_table,
|
186
|
-
racc_shift_n,
|
187
|
-
racc_reduce_n,
|
188
|
-
racc_use_result_var ]
|
189
|
-
|
190
|
-
Racc_token_to_s_table = [
|
191
|
-
'$end',
|
192
|
-
'error',
|
193
|
-
'COMMENT',
|
194
|
-
'MSGID',
|
195
|
-
'MSGID_PLURAL',
|
196
|
-
'MSGSTR',
|
197
|
-
'STRING',
|
198
|
-
'PLURAL_NUM',
|
199
|
-
'$start',
|
200
|
-
'msgfmt',
|
201
|
-
'comment',
|
202
|
-
'message',
|
203
|
-
'string_list',
|
204
|
-
'msgstr_plural',
|
205
|
-
'msgstr_plural_line']
|
206
|
-
|
207
|
-
Racc_debug_parser = true
|
208
|
-
|
209
|
-
##### racc system variables end #####
|
210
|
-
|
211
|
-
# reduce 0 omitted
|
212
|
-
|
213
|
-
# reduce 1 omitted
|
214
|
-
|
215
|
-
# reduce 2 omitted
|
216
|
-
|
217
|
-
# reduce 3 omitted
|
218
|
-
|
219
|
-
module_eval <<'.,.,', 'src/poparser.ry', 36
|
220
|
-
def _reduce_4( val, _values, result )
|
221
|
-
if @fuzzy and $ignore_fuzzy
|
222
|
-
if val[1] != ""
|
223
|
-
$stderr.print _("Warning: fuzzy message was ignored.\n")
|
224
|
-
$stderr.print " msgid '#{val[1]}'\n"
|
225
|
-
else
|
226
|
-
on_message('', unescape(val[3]))
|
227
|
-
end
|
228
|
-
@fuzzy = false
|
229
|
-
else
|
230
|
-
on_message(unescape(val[1]), unescape(val[3]))
|
231
|
-
end
|
232
|
-
result = ""
|
233
|
-
result
|
234
|
-
end
|
235
|
-
.,.,
|
236
|
-
|
237
|
-
module_eval <<'.,.,', 'src/poparser.ry', 51
|
238
|
-
def _reduce_5( val, _values, result )
|
239
|
-
if @fuzzy and $ignore_fuzzy
|
240
|
-
if val[1] != ""
|
241
|
-
$stderr.print _("Warning: fuzzy message was ignored.\n")
|
242
|
-
$stderr.print "msgid = '#{val[1]}\n"
|
243
|
-
else
|
244
|
-
on_message('', unescape(val[3]))
|
245
|
-
end
|
246
|
-
@fuzzy = false
|
247
|
-
else
|
248
|
-
on_message(unescape(val[1]) + "\000" + unescape(val[3]), unescape(val[4]))
|
249
|
-
end
|
250
|
-
result = ""
|
251
|
-
result
|
252
|
-
end
|
253
|
-
.,.,
|
254
|
-
|
255
|
-
module_eval <<'.,.,', 'src/poparser.ry', 58
|
256
|
-
def _reduce_6( val, _values, result )
|
257
|
-
result = val[0] + "\000" + val[1]
|
258
|
-
result
|
259
|
-
end
|
260
|
-
.,.,
|
261
|
-
|
262
|
-
# reduce 7 omitted
|
263
|
-
|
264
|
-
module_eval <<'.,.,', 'src/poparser.ry', 66
|
265
|
-
def _reduce_8( val, _values, result )
|
266
|
-
result = val[2]
|
267
|
-
result
|
268
|
-
end
|
269
|
-
.,.,
|
270
|
-
|
271
|
-
module_eval <<'.,.,', 'src/poparser.ry', 73
|
272
|
-
def _reduce_9( val, _values, result )
|
273
|
-
on_comment(val[0])
|
274
|
-
result
|
275
|
-
end
|
276
|
-
.,.,
|
277
|
-
|
278
|
-
module_eval <<'.,.,', 'src/poparser.ry', 81
|
279
|
-
def _reduce_10( val, _values, result )
|
280
|
-
result = val.delete_if{|item| item == ""}.join
|
281
|
-
result
|
282
|
-
end
|
283
|
-
.,.,
|
284
|
-
|
285
|
-
module_eval <<'.,.,', 'src/poparser.ry', 85
|
286
|
-
def _reduce_11( val, _values, result )
|
287
|
-
result = val[0]
|
288
|
-
result
|
289
|
-
end
|
290
|
-
.,.,
|
291
|
-
|
292
|
-
def _reduce_none( val, _values, result )
|
293
|
-
result
|
294
|
-
end
|
295
|
-
|
296
|
-
end # class PoParser
|
297
|
-
|
298
|
-
end # module GetText
|
1
|
+
=begin
|
2
|
+
poparser.rb - Generate a .mo
|
3
|
+
|
4
|
+
Copyright (C) 2003-2005 Masao Mutoh <mutoh@highway.ne.jp>
|
5
|
+
|
6
|
+
You may redistribute it and/or modify it under the same
|
7
|
+
license terms as Ruby.
|
8
|
+
=end
|
9
|
+
|
10
|
+
#
|
11
|
+
# DO NOT MODIFY!!!!
|
12
|
+
# This file is automatically generated by racc 1.4.5
|
13
|
+
# from racc grammer file "src/poparser.ry".
|
14
|
+
#
|
15
|
+
|
16
|
+
require 'racc/parser'
|
17
|
+
|
18
|
+
|
19
|
+
module GetText
|
20
|
+
|
21
|
+
class PoParser < Racc::Parser
|
22
|
+
|
23
|
+
module_eval <<'..end src/poparser.ry modeval..id0da1ccb1f3', 'src/poparser.ry', 90
|
24
|
+
include GetText
|
25
|
+
GetText.bindtextdomain("rgettext")
|
26
|
+
|
27
|
+
def unescape(orig)
|
28
|
+
ret = orig.gsub(/\\n/, "\n")
|
29
|
+
ret.gsub!(/\\t/, "\t")
|
30
|
+
ret.gsub!(/\\r/, "\r")
|
31
|
+
ret.gsub!(/\\"/, "\"")
|
32
|
+
ret
|
33
|
+
end
|
34
|
+
|
35
|
+
def parse(str, data, ignore_fuzzy = true)
|
36
|
+
@comments = []
|
37
|
+
@data = data
|
38
|
+
@fuzzy = false
|
39
|
+
$ignore_fuzzy = ignore_fuzzy
|
40
|
+
str.strip!
|
41
|
+
@q = []
|
42
|
+
until str.empty? do
|
43
|
+
case str
|
44
|
+
when /\A\s+/
|
45
|
+
str = $'
|
46
|
+
when /\Amsgid_plural/
|
47
|
+
@q.push [:MSGID_PLURAL, $&]
|
48
|
+
str = $'
|
49
|
+
when /\Amsgid/
|
50
|
+
@q.push [:MSGID, $&]
|
51
|
+
str = $'
|
52
|
+
when /\Amsgstr/
|
53
|
+
@q.push [:MSGSTR, $&]
|
54
|
+
str = $'
|
55
|
+
when /\A\[(\d+)\]/
|
56
|
+
@q.push [:PLURAL_NUM, $1]
|
57
|
+
str = $'
|
58
|
+
when /\A\#~(.*)/
|
59
|
+
$stderr.print _("Warning: obsolete msgid is existed.\n")
|
60
|
+
$stderr.print " #{$&}\n"
|
61
|
+
@q.push [:COMMENT, $&]
|
62
|
+
str = $'
|
63
|
+
when /\A\#(.*)/
|
64
|
+
@q.push [:COMMENT, $&]
|
65
|
+
str = $'
|
66
|
+
when /\A\"(.*)\"/
|
67
|
+
@q.push [:STRING, $1]
|
68
|
+
str = $'
|
69
|
+
else
|
70
|
+
#c = str[0,1]
|
71
|
+
#@q.push [:STRING, c]
|
72
|
+
str = str[1..-1]
|
73
|
+
end
|
74
|
+
end
|
75
|
+
@q.push [false, '$end']
|
76
|
+
if $DEBUG
|
77
|
+
@q.each do |a,b|
|
78
|
+
puts "[#{a}, #{b}]"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
@yydebug = true if $DEBUG
|
82
|
+
do_parse
|
83
|
+
|
84
|
+
if @comments.size > 0
|
85
|
+
@data.set_comment(:last, @comments.join("\n"))
|
86
|
+
end
|
87
|
+
@data
|
88
|
+
end
|
89
|
+
|
90
|
+
def next_token
|
91
|
+
@q.shift
|
92
|
+
end
|
93
|
+
|
94
|
+
def on_message(msgid, msgstr)
|
95
|
+
@data[msgid] = msgstr
|
96
|
+
|
97
|
+
@data.set_comment(msgid, @comments.join("\n"))
|
98
|
+
@comments.clear
|
99
|
+
end
|
100
|
+
|
101
|
+
def on_comment(comment)
|
102
|
+
@fuzzy = true if (/fuzzy/ =~ comment)
|
103
|
+
@comments << comment
|
104
|
+
end
|
105
|
+
|
106
|
+
..end src/poparser.ry modeval..id0da1ccb1f3
|
107
|
+
|
108
|
+
##### racc 1.4.5 generates ###
|
109
|
+
|
110
|
+
racc_reduce_table = [
|
111
|
+
0, 0, :racc_error,
|
112
|
+
0, 9, :_reduce_none,
|
113
|
+
2, 9, :_reduce_none,
|
114
|
+
2, 9, :_reduce_none,
|
115
|
+
4, 11, :_reduce_4,
|
116
|
+
5, 11, :_reduce_5,
|
117
|
+
2, 13, :_reduce_6,
|
118
|
+
1, 13, :_reduce_none,
|
119
|
+
3, 14, :_reduce_8,
|
120
|
+
1, 10, :_reduce_9,
|
121
|
+
2, 12, :_reduce_10,
|
122
|
+
1, 12, :_reduce_11 ]
|
123
|
+
|
124
|
+
racc_reduce_n = 12
|
125
|
+
|
126
|
+
racc_shift_n = 21
|
127
|
+
|
128
|
+
racc_action_table = [
|
129
|
+
3, 9, 4, 5, 10, 11, 12, 17, 12, 9,
|
130
|
+
9, 7, 12, 17, 19, 9, 12 ]
|
131
|
+
|
132
|
+
racc_action_check = [
|
133
|
+
1, 5, 1, 1, 8, 8, 8, 13, 13, 10,
|
134
|
+
11, 3, 14, 15, 17, 19, 20 ]
|
135
|
+
|
136
|
+
racc_action_pointer = [
|
137
|
+
nil, 0, nil, 11, nil, -5, nil, nil, 0, nil,
|
138
|
+
3, 4, nil, 2, 6, 8, nil, 7, nil, 9,
|
139
|
+
10 ]
|
140
|
+
|
141
|
+
racc_action_default = [
|
142
|
+
-1, -12, -3, -12, -9, -12, -2, 21, -12, -11,
|
143
|
+
-12, -12, -10, -12, -4, -5, -7, -12, -6, -12,
|
144
|
+
-8 ]
|
145
|
+
|
146
|
+
racc_goto_table = [
|
147
|
+
8, 16, 2, 18, 6, 13, 14, 15, 1, nil,
|
148
|
+
nil, nil, nil, nil, 20 ]
|
149
|
+
|
150
|
+
racc_goto_check = [
|
151
|
+
4, 6, 3, 6, 2, 4, 4, 5, 1, nil,
|
152
|
+
nil, nil, nil, nil, 4 ]
|
153
|
+
|
154
|
+
racc_goto_pointer = [
|
155
|
+
nil, 8, 3, 1, -5, -6, -12 ]
|
156
|
+
|
157
|
+
racc_goto_default = [
|
158
|
+
nil, nil, nil, nil, nil, nil, nil ]
|
159
|
+
|
160
|
+
racc_token_table = {
|
161
|
+
false => 0,
|
162
|
+
Object.new => 1,
|
163
|
+
:COMMENT => 2,
|
164
|
+
:MSGID => 3,
|
165
|
+
:MSGID_PLURAL => 4,
|
166
|
+
:MSGSTR => 5,
|
167
|
+
:STRING => 6,
|
168
|
+
:PLURAL_NUM => 7 }
|
169
|
+
|
170
|
+
racc_use_result_var = true
|
171
|
+
|
172
|
+
racc_nt_base = 8
|
173
|
+
|
174
|
+
Racc_arg = [
|
175
|
+
racc_action_table,
|
176
|
+
racc_action_check,
|
177
|
+
racc_action_default,
|
178
|
+
racc_action_pointer,
|
179
|
+
racc_goto_table,
|
180
|
+
racc_goto_check,
|
181
|
+
racc_goto_default,
|
182
|
+
racc_goto_pointer,
|
183
|
+
racc_nt_base,
|
184
|
+
racc_reduce_table,
|
185
|
+
racc_token_table,
|
186
|
+
racc_shift_n,
|
187
|
+
racc_reduce_n,
|
188
|
+
racc_use_result_var ]
|
189
|
+
|
190
|
+
Racc_token_to_s_table = [
|
191
|
+
'$end',
|
192
|
+
'error',
|
193
|
+
'COMMENT',
|
194
|
+
'MSGID',
|
195
|
+
'MSGID_PLURAL',
|
196
|
+
'MSGSTR',
|
197
|
+
'STRING',
|
198
|
+
'PLURAL_NUM',
|
199
|
+
'$start',
|
200
|
+
'msgfmt',
|
201
|
+
'comment',
|
202
|
+
'message',
|
203
|
+
'string_list',
|
204
|
+
'msgstr_plural',
|
205
|
+
'msgstr_plural_line']
|
206
|
+
|
207
|
+
Racc_debug_parser = true
|
208
|
+
|
209
|
+
##### racc system variables end #####
|
210
|
+
|
211
|
+
# reduce 0 omitted
|
212
|
+
|
213
|
+
# reduce 1 omitted
|
214
|
+
|
215
|
+
# reduce 2 omitted
|
216
|
+
|
217
|
+
# reduce 3 omitted
|
218
|
+
|
219
|
+
module_eval <<'.,.,', 'src/poparser.ry', 36
|
220
|
+
def _reduce_4( val, _values, result )
|
221
|
+
if @fuzzy and $ignore_fuzzy
|
222
|
+
if val[1] != ""
|
223
|
+
$stderr.print _("Warning: fuzzy message was ignored.\n")
|
224
|
+
$stderr.print " msgid '#{val[1]}'\n"
|
225
|
+
else
|
226
|
+
on_message('', unescape(val[3]))
|
227
|
+
end
|
228
|
+
@fuzzy = false
|
229
|
+
else
|
230
|
+
on_message(unescape(val[1]), unescape(val[3]))
|
231
|
+
end
|
232
|
+
result = ""
|
233
|
+
result
|
234
|
+
end
|
235
|
+
.,.,
|
236
|
+
|
237
|
+
module_eval <<'.,.,', 'src/poparser.ry', 51
|
238
|
+
def _reduce_5( val, _values, result )
|
239
|
+
if @fuzzy and $ignore_fuzzy
|
240
|
+
if val[1] != ""
|
241
|
+
$stderr.print _("Warning: fuzzy message was ignored.\n")
|
242
|
+
$stderr.print "msgid = '#{val[1]}\n"
|
243
|
+
else
|
244
|
+
on_message('', unescape(val[3]))
|
245
|
+
end
|
246
|
+
@fuzzy = false
|
247
|
+
else
|
248
|
+
on_message(unescape(val[1]) + "\000" + unescape(val[3]), unescape(val[4]))
|
249
|
+
end
|
250
|
+
result = ""
|
251
|
+
result
|
252
|
+
end
|
253
|
+
.,.,
|
254
|
+
|
255
|
+
module_eval <<'.,.,', 'src/poparser.ry', 58
|
256
|
+
def _reduce_6( val, _values, result )
|
257
|
+
result = val[0] + "\000" + val[1]
|
258
|
+
result
|
259
|
+
end
|
260
|
+
.,.,
|
261
|
+
|
262
|
+
# reduce 7 omitted
|
263
|
+
|
264
|
+
module_eval <<'.,.,', 'src/poparser.ry', 66
|
265
|
+
def _reduce_8( val, _values, result )
|
266
|
+
result = val[2]
|
267
|
+
result
|
268
|
+
end
|
269
|
+
.,.,
|
270
|
+
|
271
|
+
module_eval <<'.,.,', 'src/poparser.ry', 73
|
272
|
+
def _reduce_9( val, _values, result )
|
273
|
+
on_comment(val[0])
|
274
|
+
result
|
275
|
+
end
|
276
|
+
.,.,
|
277
|
+
|
278
|
+
module_eval <<'.,.,', 'src/poparser.ry', 81
|
279
|
+
def _reduce_10( val, _values, result )
|
280
|
+
result = val.delete_if{|item| item == ""}.join
|
281
|
+
result
|
282
|
+
end
|
283
|
+
.,.,
|
284
|
+
|
285
|
+
module_eval <<'.,.,', 'src/poparser.ry', 85
|
286
|
+
def _reduce_11( val, _values, result )
|
287
|
+
result = val[0]
|
288
|
+
result
|
289
|
+
end
|
290
|
+
.,.,
|
291
|
+
|
292
|
+
def _reduce_none( val, _values, result )
|
293
|
+
result
|
294
|
+
end
|
295
|
+
|
296
|
+
end # class PoParser
|
297
|
+
|
298
|
+
end # module GetText
|