gettext 1.5.0-mswin32 → 1.6.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 (231) hide show
  1. data/ChangeLog +113 -0
  2. data/NEWS +17 -1
  3. data/README +56 -46
  4. data/Rakefile +7 -3
  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/locale_system.c +3 -3
  31. data/lib/gettext.rb +149 -98
  32. data/lib/gettext/container.rb +3 -23
  33. data/lib/gettext/erb.rb +2 -2
  34. data/lib/gettext/locale_posix.rb +37 -5
  35. data/lib/gettext/locale_win32.rb +2 -1
  36. data/lib/gettext/mo.rb +6 -4
  37. data/lib/gettext/parser/activerecord.rb +7 -3
  38. data/lib/gettext/poparser.rb +298 -298
  39. data/lib/gettext/rails.rb +131 -112
  40. data/lib/gettext/rgettext.rb +3 -1
  41. data/lib/gettext/rmsgfmt.rb +3 -1
  42. data/lib/gettext/rmsgmerge.rb +3 -1
  43. data/lib/gettext/textdomain.rb +14 -8
  44. data/lib/gettext/textdomainmanager.rb +103 -0
  45. data/lib/gettext/version.rb +1 -1
  46. data/po/cs/rails.po +16 -16
  47. data/po/cs/rgettext.po +7 -3
  48. data/po/de/rails.po +16 -16
  49. data/po/de/rgettext.po +7 -3
  50. data/po/el/rails.po +16 -16
  51. data/po/el/rgettext.po +7 -3
  52. data/po/es/rails.po +16 -16
  53. data/po/es/rgettext.po +7 -3
  54. data/po/fr/rails.po +16 -16
  55. data/po/fr/rgettext.po +7 -3
  56. data/po/it/rails.po +79 -0
  57. data/po/it/rgettext.po +42 -32
  58. data/po/ja/rails.po +20 -18
  59. data/po/ja/rgettext.po +7 -3
  60. data/po/ko/rails.po +16 -16
  61. data/po/ko/rgettext.po +7 -3
  62. data/po/nl/rails.po +16 -16
  63. data/po/nl/rgettext.po +7 -3
  64. data/po/pt_BR/rails.po +16 -16
  65. data/po/pt_BR/rgettext.po +7 -3
  66. data/po/rails.pot +16 -16
  67. data/po/rgettext.pot +7 -3
  68. data/po/ru/rails.po +18 -18
  69. data/po/ru/rgettext.po +13 -9
  70. data/po/sv/rgettext.po +7 -3
  71. data/po/zh/rails.po +78 -0
  72. data/po/zh/rgettext.po +104 -0
  73. data/pre-setup.rb +1 -4
  74. data/samples/cgi/helloerb.rhtml +1 -0
  75. data/samples/cgi/locale/zh/LC_MESSAGES/helloerb1.mo +0 -0
  76. data/samples/cgi/locale/zh/LC_MESSAGES/helloerb2.mo +0 -0
  77. data/samples/cgi/locale/zh/LC_MESSAGES/hellolib.mo +0 -0
  78. data/samples/cgi/locale/zh/LC_MESSAGES/main.mo +0 -0
  79. data/samples/cgi/po/zh/helloerb1.po +60 -0
  80. data/samples/cgi/po/zh/helloerb2.po +52 -0
  81. data/samples/cgi/po/zh/hellolib.po +24 -0
  82. data/samples/cgi/po/zh/main.po +80 -0
  83. data/samples/hello.rb +28 -5
  84. data/samples/hello2.rb +13 -6
  85. data/samples/hello_noop.rb +20 -8
  86. data/samples/hello_plural.rb +16 -6
  87. data/samples/hello_textdomain.rb +13 -4
  88. data/samples/hellogtk.rb +5 -4
  89. data/samples/hellogtk2.rb +5 -6
  90. data/samples/locale/cs/LC_MESSAGES/hello2.mo +0 -0
  91. data/samples/locale/cs/LC_MESSAGES/hello_plural.mo +0 -0
  92. data/samples/locale/de/LC_MESSAGES/hello2.mo +0 -0
  93. data/samples/locale/de/LC_MESSAGES/hello_plural.mo +0 -0
  94. data/samples/locale/el/LC_MESSAGES/hello2.mo +0 -0
  95. data/samples/locale/el/LC_MESSAGES/hello_plural.mo +0 -0
  96. data/samples/locale/es/LC_MESSAGES/hello2.mo +0 -0
  97. data/samples/locale/es/LC_MESSAGES/hello_plural.mo +0 -0
  98. data/samples/locale/fr/LC_MESSAGES/hello2.mo +0 -0
  99. data/samples/locale/fr/LC_MESSAGES/hello_plural.mo +0 -0
  100. data/samples/locale/it/LC_MESSAGES/hello2.mo +0 -0
  101. data/samples/locale/it/LC_MESSAGES/hello_plural.mo +0 -0
  102. data/samples/locale/ja/LC_MESSAGES/hello2.mo +0 -0
  103. data/samples/locale/ja/LC_MESSAGES/hello_plural.mo +0 -0
  104. data/samples/locale/ko/LC_MESSAGES/hello2.mo +0 -0
  105. data/samples/locale/ko/LC_MESSAGES/hello_plural.mo +0 -0
  106. data/samples/locale/nl/LC_MESSAGES/hello2.mo +0 -0
  107. data/samples/locale/nl/LC_MESSAGES/hello_plural.mo +0 -0
  108. data/samples/locale/pt_BR/LC_MESSAGES/hello2.mo +0 -0
  109. data/samples/locale/pt_BR/LC_MESSAGES/hello_plural.mo +0 -0
  110. data/samples/locale/ru/LC_MESSAGES/hello2.mo +0 -0
  111. data/samples/locale/ru/LC_MESSAGES/hello_plural.mo +0 -0
  112. data/samples/locale/sv/LC_MESSAGES/hello2.mo +0 -0
  113. data/samples/locale/sv/LC_MESSAGES/hello_plural.mo +0 -0
  114. data/samples/locale/zh/LC_MESSAGES/hello.mo +0 -0
  115. data/samples/locale/zh/LC_MESSAGES/hello2.mo +0 -0
  116. data/samples/locale/zh/LC_MESSAGES/hello_noop.mo +0 -0
  117. data/samples/locale/zh/LC_MESSAGES/hello_plural.mo +0 -0
  118. data/samples/locale/zh/LC_MESSAGES/helloglade2.mo +0 -0
  119. data/samples/locale/zh/LC_MESSAGES/hellogtk.mo +0 -0
  120. data/samples/locale/zh/LC_MESSAGES/hellotk.mo +0 -0
  121. data/samples/po/cs/hello2.po +4 -4
  122. data/samples/po/cs/hello_plural.po +5 -5
  123. data/samples/po/de/hello2.po +4 -4
  124. data/samples/po/de/hello_plural.po +9 -6
  125. data/samples/po/el/hello2.po +4 -4
  126. data/samples/po/el/hello_plural.po +3 -3
  127. data/samples/po/es/hello2.po +4 -4
  128. data/samples/po/es/hello_plural.po +6 -6
  129. data/samples/po/fr/hello2.po +4 -4
  130. data/samples/po/fr/hello_plural.po +3 -3
  131. data/samples/po/hello2.pot +2 -2
  132. data/samples/po/hello_plural.pot +1 -1
  133. data/samples/po/it/hello2.po +4 -4
  134. data/samples/po/it/hello_plural.po +4 -5
  135. data/samples/po/ja/hello2.po +4 -4
  136. data/samples/po/ja/hello_plural.po +4 -5
  137. data/samples/po/ko/hello2.po +4 -4
  138. data/samples/po/ko/hello_plural.po +10 -7
  139. data/samples/po/nl/hello2.po +4 -4
  140. data/samples/po/nl/hello_plural.po +6 -7
  141. data/samples/po/pt_BR/hello2.po +4 -4
  142. data/samples/po/pt_BR/hello_plural.po +6 -6
  143. data/samples/po/ru/hello2.po +4 -4
  144. data/samples/po/ru/hello_plural.po +10 -7
  145. data/samples/po/sv/hello2.po +4 -4
  146. data/samples/po/sv/hello_plural.po +4 -4
  147. data/samples/po/zh/hello.po +23 -0
  148. data/samples/po/zh/hello2.po +31 -0
  149. data/samples/po/zh/hello_noop.po +27 -0
  150. data/samples/po/zh/hello_plural.po +25 -0
  151. data/samples/po/zh/helloglade2.po +31 -0
  152. data/samples/po/zh/hellogtk.po +23 -0
  153. data/samples/po/zh/hellotk.po +23 -0
  154. data/samples/rails/README +2 -2
  155. data/samples/rails/lib/tasks/gettext.rake +0 -3
  156. data/samples/rails/locale/cs/LC_MESSAGES/blog.mo +0 -0
  157. data/samples/rails/locale/de/LC_MESSAGES/blog.mo +0 -0
  158. data/samples/rails/locale/el/LC_MESSAGES/blog.mo +0 -0
  159. data/samples/rails/locale/en/LC_MESSAGES/blog.mo +0 -0
  160. data/samples/rails/locale/es/LC_MESSAGES/blog.mo +0 -0
  161. data/samples/rails/locale/fr/LC_MESSAGES/blog.mo +0 -0
  162. data/samples/rails/locale/it/LC_MESSAGES/blog.mo +0 -0
  163. data/samples/rails/locale/ja/LC_MESSAGES/blog.mo +0 -0
  164. data/samples/rails/locale/ko/LC_MESSAGES/blog.mo +0 -0
  165. data/samples/rails/locale/nl/LC_MESSAGES/blog.mo +0 -0
  166. data/samples/rails/locale/pt_BR/LC_MESSAGES/blog.mo +0 -0
  167. data/samples/rails/locale/ru/LC_MESSAGES/blog.mo +0 -0
  168. data/samples/rails/locale/zh/LC_MESSAGES/blog.mo +0 -0
  169. data/samples/rails/po/blog.pot +1 -1
  170. data/samples/rails/po/cs/blog.po +1 -1
  171. data/samples/rails/po/de/blog.po +1 -1
  172. data/samples/rails/po/el/blog.po +1 -1
  173. data/samples/rails/po/en/blog.po +3 -3
  174. data/samples/rails/po/es/blog.po +1 -1
  175. data/samples/rails/po/fr/blog.po +1 -1
  176. data/samples/rails/po/it/blog.po +109 -0
  177. data/samples/rails/po/ja/blog.po +1 -14
  178. data/samples/rails/po/ko/blog.po +2 -2
  179. data/samples/rails/po/nl/blog.po +1 -1
  180. data/samples/rails/po/pt_BR/blog.po +1 -1
  181. data/samples/rails/po/ru/blog.po +1 -2
  182. data/samples/rails/po/zh/blog.po +109 -0
  183. data/samples/rails/vendor/plugins/gettext/README +17 -0
  184. data/samples/rails/vendor/plugins/gettext/Rakefile +17 -0
  185. data/samples/rails/vendor/plugins/gettext/lib/gettext_plugin.rb +16 -35
  186. data/samples/rails/{locale → vendor/plugins/gettext/locale}/cs/LC_MESSAGES/gettext_plugin.mo +0 -0
  187. data/samples/rails/{locale → vendor/plugins/gettext/locale}/de/LC_MESSAGES/gettext_plugin.mo +0 -0
  188. data/samples/rails/{locale → vendor/plugins/gettext/locale}/el/LC_MESSAGES/gettext_plugin.mo +0 -0
  189. data/samples/rails/{locale → vendor/plugins/gettext/locale}/es/LC_MESSAGES/gettext_plugin.mo +0 -0
  190. data/samples/rails/{locale → vendor/plugins/gettext/locale}/fr/LC_MESSAGES/gettext_plugin.mo +0 -0
  191. data/samples/rails/vendor/plugins/gettext/locale/it/LC_MESSAGES/gettext_plugin.mo +0 -0
  192. data/samples/rails/{locale → vendor/plugins/gettext/locale}/ja/LC_MESSAGES/gettext_plugin.mo +0 -0
  193. data/samples/rails/{locale → vendor/plugins/gettext/locale}/ko/LC_MESSAGES/gettext_plugin.mo +0 -0
  194. data/samples/rails/{locale → vendor/plugins/gettext/locale}/nl/LC_MESSAGES/gettext_plugin.mo +0 -0
  195. data/samples/rails/{locale → vendor/plugins/gettext/locale}/pt_BR/LC_MESSAGES/gettext_plugin.mo +0 -0
  196. data/samples/rails/{locale → vendor/plugins/gettext/locale}/ru/LC_MESSAGES/gettext_plugin.mo +0 -0
  197. data/samples/rails/vendor/plugins/gettext/locale/zh/LC_MESSAGES/gettext_plugin.mo +0 -0
  198. data/samples/rails/{po → vendor/plugins/gettext/po}/cs/gettext_plugin.po +4 -4
  199. data/samples/rails/{po → vendor/plugins/gettext/po}/de/gettext_plugin.po +4 -4
  200. data/samples/rails/{po → vendor/plugins/gettext/po}/el/gettext_plugin.po +4 -4
  201. data/samples/rails/{po → vendor/plugins/gettext/po}/es/gettext_plugin.po +4 -4
  202. data/samples/rails/{po → vendor/plugins/gettext/po}/fr/gettext_plugin.po +4 -4
  203. data/samples/rails/{po → vendor/plugins/gettext/po}/gettext_plugin.pot +4 -4
  204. data/samples/rails/vendor/plugins/gettext/po/it/gettext_plugin.po +27 -0
  205. data/samples/rails/{po → vendor/plugins/gettext/po}/ja/gettext_plugin.po +4 -4
  206. data/samples/rails/{po → vendor/plugins/gettext/po}/ko/gettext_plugin.po +4 -4
  207. data/samples/rails/{po → vendor/plugins/gettext/po}/nl/gettext_plugin.po +4 -4
  208. data/samples/rails/{po → vendor/plugins/gettext/po}/pt_BR/gettext_plugin.po +4 -4
  209. data/samples/rails/{po → vendor/plugins/gettext/po}/ru/gettext_plugin.po +4 -5
  210. data/samples/rails/vendor/plugins/gettext/po/zh/gettext_plugin.po +27 -0
  211. data/test/gettext_test.rb +18 -14
  212. data/test/gettext_test_multi_textdomain.rb +49 -0
  213. data/test/locale/fr/LC_MESSAGES/test6.mo +0 -0
  214. data/test/locale/ja/LC_MESSAGES/test6.mo +0 -0
  215. data/test/po/fr/test6.po +23 -0
  216. data/test/po/ja/test6.po +23 -0
  217. data/test/test.sh +3 -1
  218. data/test/testlib1.rb +0 -5
  219. data/test/testlib5.rb +70 -0
  220. data/test/testlib6.rb +19 -0
  221. metadata +128 -33
  222. data/COPYING.ja +0 -51
  223. data/ext/gettext/Makefile +0 -178
  224. data/ext/gettext/locale_system-i386-mswin32.def +0 -2
  225. data/ext/gettext/locale_system.exp +0 -0
  226. data/ext/gettext/locale_system.lib +0 -0
  227. data/ext/gettext/locale_system.obj +0 -0
  228. data/ext/gettext/locale_system.pdb +0 -0
  229. data/ext/gettext/locale_system.so +0 -0
  230. data/ext/gettext/mkmf.log +0 -16
  231. data/ext/gettext/vc70.pdb +0 -0
@@ -6,34 +6,14 @@
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.4 2006/02/23 14:53:59 mutoh Exp $
9
+ $Id: container.rb,v 1.5 2006/06/04 14:43:37 mutoh Exp $
10
10
  =end
11
11
 
12
12
  require 'gettext'
13
13
 
14
- module GetText
15
- # This module is used instead of GetText module. This module provides same functions as GetText module.
16
- #
17
- # Normaly, GetText.bindtexdomain should be called once a ruby-script-file.
18
- # But if the class includes GetText::Container, a TextDomain is bound to an instance of the class.
19
- # So you don't need to call bindtextdomain in each files if the files define a class.
20
- #
21
- # This module is useful for application-side classes, but you shouldn't use this for libraries.
22
- # Because the user of your library may override/add new features to the original library and the
23
- # user needs to prepare another TextDomain(Otherwise, apply po/mo patch to the original library).
14
+ module GetText # :nodoc:
15
+ # Deprecated. You don't need this. Use GetText instead.
24
16
  module Container
25
17
  include GetText
26
-
27
- alias :_bindtextdomain :bindtextdomain #:nodoc:
28
-
29
- def bindtextdomain(domainname, path = nil, locale = nil, charset = nil) #:nodoc:
30
- @gettext_container_domainname = domainname
31
- _bindtextdomain(domainname, path, locale, charset)
32
- end
33
-
34
- def callersrc #:nodoc:
35
- @gettext_container_domainname
36
- end
37
-
38
18
  end
39
19
  end
data/lib/gettext/erb.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: erb.rb,v 1.2 2006/02/23 14:53:59 mutoh Exp $
9
+ $Id: erb.rb,v 1.3 2006/06/04 14:43:37 mutoh Exp $
10
10
  =end
11
11
 
12
12
  require 'erb'
13
- require 'gettext/container'
13
+ require 'gettext'
14
14
 
15
15
  module GetText
16
16
 
@@ -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: locale_posix.rb,v 1.1 2006/02/20 12:35:06 mutoh Exp $
9
+ $Id: locale_posix.rb,v 1.3 2006/06/07 15:56:04 mutoh Exp $
10
10
  =end
11
11
 
12
12
 
@@ -16,12 +16,20 @@ module Locale # :nodoc:
16
16
  module SystemPosix
17
17
  extend Locale::System
18
18
  module_function
19
+ @@default_locale = Locale::Object.new("C", nil, "UTF-8")
20
+
19
21
  # Gets the system locale using setlocale and nl_langinfo.
20
22
  # * Returns the system locale (Locale::Object).
21
23
  def system
22
- old = set(Locale::System::CTYPE, nil)
23
- locale = Locale::Object.new(set(Locale::System::CTYPE, ""), nil, codeset)
24
- set(Locale::System::CTYPE, old)
24
+ locale = nil
25
+ [ENV["LC_ALL"], ENV["LC_MESSAGES"], ENV["LANG"],
26
+ @@default_locale.orig_str].each do |loc|
27
+ if loc != nil and loc.size > 0
28
+ locale = Locale::Object.new(loc)
29
+ locale.charset = get_charset(locale)
30
+ break
31
+ end
32
+ end
25
33
  locale
26
34
  end
27
35
 
@@ -36,7 +44,31 @@ module Locale # :nodoc:
36
44
  ret
37
45
  end
38
46
  end
39
- if defined? Locale::System::CTYPE
47
+
48
+ # Sets a default locale. en.UTF-8 is the default value if not set.
49
+ # * locale: Locale::Object object. You can't set nil.
50
+ # * Returns: self
51
+ def set_default_locale(locale)
52
+ raise "Wrong parameter: #{locale}" if locale.nil?
53
+ @@default_locale = locale
54
+ self
55
+ end
56
+
57
+ # Sets a default locale. en.UTF-8 is the default value if not set.
58
+ # * locale: Locale::Object
59
+ # * Returns: locale
60
+ def default_locale=(locale)
61
+ set_default_locale(locale)
62
+ locale
63
+ end
64
+
65
+ # Gets the default Locale::Object.
66
+ # * Returns: the default locale
67
+ def default_locale
68
+ @@default_locale
69
+ end
70
+
71
+ if defined? Locale::System::MESSAGES
40
72
  CTYPE = Locale::System::CTYPE #:nodoc:
41
73
  NUMERIC = Locale::System::NUMERIC #:nodoc:
42
74
  TIME = Locale::System::TIME #:nodoc:
@@ -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: locale_win32.rb,v 1.12 2006/02/20 16:12:05 mutoh Exp $
9
+ $Id: locale_win32.rb,v 1.13 2006/06/04 14:43:37 mutoh Exp $
10
10
  =end
11
11
 
12
12
  require 'gettext/locale_table_win32'
@@ -32,6 +32,7 @@ module Locale #:nodoc:
32
32
  # * Returns the system locale (Locale::Object)
33
33
  def system
34
34
  lang = nil
35
+ ret = nil
35
36
  ["LC_ALL", "LC_CTYPE", "LC_MESSAGES", "LANG"].each do |env|
36
37
  lang = ENV[env]
37
38
  if lang
data/lib/gettext/mo.rb CHANGED
@@ -12,7 +12,7 @@
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.4 2006/04/29 17:17:15 mutoh Exp $
15
+ $Id: mo.rb,v 1.6 2006/05/19 15:42:14 mutoh Exp $
16
16
  =end
17
17
 
18
18
  require 'gettext/iconv'
@@ -38,7 +38,7 @@ class MOFile < Hash #:nodoc:
38
38
 
39
39
  def initialize(output_charset = nil)
40
40
  @filename = nil
41
- @last_modified = Time.now
41
+ @last_modified = nil
42
42
  @little_endian = true
43
43
  @output_charset = output_charset
44
44
  super()
@@ -46,7 +46,8 @@ class MOFile < Hash #:nodoc:
46
46
 
47
47
  def update!
48
48
  if FileTest.exist?(@filename)
49
- load (@filename) unless (@last_modified == File.ctime(@filename))
49
+ st = File.stat(@filename)
50
+ load(@filename) unless (@last_modified == [st.ctime, st.mtime])
50
51
  else
51
52
  puts "#{@filename} was lost." if $DEBUG
52
53
  clear
@@ -58,7 +59,8 @@ class MOFile < Hash #:nodoc:
58
59
  case arg
59
60
  when String
60
61
  begin
61
- @last_modified = File.ctime(arg)
62
+ st = File.stat(arg)
63
+ @last_modified = [st.ctime, st.mtime]
62
64
  rescue Exception
63
65
  end
64
66
  load_from_file(arg)
@@ -2,12 +2,12 @@
2
2
  =begin
3
3
  parser/activerecord.rb - parser for ActiveRecord
4
4
 
5
- Copyright (C) 2005 Masao Mutoh
5
+ Copyright (C) 2005, 2006 Masao Mutoh
6
6
 
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.8 2006/05/06 14:59:08 mutoh Exp $
10
+ $Id: activerecord.rb,v 1.9 2006/05/13 17:20:52 mutoh Exp $
11
11
  =end
12
12
 
13
13
  require 'gettext'
@@ -110,7 +110,11 @@ module GetText
110
110
  data.each do |v|
111
111
  if @ar_re =~ v
112
112
  unless @db
113
- require 'rubygems'
113
+ begin
114
+ require 'rubygems'
115
+ rescue LoadError
116
+ $stderr.puts _("rubygems are not found.") if $DEBUG
117
+ end
114
118
  require 'active_record'
115
119
  begin
116
120
  yml = YAML.load(ERB.new(IO.read(@config[:db_yml])).result)
@@ -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.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
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