gettext 1.1.1-mswin32 → 1.2.0-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +128 -0
- data/NEWS +10 -0
- data/README +21 -23
- data/Rakefile +40 -21
- data/bin/rgettext +1 -1
- data/bin/rmsgfmt +1 -1
- data/bin/rmsgmerge +1 -1
- 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/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/sv/LC_MESSAGES/rgettext.mo +0 -0
- data/ext/gettext/{gettext/Makefile → Makefile} +3 -3
- data/ext/gettext/extconf.rb +20 -0
- data/ext/gettext/locale_system-i386-mswin32.def +2 -0
- data/ext/gettext/{gettext/_locale.c → locale_system.c} +15 -19
- data/ext/gettext/locale_system.exp +0 -0
- data/ext/gettext/locale_system.lib +0 -0
- data/ext/gettext/locale_system.obj +0 -0
- data/ext/gettext/{gettext/_locale.pdb → locale_system.pdb} +0 -0
- data/ext/gettext/locale_system.so +0 -0
- data/ext/gettext/mkmf.log +10 -0
- data/ext/gettext/{gettext/vc70.pdb → vc70.pdb} +0 -0
- data/lib/gettext.rb +186 -38
- data/lib/gettext/cgi.rb +35 -69
- data/lib/gettext/container.rb +14 -5
- data/lib/gettext/erb.rb +30 -2
- data/lib/gettext/iconv.rb +19 -4
- data/lib/gettext/locale.rb +188 -39
- data/lib/gettext/locale_cgi.rb +102 -0
- data/lib/gettext/locale_object.rb +131 -0
- data/lib/gettext/locale_posix.rb +50 -0
- data/lib/gettext/locale_table_win32.rb +224 -182
- data/lib/gettext/locale_win32.rb +59 -35
- data/lib/gettext/mo.rb +2 -2
- data/lib/gettext/parser/activerecord.rb +19 -5
- data/lib/gettext/parser/erb.rb +6 -3
- data/lib/gettext/parser/glade.rb +5 -5
- data/lib/gettext/parser/ruby.rb +6 -6
- data/lib/gettext/poparser.rb +298 -297
- data/lib/gettext/rails.rb +122 -44
- data/lib/gettext/rgettext.rb +21 -8
- data/lib/gettext/rmsgfmt.rb +16 -8
- data/lib/gettext/rmsgmerge.rb +172 -50
- data/lib/gettext/string.rb +25 -3
- data/lib/gettext/textdomain.rb +89 -90
- data/lib/gettext/utils.rb +63 -3
- data/lib/gettext/version.rb +2 -2
- data/lib/locale_system.so +0 -0
- data/po/cs/rails.po +28 -28
- data/po/cs/rgettext.po +14 -14
- data/po/de/rails.po +29 -26
- data/po/de/rgettext.po +24 -17
- data/po/el/rails.po +26 -26
- data/po/el/rgettext.po +18 -15
- data/po/es/rails.po +26 -26
- data/po/es/rgettext.po +16 -16
- data/po/fr/rails.po +27 -27
- data/po/fr/rgettext.po +14 -14
- data/po/it/rgettext.po +14 -14
- data/po/ja/rails.po +24 -24
- data/po/ja/rgettext.po +14 -14
- data/po/ko/rails.po +24 -24
- data/po/ko/rgettext.po +17 -18
- data/po/nl/rails.po +27 -27
- data/po/nl/rgettext.po +18 -18
- data/po/pt_BR/rails.po +26 -26
- data/po/pt_BR/rgettext.po +14 -14
- data/po/rails.pot +26 -26
- data/po/rgettext.pot +14 -14
- data/po/sv/rgettext.po +14 -14
- data/post-setup.rb +8 -3
- data/pre-setup.rb +14 -1
- data/samples/cgi/http.rb +2 -1
- data/samples/makemo.rb +1 -1
- data/samples/rails/app/models/article.rb +15 -1
- data/samples/rails/config/database.yml +1 -1
- data/samples/rails/locale/cs/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/cs/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/de/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/de/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/el/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/el/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/en/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/es/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/es/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/fr/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/fr/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/ja/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/ja/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/ko/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/ko/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/nl/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/nl/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/pt_BR/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/pt_BR/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/po/blog.pot +1 -1
- data/samples/rails/po/cs/blog.po +1 -2
- data/samples/rails/po/cs/gettext_plugin.po +1 -1
- data/samples/rails/po/de/blog.po +1 -2
- data/samples/rails/po/de/gettext_plugin.po +1 -1
- data/samples/rails/po/el/blog.po +1 -1
- data/samples/rails/po/el/gettext_plugin.po +1 -1
- data/samples/rails/po/en/blog.po +1 -1
- data/samples/rails/po/es/blog.po +1 -2
- data/samples/rails/po/es/gettext_plugin.po +1 -1
- data/samples/rails/po/fr/blog.po +1 -1
- data/samples/rails/po/fr/gettext_plugin.po +1 -1
- data/samples/rails/po/gettext_plugin.pot +1 -1
- data/samples/rails/po/ja/blog.po +2 -1
- data/samples/rails/po/ja/gettext_plugin.po +1 -1
- data/samples/rails/po/ko/blog.po +1 -2
- data/samples/rails/po/ko/gettext_plugin.po +1 -1
- data/samples/rails/po/nl/blog.po +1 -3
- data/samples/rails/po/nl/gettext_plugin.po +1 -1
- data/samples/rails/po/pt_BR/blog.po +1 -1
- data/samples/rails/po/pt_BR/gettext_plugin.po +1 -1
- data/setup.rb +799 -574
- data/src/poparser.ry +6 -5
- data/test/gettext_runner.rb +3 -1
- data/test/gettext_test.rb +40 -24
- data/test/gettext_test_cgi.rb +60 -6
- data/test/gettext_test_locale.rb +136 -0
- data/test/gettext_test_parser.rb +12 -12
- data/test/locale/la/LC_MESSAGES/plural_error.mo +0 -0
- data/test/po/la/plural_error.po +21 -0
- data/test/test.bat +2 -0
- data/test/test.sh +2 -4
- data/test/test_rubyparser_n_.rb +64 -0
- metadata +24 -21
- data/ext/gettext/gettext/MANIFEST +0 -3
- data/ext/gettext/gettext/_locale-i386-mswin32.def +0 -2
- data/ext/gettext/gettext/_locale.exp +0 -0
- data/ext/gettext/gettext/_locale.lib +0 -0
- data/ext/gettext/gettext/_locale.obj +0 -0
- data/ext/gettext/gettext/_locale.so +0 -0
- data/ext/gettext/gettext/extconf.rb +0 -20
- data/ext/gettext/gettext/mkmf.log +0 -16
- data/lib/_locale.so +0 -0
- data/lib/gettext/locale_default.rb +0 -35
- data/po/it/messages.mo +0 -0
- data/samples/cgi/po/it/messages.mo +0 -0
data/lib/gettext/locale_win32.rb
CHANGED
@@ -1,55 +1,79 @@
|
|
1
1
|
=begin
|
2
|
-
locale_win32.rb
|
2
|
+
locale_win32.rb
|
3
3
|
|
4
|
-
Copyright (C) 2002
|
4
|
+
Copyright (C) 2002-2006 Masao Mutoh <mutoh@highway.ne.jp>
|
5
5
|
|
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.12 2006/02/20 16:12:05 mutoh Exp $
|
10
10
|
=end
|
11
11
|
|
12
12
|
require 'gettext/locale_table_win32'
|
13
13
|
|
14
|
-
module Locale
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
14
|
+
module Locale #:nodoc:
|
15
|
+
# Locale::SystemWin32 module for win32.
|
16
|
+
module SystemWin32
|
17
|
+
extend Locale::System
|
18
|
+
|
19
|
+
@@default_locale = Locale::Object.new("en", nil, "CP1252")
|
20
|
+
|
21
|
+
module_function
|
22
|
+
# Gets the charset of the locale. ENV(LC_ALL > LC_CTYPE > LC_MESSAGES > LANG) >
|
23
|
+
# the default locale from GetUserDefaultLangID.
|
24
|
+
# * locale: Locale::Object
|
25
|
+
# * Returns the charset of the locale
|
26
|
+
def get_charset(locale)
|
27
|
+
loc = LocaleTable.find{|v| v[1] == locale.to_win}
|
28
|
+
loc ? loc[2] : "CP1252"
|
29
|
+
end
|
30
|
+
|
31
|
+
# Gets the system locale.
|
32
|
+
# * Returns the system locale (Locale::Object)
|
33
|
+
def system
|
34
|
+
lang = nil
|
35
|
+
["LC_ALL", "LC_CTYPE", "LC_MESSAGES", "LANG"].each do |env|
|
36
|
+
lang = ENV[env]
|
37
|
+
if lang
|
38
|
+
ret = Locale::Object.new(lang)
|
39
|
+
ret.charset = get_charset(ret)
|
40
|
+
break
|
41
|
+
end
|
24
42
|
end
|
25
|
-
unless
|
26
|
-
|
27
|
-
lang
|
28
|
-
|
29
|
-
|
43
|
+
unless lang
|
44
|
+
lang = LocaleTable.assoc(locale_id)
|
45
|
+
if lang
|
46
|
+
ret = Locale::Object.new(lang[1], nil, lang[2])
|
47
|
+
else
|
48
|
+
ret = @@default_locale
|
30
49
|
end
|
31
|
-
ret = lang ? lang[1] : "C"
|
32
50
|
end
|
33
|
-
|
51
|
+
ret
|
34
52
|
end
|
35
|
-
ret
|
36
|
-
end
|
37
53
|
|
38
|
-
|
39
|
-
|
40
|
-
|
54
|
+
# Sets a default locale. en.UTF-8 is the default value if not set.
|
55
|
+
# * locale: Locale::Object object. You can't set nil.
|
56
|
+
# * Returns: self
|
57
|
+
def set_default_locale(locale)
|
58
|
+
raise "Wrong parameter: #{locale}" if locale.nil?
|
59
|
+
@@default_locale = locale
|
60
|
+
self
|
61
|
+
end
|
62
|
+
|
63
|
+
# Sets a default locale. en.UTF-8 is the default value if not set.
|
64
|
+
# * locale: Locale::Object
|
65
|
+
# * Returns: locale
|
66
|
+
def default_locale=(locale)
|
67
|
+
set_default_locale(locale)
|
68
|
+
locale
|
41
69
|
end
|
42
|
-
end
|
43
70
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
MONETARY = 4
|
50
|
-
MESSAGES = 5
|
51
|
-
ALL = 6
|
71
|
+
# Gets the default Locale::Object.
|
72
|
+
# * Returns: the default locale
|
73
|
+
def default_locale
|
74
|
+
@@default_locale
|
75
|
+
end
|
52
76
|
end
|
53
|
-
|
77
|
+
@@locale_system_module = SystemWin32
|
54
78
|
end
|
55
79
|
|
data/lib/gettext/mo.rb
CHANGED
@@ -12,12 +12,12 @@
|
|
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.3 2006/02/23 14:53:59 mutoh Exp $
|
16
16
|
=end
|
17
17
|
|
18
18
|
require 'gettext/iconv'
|
19
19
|
|
20
|
-
class MOFile < Hash
|
20
|
+
class MOFile < Hash #:nodoc:
|
21
21
|
class InvalidFormat < RuntimeError; end;
|
22
22
|
|
23
23
|
Header = Struct.new(:magic,
|
@@ -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.6 2006/02/22 16:42:41 mutoh Exp $
|
11
11
|
=end
|
12
12
|
|
13
13
|
require 'gettext'
|
@@ -31,7 +31,7 @@ module GetText
|
|
31
31
|
@ar_re = nil
|
32
32
|
|
33
33
|
module_function
|
34
|
-
def require_rails(file)
|
34
|
+
def require_rails(file) # :nodoc:
|
35
35
|
begin
|
36
36
|
require file
|
37
37
|
rescue MissingSourceFile
|
@@ -39,6 +39,16 @@ module GetText
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
# Sets some preferences to parse ActiveRecord files.
|
43
|
+
#
|
44
|
+
# * config: a Hash of the config. It can takes some values below:
|
45
|
+
# * :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.
|
46
|
+
# * :db_yml: the path of database.yml. Default is "config/database.yml".
|
47
|
+
# * :db_mode: the mode of the database. Default is "development"
|
48
|
+
# * :activerecord_classes: an Array of the superclass of the models. The classes should be String value. Default is ["ActiveRecord::Base"]
|
49
|
+
#
|
50
|
+
# "ClassName|FieldName" uses GetText.sgettext. So you don't need to translate the left-side of "|".
|
51
|
+
# See <Documents for Translators for more details(http://www.yotabanana.com/hiki/ruby-gettext-translate.html)>.
|
42
52
|
def init(config)
|
43
53
|
if config
|
44
54
|
config.each{|k, v|
|
@@ -48,7 +58,7 @@ module GetText
|
|
48
58
|
@ar_re = /class.*(#{@config[:activerecord_classes].join("|")})/
|
49
59
|
end
|
50
60
|
|
51
|
-
def parse(file, targets = [])
|
61
|
+
def parse(file, targets = []) # :nodoc:
|
52
62
|
old_constants = constants
|
53
63
|
begin
|
54
64
|
eval(open(file).read)
|
@@ -83,7 +93,7 @@ module GetText
|
|
83
93
|
targets
|
84
94
|
end
|
85
95
|
|
86
|
-
def target?(file)
|
96
|
+
def target?(file) # :nodoc:
|
87
97
|
init(nil) unless @ar_re
|
88
98
|
data = IO.readlines(file)
|
89
99
|
data.each do |v|
|
@@ -91,7 +101,11 @@ module GetText
|
|
91
101
|
unless @db
|
92
102
|
require 'rubygems'
|
93
103
|
require 'active_record'
|
94
|
-
|
104
|
+
begin
|
105
|
+
yml = YAML.load(ERB.new(IO.read(@config[:db_yml])).result)
|
106
|
+
rescue
|
107
|
+
return false
|
108
|
+
end
|
95
109
|
ENV["RAILS_ENV"] = @config[:db_mode]
|
96
110
|
require_rails 'config/boot.rb'
|
97
111
|
require_rails 'config/environment.rb'
|
data/lib/gettext/parser/erb.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: erb.rb,v 1.
|
9
|
+
$Id: erb.rb,v 1.4 2006/02/22 16:42:41 mutoh Exp $
|
10
10
|
=end
|
11
11
|
|
12
12
|
require 'erb'
|
@@ -19,18 +19,21 @@ module GetText
|
|
19
19
|
}
|
20
20
|
|
21
21
|
module_function
|
22
|
+
# Sets some preferences to parse ERB files.
|
23
|
+
# * config: a Hash of the config. It can takes some values below:
|
24
|
+
# * :extnames: An Array of target files extension. Default is [".rhtml"].
|
22
25
|
def init(config)
|
23
26
|
config.each{|k, v|
|
24
27
|
@config[k] = v
|
25
28
|
}
|
26
29
|
end
|
27
30
|
|
28
|
-
def parse(file, targets = [])
|
31
|
+
def parse(file, targets = []) # :nodoc:
|
29
32
|
erb = ERB.new(IO.readlines(file).join).src.split(/$/)
|
30
33
|
RubyParser.parse_lines(file, erb, targets)
|
31
34
|
end
|
32
35
|
|
33
|
-
def target?(file)
|
36
|
+
def target?(file) # :nodoc:
|
34
37
|
@config[:extnames].each do |v|
|
35
38
|
return true if File.extname(file) == v
|
36
39
|
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.4 2006/02/22 16:42:41 mutoh Exp $
|
10
10
|
=end
|
11
11
|
|
12
12
|
require 'cgi'
|
@@ -21,13 +21,13 @@ module GetText
|
|
21
21
|
TARGET2 = /(.*)<\/property>/
|
22
22
|
|
23
23
|
module_function
|
24
|
-
def parse(file, targets = [])
|
24
|
+
def parse(file, targets = []) # :nodoc:
|
25
25
|
lines = IO.readlines(file)
|
26
26
|
parse_lines(file, lines, targets)
|
27
27
|
end
|
28
28
|
|
29
29
|
#from ary of lines.
|
30
|
-
def parse_lines(file, lines, targets)
|
30
|
+
def parse_lines(file, lines, targets) # :nodoc:
|
31
31
|
cnt = 0
|
32
32
|
target = false
|
33
33
|
line_no = 0
|
@@ -65,7 +65,7 @@ module GetText
|
|
65
65
|
XML_RE = /<\?xml/
|
66
66
|
GLADE_RE = /glade-2.0.dtd/
|
67
67
|
|
68
|
-
def target?(file)
|
68
|
+
def target?(file) # :nodoc:
|
69
69
|
data = IO.readlines(file)
|
70
70
|
if XML_RE =~ data[0]
|
71
71
|
if GLADE_RE =~ data[1]
|
@@ -81,7 +81,7 @@ module GetText
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
-
def add_target(val, file, line_no, targets)
|
84
|
+
def add_target(val, file, line_no, targets) # :nodoc:
|
85
85
|
return unless val.size > 0
|
86
86
|
assoc_data = targets.assoc(val)
|
87
87
|
val = CGI.unescapeHTML(val)
|
data/lib/gettext/parser/ruby.rb
CHANGED
@@ -9,13 +9,13 @@
|
|
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.6 2006/02/22 16:42:41 mutoh Exp $
|
13
13
|
=end
|
14
14
|
|
15
15
|
require 'irb/ruby-lex.rb'
|
16
16
|
require 'stringio'
|
17
17
|
|
18
|
-
class RubyLexX < RubyLex
|
18
|
+
class RubyLexX < RubyLex # :nodoc: all
|
19
19
|
|
20
20
|
def initialize
|
21
21
|
super
|
@@ -124,15 +124,15 @@ end
|
|
124
124
|
module GetText
|
125
125
|
module RubyParser
|
126
126
|
ID = ['gettext', '_', 'N_', 'sgettext', 's_']
|
127
|
-
PLURAL_ID = ['ngettext', 'n_']
|
127
|
+
PLURAL_ID = ['ngettext', 'n_', 'Nn_']
|
128
128
|
|
129
129
|
module_function
|
130
|
-
def parse(file, targets = [])
|
130
|
+
def parse(file, targets = []) # :nodoc:
|
131
131
|
lines = IO.readlines(file)
|
132
132
|
parse_lines(file, lines, targets)
|
133
133
|
end
|
134
134
|
|
135
|
-
def parse_lines(file_name, lines, targets)
|
135
|
+
def parse_lines(file_name, lines, targets) # :nodoc:
|
136
136
|
file = StringIO.new(lines.join + "\n")
|
137
137
|
rl = RubyLexX.new
|
138
138
|
rl.set_input(file)
|
@@ -188,7 +188,7 @@ module GetText
|
|
188
188
|
targets
|
189
189
|
end
|
190
190
|
|
191
|
-
def target?(file)
|
191
|
+
def target?(file) # :nodoc:
|
192
192
|
true # always true, as default parser.
|
193
193
|
end
|
194
194
|
|
data/lib/gettext/poparser.rb
CHANGED
@@ -1,297 +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)
|
36
|
-
@comments = []
|
37
|
-
@data = data
|
38
|
-
@fuzzy = false
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
$stderr.print "
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
@comments.
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
@
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
0,
|
112
|
-
|
113
|
-
2, 9, :_reduce_none,
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
9,
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
:
|
164
|
-
:
|
165
|
-
:
|
166
|
-
:
|
167
|
-
:
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
'
|
192
|
-
'
|
193
|
-
'
|
194
|
-
'
|
195
|
-
'
|
196
|
-
'
|
197
|
-
'
|
198
|
-
'
|
199
|
-
'
|
200
|
-
'
|
201
|
-
'
|
202
|
-
'
|
203
|
-
'
|
204
|
-
'
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
$stderr.print "
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
$stderr.print "
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
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..id4a44ddde81', '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..id4a44ddde81
|
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
|