gettext 1.6.0-mswin32 → 1.7.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 (104) hide show
  1. data/ChangeLog +65 -0
  2. data/NEWS +20 -0
  3. data/README +9 -9
  4. data/Rakefile +4 -4
  5. data/data/locale/cs/LC_MESSAGES/rails.mo +0 -0
  6. data/data/locale/cs/LC_MESSAGES/rgettext.mo +0 -0
  7. data/data/locale/de/LC_MESSAGES/rails.mo +0 -0
  8. data/data/locale/de/LC_MESSAGES/rgettext.mo +0 -0
  9. data/data/locale/el/LC_MESSAGES/rails.mo +0 -0
  10. data/data/locale/el/LC_MESSAGES/rgettext.mo +0 -0
  11. data/data/locale/es/LC_MESSAGES/rails.mo +0 -0
  12. data/data/locale/es/LC_MESSAGES/rgettext.mo +0 -0
  13. data/data/locale/fr/LC_MESSAGES/rails.mo +0 -0
  14. data/data/locale/fr/LC_MESSAGES/rgettext.mo +0 -0
  15. data/data/locale/it/LC_MESSAGES/rails.mo +0 -0
  16. data/data/locale/it/LC_MESSAGES/rgettext.mo +0 -0
  17. data/data/locale/ja/LC_MESSAGES/rails.mo +0 -0
  18. data/data/locale/ja/LC_MESSAGES/rgettext.mo +0 -0
  19. data/data/locale/ko/LC_MESSAGES/rails.mo +0 -0
  20. data/data/locale/ko/LC_MESSAGES/rgettext.mo +0 -0
  21. data/data/locale/nl/LC_MESSAGES/rails.mo +0 -0
  22. data/data/locale/nl/LC_MESSAGES/rgettext.mo +0 -0
  23. data/data/locale/pt_BR/LC_MESSAGES/rails.mo +0 -0
  24. data/data/locale/pt_BR/LC_MESSAGES/rgettext.mo +0 -0
  25. data/data/locale/ru/LC_MESSAGES/rails.mo +0 -0
  26. data/data/locale/ru/LC_MESSAGES/rgettext.mo +0 -0
  27. data/data/locale/sv/LC_MESSAGES/rgettext.mo +0 -0
  28. data/data/locale/zh/LC_MESSAGES/rails.mo +0 -0
  29. data/data/locale/zh/LC_MESSAGES/rgettext.mo +0 -0
  30. data/ext/gettext/Makefile +178 -0
  31. data/ext/gettext/locale_system-i386-mswin32.def +2 -0
  32. data/ext/gettext/locale_system-i386-mswin32.exp +0 -0
  33. data/ext/gettext/locale_system-i386-mswin32.lib +0 -0
  34. data/ext/gettext/locale_system-i386-mswin32.pdb +0 -0
  35. data/ext/gettext/locale_system.obj +0 -0
  36. data/ext/gettext/locale_system.so +0 -0
  37. data/ext/gettext/mkmf.log +16 -0
  38. data/ext/gettext/vc70.pdb +0 -0
  39. data/lib/gettext.rb +38 -12
  40. data/lib/gettext/container.rb +2 -2
  41. data/lib/gettext/iconv.rb +2 -2
  42. data/lib/gettext/locale_cgi.rb +3 -2
  43. data/lib/gettext/locale_object.rb +8 -8
  44. data/lib/gettext/locale_posix.rb +2 -2
  45. data/lib/gettext/locale_table_win32.rb +3 -3
  46. data/lib/gettext/locale_win32.rb +2 -2
  47. data/lib/gettext/mo.rb +5 -2
  48. data/lib/gettext/parser/activerecord.rb +27 -17
  49. data/lib/gettext/parser/glade.rb +7 -11
  50. data/lib/gettext/parser/ruby.rb +2 -3
  51. data/lib/gettext/poparser.rb +298 -298
  52. data/lib/gettext/rails.rb +220 -85
  53. data/lib/gettext/rgettext.rb +2 -2
  54. data/lib/gettext/rmsgfmt.rb +3 -3
  55. data/lib/gettext/rmsgmerge.rb +2 -2
  56. data/lib/gettext/string.rb +2 -1
  57. data/lib/gettext/textdomain.rb +5 -2
  58. data/lib/gettext/textdomainmanager.rb +3 -3
  59. data/lib/gettext/version.rb +1 -1
  60. data/lib/locale_system.so +0 -0
  61. data/po/cs/rails.po +63 -22
  62. data/po/cs/rgettext.po +71 -37
  63. data/po/de/rails.po +54 -16
  64. data/po/de/rgettext.po +56 -22
  65. data/po/el/rails.po +54 -16
  66. data/po/el/rgettext.po +56 -22
  67. data/po/es/rails.po +57 -20
  68. data/po/es/rgettext.po +70 -30
  69. data/po/fr/rails.po +57 -19
  70. data/po/fr/rgettext.po +61 -25
  71. data/po/it/rails.po +54 -16
  72. data/po/it/rgettext.po +56 -22
  73. data/po/ja/rails.po +55 -18
  74. data/po/ja/rgettext.po +58 -24
  75. data/po/ko/rails.po +68 -33
  76. data/po/ko/rgettext.po +77 -37
  77. data/po/nl/rails.po +61 -22
  78. data/po/nl/rgettext.po +72 -36
  79. data/po/pt_BR/rails.po +54 -16
  80. data/po/pt_BR/rgettext.po +56 -22
  81. data/po/rails.pot +54 -16
  82. data/po/rgettext.pot +55 -21
  83. data/po/ru/rails.po +68 -26
  84. data/po/ru/rgettext.po +70 -30
  85. data/po/sv/rgettext.po +55 -21
  86. data/po/zh/rails.po +51 -16
  87. data/po/zh/rgettext.po +59 -23
  88. data/samples/rails/app/controllers/application.rb +7 -1
  89. data/samples/rails/app/models/article.rb +0 -6
  90. data/samples/rails/locale/cs/LC_MESSAGES/gettext_plugin.mo +0 -0
  91. data/samples/rails/locale/de/LC_MESSAGES/gettext_plugin.mo +0 -0
  92. data/samples/rails/locale/el/LC_MESSAGES/gettext_plugin.mo +0 -0
  93. data/samples/rails/locale/es/LC_MESSAGES/gettext_plugin.mo +0 -0
  94. data/samples/rails/locale/fr/LC_MESSAGES/gettext_plugin.mo +0 -0
  95. data/samples/rails/locale/ja/LC_MESSAGES/gettext_plugin.mo +0 -0
  96. data/samples/rails/locale/ko/LC_MESSAGES/gettext_plugin.mo +0 -0
  97. data/samples/rails/locale/nl/LC_MESSAGES/gettext_plugin.mo +0 -0
  98. data/samples/rails/locale/pt_BR/LC_MESSAGES/gettext_plugin.mo +0 -0
  99. data/samples/rails/locale/ru/LC_MESSAGES/gettext_plugin.mo +0 -0
  100. data/src/poparser.ry +1 -1
  101. data/test/gettext_test.rb +1 -1
  102. data/test/gettext_test_parser.rb +0 -1
  103. data/test/test_rubyparser.rb +0 -11
  104. metadata +21 -7
@@ -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.5 2006/06/04 14:43:37 mutoh Exp $
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 # :nodoc:
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.2 2006/02/22 16:42:41 mutoh Exp $
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
- # = Pseudo Iconv module
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
@@ -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.3 2006/03/07 17:26:57 mutoh Exp $
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 # :nodoc:
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.7 2006/03/03 07:03:50 mutoh Exp $
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 # :nodoc:
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
- # * Both of POSIX and C are converted to "en".
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
- # * <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.
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]
@@ -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.3 2006/06/07 15:56:04 mutoh Exp $
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 # :nodoc:
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.4 2006/02/20 16:07:36 mutoh Exp $
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 #:nodoc:
13
- module SystemWin32 #:nodoc:
12
+ module Locale
13
+ module SystemWin32
14
14
  #LangID, locale name, code page
15
15
  LocaleTable = [
16
16
  [0x0000, "en", "CP1252"],
@@ -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.13 2006/06/04 14:43:37 mutoh Exp $
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 #:nodoc:
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.6 2006/05/19 15:42:14 mutoh Exp $
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 #:nodoc:
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.9 2006/05/13 17:20:52 mutoh Exp $
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: 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"]
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
- add_target(targets, file, ::Inflector.singularize(klass.table_name.gsub(/_/, " ")))
74
- tablename = klass.class_name
75
- begin
76
- klass.columns.each do |column|
77
- if @config[:use_classname]
78
- msgid = tablename + "|" + klass.human_attribute_name(column.name)
79
- else
80
- msgid = klass.human_attribute_name(column.name)
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
- add_target(targets, file, msgid)
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
@@ -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.4 2006/02/22 16:42:41 mutoh Exp $
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
- if GLADE_RE =~ data[1]
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
- return false
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
 
@@ -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.6 2006/02/22 16:42:41 mutoh Exp $
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
 
@@ -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.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..id2c720ef3d7', '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..id2c720ef3d7
107
-
108
- ##### racc 1.4.4 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
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