gettext 1.1.1-mswin32 → 1.2.0-mswin32

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 (157) hide show
  1. data/ChangeLog +128 -0
  2. data/NEWS +10 -0
  3. data/README +21 -23
  4. data/Rakefile +40 -21
  5. data/bin/rgettext +1 -1
  6. data/bin/rmsgfmt +1 -1
  7. data/bin/rmsgmerge +1 -1
  8. data/data/locale/cs/LC_MESSAGES/rails.mo +0 -0
  9. data/data/locale/cs/LC_MESSAGES/rgettext.mo +0 -0
  10. data/data/locale/de/LC_MESSAGES/rails.mo +0 -0
  11. data/data/locale/de/LC_MESSAGES/rgettext.mo +0 -0
  12. data/data/locale/el/LC_MESSAGES/rails.mo +0 -0
  13. data/data/locale/el/LC_MESSAGES/rgettext.mo +0 -0
  14. data/data/locale/es/LC_MESSAGES/rails.mo +0 -0
  15. data/data/locale/es/LC_MESSAGES/rgettext.mo +0 -0
  16. data/data/locale/fr/LC_MESSAGES/rails.mo +0 -0
  17. data/data/locale/fr/LC_MESSAGES/rgettext.mo +0 -0
  18. data/data/locale/it/LC_MESSAGES/rgettext.mo +0 -0
  19. data/data/locale/ja/LC_MESSAGES/rails.mo +0 -0
  20. data/data/locale/ja/LC_MESSAGES/rgettext.mo +0 -0
  21. data/data/locale/ko/LC_MESSAGES/rails.mo +0 -0
  22. data/data/locale/ko/LC_MESSAGES/rgettext.mo +0 -0
  23. data/data/locale/nl/LC_MESSAGES/rails.mo +0 -0
  24. data/data/locale/nl/LC_MESSAGES/rgettext.mo +0 -0
  25. data/data/locale/pt_BR/LC_MESSAGES/rails.mo +0 -0
  26. data/data/locale/pt_BR/LC_MESSAGES/rgettext.mo +0 -0
  27. data/data/locale/sv/LC_MESSAGES/rgettext.mo +0 -0
  28. data/ext/gettext/{gettext/Makefile → Makefile} +3 -3
  29. data/ext/gettext/extconf.rb +20 -0
  30. data/ext/gettext/locale_system-i386-mswin32.def +2 -0
  31. data/ext/gettext/{gettext/_locale.c → locale_system.c} +15 -19
  32. data/ext/gettext/locale_system.exp +0 -0
  33. data/ext/gettext/locale_system.lib +0 -0
  34. data/ext/gettext/locale_system.obj +0 -0
  35. data/ext/gettext/{gettext/_locale.pdb → locale_system.pdb} +0 -0
  36. data/ext/gettext/locale_system.so +0 -0
  37. data/ext/gettext/mkmf.log +10 -0
  38. data/ext/gettext/{gettext/vc70.pdb → vc70.pdb} +0 -0
  39. data/lib/gettext.rb +186 -38
  40. data/lib/gettext/cgi.rb +35 -69
  41. data/lib/gettext/container.rb +14 -5
  42. data/lib/gettext/erb.rb +30 -2
  43. data/lib/gettext/iconv.rb +19 -4
  44. data/lib/gettext/locale.rb +188 -39
  45. data/lib/gettext/locale_cgi.rb +102 -0
  46. data/lib/gettext/locale_object.rb +131 -0
  47. data/lib/gettext/locale_posix.rb +50 -0
  48. data/lib/gettext/locale_table_win32.rb +224 -182
  49. data/lib/gettext/locale_win32.rb +59 -35
  50. data/lib/gettext/mo.rb +2 -2
  51. data/lib/gettext/parser/activerecord.rb +19 -5
  52. data/lib/gettext/parser/erb.rb +6 -3
  53. data/lib/gettext/parser/glade.rb +5 -5
  54. data/lib/gettext/parser/ruby.rb +6 -6
  55. data/lib/gettext/poparser.rb +298 -297
  56. data/lib/gettext/rails.rb +122 -44
  57. data/lib/gettext/rgettext.rb +21 -8
  58. data/lib/gettext/rmsgfmt.rb +16 -8
  59. data/lib/gettext/rmsgmerge.rb +172 -50
  60. data/lib/gettext/string.rb +25 -3
  61. data/lib/gettext/textdomain.rb +89 -90
  62. data/lib/gettext/utils.rb +63 -3
  63. data/lib/gettext/version.rb +2 -2
  64. data/lib/locale_system.so +0 -0
  65. data/po/cs/rails.po +28 -28
  66. data/po/cs/rgettext.po +14 -14
  67. data/po/de/rails.po +29 -26
  68. data/po/de/rgettext.po +24 -17
  69. data/po/el/rails.po +26 -26
  70. data/po/el/rgettext.po +18 -15
  71. data/po/es/rails.po +26 -26
  72. data/po/es/rgettext.po +16 -16
  73. data/po/fr/rails.po +27 -27
  74. data/po/fr/rgettext.po +14 -14
  75. data/po/it/rgettext.po +14 -14
  76. data/po/ja/rails.po +24 -24
  77. data/po/ja/rgettext.po +14 -14
  78. data/po/ko/rails.po +24 -24
  79. data/po/ko/rgettext.po +17 -18
  80. data/po/nl/rails.po +27 -27
  81. data/po/nl/rgettext.po +18 -18
  82. data/po/pt_BR/rails.po +26 -26
  83. data/po/pt_BR/rgettext.po +14 -14
  84. data/po/rails.pot +26 -26
  85. data/po/rgettext.pot +14 -14
  86. data/po/sv/rgettext.po +14 -14
  87. data/post-setup.rb +8 -3
  88. data/pre-setup.rb +14 -1
  89. data/samples/cgi/http.rb +2 -1
  90. data/samples/makemo.rb +1 -1
  91. data/samples/rails/app/models/article.rb +15 -1
  92. data/samples/rails/config/database.yml +1 -1
  93. data/samples/rails/locale/cs/LC_MESSAGES/blog.mo +0 -0
  94. data/samples/rails/locale/cs/LC_MESSAGES/gettext_plugin.mo +0 -0
  95. data/samples/rails/locale/de/LC_MESSAGES/blog.mo +0 -0
  96. data/samples/rails/locale/de/LC_MESSAGES/gettext_plugin.mo +0 -0
  97. data/samples/rails/locale/el/LC_MESSAGES/blog.mo +0 -0
  98. data/samples/rails/locale/el/LC_MESSAGES/gettext_plugin.mo +0 -0
  99. data/samples/rails/locale/en/LC_MESSAGES/blog.mo +0 -0
  100. data/samples/rails/locale/es/LC_MESSAGES/blog.mo +0 -0
  101. data/samples/rails/locale/es/LC_MESSAGES/gettext_plugin.mo +0 -0
  102. data/samples/rails/locale/fr/LC_MESSAGES/blog.mo +0 -0
  103. data/samples/rails/locale/fr/LC_MESSAGES/gettext_plugin.mo +0 -0
  104. data/samples/rails/locale/ja/LC_MESSAGES/blog.mo +0 -0
  105. data/samples/rails/locale/ja/LC_MESSAGES/gettext_plugin.mo +0 -0
  106. data/samples/rails/locale/ko/LC_MESSAGES/blog.mo +0 -0
  107. data/samples/rails/locale/ko/LC_MESSAGES/gettext_plugin.mo +0 -0
  108. data/samples/rails/locale/nl/LC_MESSAGES/blog.mo +0 -0
  109. data/samples/rails/locale/nl/LC_MESSAGES/gettext_plugin.mo +0 -0
  110. data/samples/rails/locale/pt_BR/LC_MESSAGES/blog.mo +0 -0
  111. data/samples/rails/locale/pt_BR/LC_MESSAGES/gettext_plugin.mo +0 -0
  112. data/samples/rails/po/blog.pot +1 -1
  113. data/samples/rails/po/cs/blog.po +1 -2
  114. data/samples/rails/po/cs/gettext_plugin.po +1 -1
  115. data/samples/rails/po/de/blog.po +1 -2
  116. data/samples/rails/po/de/gettext_plugin.po +1 -1
  117. data/samples/rails/po/el/blog.po +1 -1
  118. data/samples/rails/po/el/gettext_plugin.po +1 -1
  119. data/samples/rails/po/en/blog.po +1 -1
  120. data/samples/rails/po/es/blog.po +1 -2
  121. data/samples/rails/po/es/gettext_plugin.po +1 -1
  122. data/samples/rails/po/fr/blog.po +1 -1
  123. data/samples/rails/po/fr/gettext_plugin.po +1 -1
  124. data/samples/rails/po/gettext_plugin.pot +1 -1
  125. data/samples/rails/po/ja/blog.po +2 -1
  126. data/samples/rails/po/ja/gettext_plugin.po +1 -1
  127. data/samples/rails/po/ko/blog.po +1 -2
  128. data/samples/rails/po/ko/gettext_plugin.po +1 -1
  129. data/samples/rails/po/nl/blog.po +1 -3
  130. data/samples/rails/po/nl/gettext_plugin.po +1 -1
  131. data/samples/rails/po/pt_BR/blog.po +1 -1
  132. data/samples/rails/po/pt_BR/gettext_plugin.po +1 -1
  133. data/setup.rb +799 -574
  134. data/src/poparser.ry +6 -5
  135. data/test/gettext_runner.rb +3 -1
  136. data/test/gettext_test.rb +40 -24
  137. data/test/gettext_test_cgi.rb +60 -6
  138. data/test/gettext_test_locale.rb +136 -0
  139. data/test/gettext_test_parser.rb +12 -12
  140. data/test/locale/la/LC_MESSAGES/plural_error.mo +0 -0
  141. data/test/po/la/plural_error.po +21 -0
  142. data/test/test.bat +2 -0
  143. data/test/test.sh +2 -4
  144. data/test/test_rubyparser_n_.rb +64 -0
  145. metadata +24 -21
  146. data/ext/gettext/gettext/MANIFEST +0 -3
  147. data/ext/gettext/gettext/_locale-i386-mswin32.def +0 -2
  148. data/ext/gettext/gettext/_locale.exp +0 -0
  149. data/ext/gettext/gettext/_locale.lib +0 -0
  150. data/ext/gettext/gettext/_locale.obj +0 -0
  151. data/ext/gettext/gettext/_locale.so +0 -0
  152. data/ext/gettext/gettext/extconf.rb +0 -20
  153. data/ext/gettext/gettext/mkmf.log +0 -16
  154. data/lib/_locale.so +0 -0
  155. data/lib/gettext/locale_default.rb +0 -35
  156. data/po/it/messages.mo +0 -0
  157. data/samples/cgi/po/it/messages.mo +0 -0
@@ -1,55 +1,79 @@
1
1
  =begin
2
- locale_win32.rb - Locale module for win32.
2
+ locale_win32.rb
3
3
 
4
- Copyright (C) 2002,2003 Masao Mutoh <mutoh@highway.ne.jp>
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.4 2005/12/29 07:02:52 mutoh Exp $
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
- @@locale_win32 = {}
16
- def __get(lctype = Locale::CTYPE)
17
- ret = nil
18
- if @@locale_win32[lctype]
19
- ret = @@locale_win32[lctype]
20
- else
21
- ["LC_ALL", "LC_MESSAGES", "LANG"].each do |env|
22
- ret = ENV[env]
23
- break if ret
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 ret
26
- pri_id, sub_id = __locale_id
27
- lang = LocaleTable.assoc(pri_id)
28
- if lang.size == 3
29
- lang = lang[2].assoc(sub_id)
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
- @@locale_win32[lctype] = ret
51
+ ret
34
52
  end
35
- ret
36
- end
37
53
 
38
- def set(lctype, loc)
39
- if lctype == ALL
40
- @@locale_win32[lctype] = loc
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
- unless defined? CTYPE
45
- CTYPE = 0
46
- NUMERIC = 1
47
- TIME = 2
48
- COLLATE = 3
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
- module_function :__get
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.2 2005/10/22 10:49:59 mutoh Exp $
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.5 2006/01/14 13:48:23 mutoh Exp $
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
- yml = YAML.load(ERB.new(IO.read(@config[:db_yml])).result)
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'
@@ -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.3 2006/01/07 13:39:13 mutoh Exp $
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
@@ -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.3 2006/01/07 13:39:13 mutoh Exp $
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)
@@ -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.4 2005/12/17 07:12:40 mutoh Exp $
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
 
@@ -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.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..id827ea1cb71', '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)
36
- @comments = []
37
- @data = data
38
- @fuzzy = false
39
- str.strip!
40
- @q = []
41
- until str.empty? do
42
- case str
43
- when /\A\s+/
44
- str = $'
45
- when /\Amsgid_plural/
46
- @q.push [:MSGID_PLURAL, $&]
47
- str = $'
48
- when /\Amsgid/
49
- @q.push [:MSGID, $&]
50
- str = $'
51
- when /\Amsgstr/
52
- @q.push [:MSGSTR, $&]
53
- str = $'
54
- when /\A\[(\d+)\]/
55
- @q.push [:PLURAL_NUM, $1]
56
- str = $'
57
- when /\A\#~(.*)/
58
- $stderr.print _("Warning: obsolete msgid is existed.\n")
59
- $stderr.print " #{$&}\n"
60
- @q.push [:COMMENT, $&]
61
- str = $'
62
- when /\A\#(.*)/
63
- @q.push [:COMMENT, $&]
64
- str = $'
65
- when /\A\"(.*)\"/
66
- @q.push [:STRING, $1]
67
- str = $'
68
- else
69
- #c = str[0,1]
70
- #@q.push [:STRING, c]
71
- str = str[1..-1]
72
- end
73
- end
74
- @q.push [false, '$end']
75
- if $DEBUG
76
- @q.each do |a,b|
77
- puts "[#{a}, #{b}]"
78
- end
79
- end
80
- @yydebug = true if $DEBUG
81
- do_parse
82
-
83
- if @comments.size > 0
84
- @data.set_comment(:last, @comments.join("\n"))
85
- end
86
- @data
87
- end
88
-
89
- def next_token
90
- @q.shift
91
- end
92
-
93
- def on_message(msgid, msgstr)
94
- @data[msgid] = msgstr
95
-
96
- @data.set_comment(msgid, @comments.join("\n"))
97
- @comments.clear
98
- end
99
-
100
- def on_comment(comment)
101
- @fuzzy = true if (/fuzzy/ =~ comment)
102
- @comments << comment
103
- end
104
-
105
- ..end src/poparser.ry modeval..id827ea1cb71
106
-
107
- ##### racc 1.4.4 generates ###
108
-
109
- racc_reduce_table = [
110
- 0, 0, :racc_error,
111
- 0, 9, :_reduce_none,
112
- 2, 9, :_reduce_none,
113
- 2, 9, :_reduce_none,
114
- 4, 11, :_reduce_4,
115
- 5, 11, :_reduce_5,
116
- 2, 13, :_reduce_6,
117
- 1, 13, :_reduce_none,
118
- 3, 14, :_reduce_8,
119
- 1, 10, :_reduce_9,
120
- 2, 12, :_reduce_10,
121
- 1, 12, :_reduce_11 ]
122
-
123
- racc_reduce_n = 12
124
-
125
- racc_shift_n = 21
126
-
127
- racc_action_table = [
128
- 3, 9, 4, 5, 10, 11, 12, 17, 12, 9,
129
- 9, 7, 12, 17, 19, 9, 12 ]
130
-
131
- racc_action_check = [
132
- 1, 5, 1, 1, 8, 8, 8, 13, 13, 10,
133
- 11, 3, 14, 15, 17, 19, 20 ]
134
-
135
- racc_action_pointer = [
136
- nil, 0, nil, 11, nil, -5, nil, nil, 0, nil,
137
- 3, 4, nil, 2, 6, 8, nil, 7, nil, 9,
138
- 10 ]
139
-
140
- racc_action_default = [
141
- -1, -12, -3, -12, -9, -12, -2, 21, -12, -11,
142
- -12, -12, -10, -12, -4, -5, -7, -12, -6, -12,
143
- -8 ]
144
-
145
- racc_goto_table = [
146
- 8, 16, 2, 18, 6, 13, 14, 15, 1, nil,
147
- nil, nil, nil, nil, 20 ]
148
-
149
- racc_goto_check = [
150
- 4, 6, 3, 6, 2, 4, 4, 5, 1, nil,
151
- nil, nil, nil, nil, 4 ]
152
-
153
- racc_goto_pointer = [
154
- nil, 8, 3, 1, -5, -6, -12 ]
155
-
156
- racc_goto_default = [
157
- nil, nil, nil, nil, nil, nil, nil ]
158
-
159
- racc_token_table = {
160
- false => 0,
161
- Object.new => 1,
162
- :COMMENT => 2,
163
- :MSGID => 3,
164
- :MSGID_PLURAL => 4,
165
- :MSGSTR => 5,
166
- :STRING => 6,
167
- :PLURAL_NUM => 7 }
168
-
169
- racc_use_result_var = true
170
-
171
- racc_nt_base = 8
172
-
173
- Racc_arg = [
174
- racc_action_table,
175
- racc_action_check,
176
- racc_action_default,
177
- racc_action_pointer,
178
- racc_goto_table,
179
- racc_goto_check,
180
- racc_goto_default,
181
- racc_goto_pointer,
182
- racc_nt_base,
183
- racc_reduce_table,
184
- racc_token_table,
185
- racc_shift_n,
186
- racc_reduce_n,
187
- racc_use_result_var ]
188
-
189
- Racc_token_to_s_table = [
190
- '$end',
191
- 'error',
192
- 'COMMENT',
193
- 'MSGID',
194
- 'MSGID_PLURAL',
195
- 'MSGSTR',
196
- 'STRING',
197
- 'PLURAL_NUM',
198
- '$start',
199
- 'msgfmt',
200
- 'comment',
201
- 'message',
202
- 'string_list',
203
- 'msgstr_plural',
204
- 'msgstr_plural_line']
205
-
206
- Racc_debug_parser = true
207
-
208
- ##### racc system variables end #####
209
-
210
- # reduce 0 omitted
211
-
212
- # reduce 1 omitted
213
-
214
- # reduce 2 omitted
215
-
216
- # reduce 3 omitted
217
-
218
- module_eval <<'.,.,', 'src/poparser.ry', 36
219
- def _reduce_4( val, _values, result )
220
- if @fuzzy
221
- if val[1] != ""
222
- $stderr.print _("Warning: fuzzy message was ignored.\n")
223
- $stderr.print " msgid '#{val[1]}'\n"
224
- else
225
- on_message('', unescape(val[3]))
226
- end
227
- @fuzzy = false
228
- else
229
- on_message(unescape(val[1]), unescape(val[3]))
230
- end
231
- result = ""
232
- result
233
- end
234
- .,.,
235
-
236
- module_eval <<'.,.,', 'src/poparser.ry', 51
237
- def _reduce_5( val, _values, result )
238
- if @fuzzy
239
- if val[1] != ""
240
- $stderr.print _("Warning: fuzzy message was ignored.\n")
241
- $stderr.print "msgid = '#{val[1]}\n"
242
- else
243
- on_message('', unescape(val[3]))
244
- end
245
- @fuzzy = false
246
- else
247
- on_message(unescape(val[1]) + "\000" + unescape(val[3]), unescape(val[4]))
248
- end
249
- result = ""
250
- result
251
- end
252
- .,.,
253
-
254
- module_eval <<'.,.,', 'src/poparser.ry', 58
255
- def _reduce_6( val, _values, result )
256
- result = val[0] + "\000" + val[1]
257
- result
258
- end
259
- .,.,
260
-
261
- # reduce 7 omitted
262
-
263
- module_eval <<'.,.,', 'src/poparser.ry', 66
264
- def _reduce_8( val, _values, result )
265
- result = val[2]
266
- result
267
- end
268
- .,.,
269
-
270
- module_eval <<'.,.,', 'src/poparser.ry', 73
271
- def _reduce_9( val, _values, result )
272
- on_comment(val[0])
273
- result
274
- end
275
- .,.,
276
-
277
- module_eval <<'.,.,', 'src/poparser.ry', 81
278
- def _reduce_10( val, _values, result )
279
- result = val.delete_if{|item| item == ""}.join
280
- result
281
- end
282
- .,.,
283
-
284
- module_eval <<'.,.,', 'src/poparser.ry', 85
285
- def _reduce_11( val, _values, result )
286
- result = val[0]
287
- result
288
- end
289
- .,.,
290
-
291
- def _reduce_none( val, _values, result )
292
- result
293
- end
294
-
295
- end # class PoParser
296
-
297
- 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..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