gettext 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (288) hide show
  1. data/ChangeLog +194 -0
  2. data/NEWS +49 -0
  3. data/README +28 -9
  4. data/Rakefile +54 -41
  5. data/bin/rgettext +2 -0
  6. data/bin/rmsgfmt +2 -0
  7. data/bin/rmsgmerge +24 -0
  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/es/LC_MESSAGES/rails.mo +0 -0
  13. data/data/locale/es/LC_MESSAGES/rgettext.mo +0 -0
  14. data/data/locale/fr/LC_MESSAGES/rails.mo +0 -0
  15. data/data/locale/fr/LC_MESSAGES/rgettext.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/sv/LC_MESSAGES/rgettext.mo +0 -0
  26. data/lib/gettext.rb +17 -4
  27. data/lib/gettext/cgi.rb +34 -19
  28. data/lib/gettext/locale.rb +3 -13
  29. data/lib/gettext/locale_default.rb +2 -2
  30. data/lib/gettext/locale_win32.rb +27 -7
  31. data/lib/gettext/mo.rb +6 -1
  32. data/lib/gettext/parser/activerecord.rb +115 -0
  33. data/lib/gettext/parser/glade.rb +3 -1
  34. data/lib/gettext/parser/ruby.rb +56 -57
  35. data/lib/gettext/poparser.rb +297 -0
  36. data/lib/gettext/rails.rb +161 -3
  37. data/lib/gettext/rgettext.rb +19 -9
  38. data/lib/gettext/rmsgfmt.rb +7 -275
  39. data/lib/gettext/rmsgmerge.rb +381 -0
  40. data/lib/gettext/string.rb +26 -0
  41. data/lib/gettext/textdomain.rb +21 -18
  42. data/lib/gettext/utils.rb +55 -0
  43. data/lib/gettext/version.rb +1 -1
  44. data/po/cs/rails.po +83 -0
  45. data/po/cs/rgettext.po +104 -0
  46. data/po/de/rails.po +79 -0
  47. data/po/de/rgettext.po +72 -21
  48. data/po/es/rails.po +80 -0
  49. data/po/es/rgettext.po +75 -19
  50. data/po/fr/rails.po +81 -0
  51. data/po/fr/rgettext.po +75 -19
  52. data/po/it/rgettext.po +68 -17
  53. data/po/ja/rails.po +78 -0
  54. data/po/ja/rgettext.po +71 -20
  55. data/po/ko/rails.po +77 -0
  56. data/po/ko/rgettext.po +74 -22
  57. data/po/nl/rails.po +80 -0
  58. data/po/nl/rgettext.po +102 -0
  59. data/po/pt_BR/rails.po +79 -0
  60. data/po/pt_BR/rgettext.po +77 -24
  61. data/po/rails.pot +80 -0
  62. data/po/rgettext.pot +63 -13
  63. data/po/sv/rgettext.po +63 -15
  64. data/samples/cgi/cookie.cgi +5 -0
  65. data/samples/cgi/helloerb1.cgi +4 -0
  66. data/samples/cgi/helloerb2.cgi +5 -0
  67. data/samples/cgi/index.cgi +5 -0
  68. data/samples/cgi/locale/cs/LC_MESSAGES/helloerb1.mo +0 -0
  69. data/samples/cgi/locale/cs/LC_MESSAGES/helloerb2.mo +0 -0
  70. data/samples/cgi/locale/cs/LC_MESSAGES/hellolib.mo +0 -0
  71. data/samples/cgi/locale/cs/LC_MESSAGES/main.mo +0 -0
  72. data/samples/cgi/locale/fr/LC_MESSAGES/main.mo +0 -0
  73. data/samples/cgi/locale/ko/LC_MESSAGES/helloerb1.mo +0 -0
  74. data/samples/cgi/locale/ko/LC_MESSAGES/helloerb2.mo +0 -0
  75. data/samples/cgi/locale/ko/LC_MESSAGES/hellolib.mo +0 -0
  76. data/samples/cgi/locale/ko/LC_MESSAGES/main.mo +0 -0
  77. data/samples/cgi/locale/nl/LC_MESSAGES/helloerb1.mo +0 -0
  78. data/samples/cgi/locale/nl/LC_MESSAGES/helloerb2.mo +0 -0
  79. data/samples/cgi/locale/nl/LC_MESSAGES/hellolib.mo +0 -0
  80. data/samples/cgi/locale/nl/LC_MESSAGES/main.mo +0 -0
  81. data/samples/cgi/locale/pt_BR/LC_MESSAGES/helloerb1.mo +0 -0
  82. data/samples/cgi/locale/pt_BR/LC_MESSAGES/helloerb2.mo +0 -0
  83. data/samples/cgi/locale/pt_BR/LC_MESSAGES/hellolib.mo +0 -0
  84. data/samples/cgi/locale/pt_BR/LC_MESSAGES/main.mo +0 -0
  85. data/samples/cgi/po/cs/helloerb1.po +66 -0
  86. data/samples/cgi/po/cs/helloerb2.po +52 -0
  87. data/samples/cgi/po/cs/hellolib.po +25 -0
  88. data/samples/cgi/po/cs/main.po +78 -0
  89. data/samples/cgi/po/fr/main.po +8 -8
  90. data/samples/cgi/po/ko/helloerb1.po +2 -3
  91. data/samples/cgi/po/ko/helloerb2.po +1 -2
  92. data/samples/cgi/po/ko/hellolib.po +1 -2
  93. data/samples/cgi/po/ko/main.po +2 -3
  94. data/samples/cgi/po/nl/helloerb1.po +60 -0
  95. data/samples/cgi/po/nl/helloerb2.po +52 -0
  96. data/samples/cgi/po/nl/hellolib.po +24 -0
  97. data/samples/cgi/po/nl/main.po +76 -0
  98. data/samples/cgi/po/pt_BR/helloerb1.po +59 -0
  99. data/samples/cgi/po/pt_BR/helloerb2.po +51 -0
  100. data/samples/cgi/po/pt_BR/hellolib.po +22 -0
  101. data/samples/cgi/po/pt_BR/main.po +75 -0
  102. data/samples/locale/cs/LC_MESSAGES/hello.mo +0 -0
  103. data/samples/locale/cs/LC_MESSAGES/hello2.mo +0 -0
  104. data/samples/locale/cs/LC_MESSAGES/hello_noop.mo +0 -0
  105. data/samples/locale/cs/LC_MESSAGES/hello_plural.mo +0 -0
  106. data/samples/locale/cs/LC_MESSAGES/helloglade2.mo +0 -0
  107. data/samples/locale/cs/LC_MESSAGES/hellogtk.mo +0 -0
  108. data/samples/locale/cs/LC_MESSAGES/hellotk.mo +0 -0
  109. data/samples/locale/fr/LC_MESSAGES/helloglade2.mo +0 -0
  110. data/samples/locale/ko/LC_MESSAGES/hello.mo +0 -0
  111. data/samples/locale/ko/LC_MESSAGES/hello2.mo +0 -0
  112. data/samples/locale/ko/LC_MESSAGES/hello_noop.mo +0 -0
  113. data/samples/locale/ko/LC_MESSAGES/hello_plural.mo +0 -0
  114. data/samples/locale/ko/LC_MESSAGES/helloglade2.mo +0 -0
  115. data/samples/locale/ko/LC_MESSAGES/hellogtk.mo +0 -0
  116. data/samples/locale/ko/LC_MESSAGES/hellotk.mo +0 -0
  117. data/samples/locale/nl/LC_MESSAGES/hello.mo +0 -0
  118. data/samples/locale/nl/LC_MESSAGES/hello2.mo +0 -0
  119. data/samples/locale/nl/LC_MESSAGES/hello_noop.mo +0 -0
  120. data/samples/locale/nl/LC_MESSAGES/hello_plural.mo +0 -0
  121. data/samples/locale/nl/LC_MESSAGES/helloglade2.mo +0 -0
  122. data/samples/locale/nl/LC_MESSAGES/hellogtk.mo +0 -0
  123. data/samples/locale/nl/LC_MESSAGES/hellotk.mo +0 -0
  124. data/samples/locale/pt_BR/LC_MESSAGES/hello.mo +0 -0
  125. data/samples/locale/pt_BR/LC_MESSAGES/hello2.mo +0 -0
  126. data/samples/locale/pt_BR/LC_MESSAGES/hello_noop.mo +0 -0
  127. data/samples/locale/pt_BR/LC_MESSAGES/hello_plural.mo +0 -0
  128. data/samples/locale/pt_BR/LC_MESSAGES/helloglade2.mo +0 -0
  129. data/samples/locale/pt_BR/LC_MESSAGES/hellogtk.mo +0 -0
  130. data/samples/locale/pt_BR/LC_MESSAGES/hellotk.mo +0 -0
  131. data/samples/po/cs/hello.po +23 -0
  132. data/samples/po/cs/hello2.po +31 -0
  133. data/samples/po/cs/hello_noop.po +27 -0
  134. data/samples/po/cs/hello_plural.po +26 -0
  135. data/samples/po/cs/helloglade2.po +37 -0
  136. data/samples/po/cs/hellogtk.po +23 -0
  137. data/samples/po/cs/hellotk.po +23 -0
  138. data/samples/po/fr/helloglade2.po +2 -2
  139. data/samples/po/hello.pot +1 -0
  140. data/samples/po/hello2.pot +1 -0
  141. data/samples/po/hello_noop.pot +2 -1
  142. data/samples/po/hello_plural.pot +6 -2
  143. data/samples/po/helloglade2.pot +8 -3
  144. data/samples/po/hellotk.pot +4 -0
  145. data/samples/po/ko/hello.po +1 -2
  146. data/samples/po/ko/hello2.po +1 -2
  147. data/samples/po/ko/hello_noop.po +1 -2
  148. data/samples/po/ko/hello_plural.po +1 -2
  149. data/samples/po/ko/helloglade2.po +2 -2
  150. data/samples/po/ko/hellogtk.po +1 -2
  151. data/samples/po/ko/hellotk.po +1 -2
  152. data/samples/po/nl/hello.po +24 -0
  153. data/samples/po/nl/hello2.po +32 -0
  154. data/samples/po/nl/hello_noop.po +28 -0
  155. data/samples/po/nl/hello_plural.po +26 -0
  156. data/samples/po/nl/helloglade2.po +31 -0
  157. data/samples/po/nl/hellogtk.po +24 -0
  158. data/samples/po/nl/hellotk.po +24 -0
  159. data/samples/po/pt_BR/hello.po +6 -5
  160. data/samples/po/pt_BR/hello2.po +6 -5
  161. data/samples/po/pt_BR/hello_noop.po +6 -5
  162. data/samples/po/pt_BR/hello_plural.po +6 -6
  163. data/samples/po/pt_BR/helloglade2.po +6 -5
  164. data/samples/po/pt_BR/hellogtk.po +6 -5
  165. data/samples/po/pt_BR/hellotk.po +6 -5
  166. data/samples/rails/README +21 -15
  167. data/samples/rails/Rakefile +10 -1
  168. data/samples/rails/app/controllers/application.rb +10 -18
  169. data/samples/rails/app/controllers/blog_controller.rb +1 -5
  170. data/samples/rails/app/helpers/blog_helper.rb +1 -1
  171. data/samples/rails/app/models/article.rb +15 -0
  172. data/samples/rails/app/views/blog/_form.rhtml +2 -2
  173. data/samples/rails/config/boot.rb +17 -0
  174. data/samples/rails/config/database.yml +5 -3
  175. data/samples/rails/config/environment.rb +40 -75
  176. data/samples/rails/config/environments/development.rb +12 -7
  177. data/samples/rails/config/environments/production.rb +17 -6
  178. data/samples/rails/config/environments/test.rb +8 -6
  179. data/samples/rails/locale/cs/LC_MESSAGES/blog.mo +0 -0
  180. data/samples/rails/locale/cs/LC_MESSAGES/gettext_plugin.mo +0 -0
  181. data/samples/rails/locale/de/LC_MESSAGES/blog.mo +0 -0
  182. data/samples/rails/locale/de/LC_MESSAGES/gettext_plugin.mo +0 -0
  183. data/samples/rails/locale/en/LC_MESSAGES/blog.mo +0 -0
  184. data/samples/rails/locale/es/LC_MESSAGES/blog.mo +0 -0
  185. data/samples/rails/locale/es/LC_MESSAGES/gettext_plugin.mo +0 -0
  186. data/samples/rails/locale/fr/LC_MESSAGES/blog.mo +0 -0
  187. data/samples/rails/locale/fr/LC_MESSAGES/{lang_helper.mo → gettext_plugin.mo} +0 -0
  188. data/samples/rails/locale/ja/LC_MESSAGES/blog.mo +0 -0
  189. data/samples/rails/locale/ja/LC_MESSAGES/{lang_helper.mo → gettext_plugin.mo} +0 -0
  190. data/samples/rails/locale/ko/LC_MESSAGES/blog.mo +0 -0
  191. data/samples/rails/locale/ko/LC_MESSAGES/gettext_plugin.mo +0 -0
  192. data/samples/rails/locale/nl/LC_MESSAGES/blog.mo +0 -0
  193. data/samples/rails/locale/nl/LC_MESSAGES/gettext_plugin.mo +0 -0
  194. data/samples/rails/locale/pt_BR/LC_MESSAGES/blog.mo +0 -0
  195. data/samples/rails/locale/pt_BR/LC_MESSAGES/gettext_plugin.mo +0 -0
  196. data/samples/rails/po/blog.pot +57 -37
  197. data/samples/rails/po/cs/blog.po +116 -0
  198. data/samples/rails/po/cs/gettext_plugin.po +29 -0
  199. data/samples/rails/po/de/blog.po +70 -51
  200. data/samples/rails/po/de/{lang_helper.po → gettext_plugin.po} +4 -5
  201. data/samples/rails/po/en/blog.po +111 -0
  202. data/samples/rails/po/es/blog.po +67 -47
  203. data/samples/rails/po/es/{lang_helper.po → gettext_plugin.po} +5 -5
  204. data/samples/rails/po/fr/blog.po +65 -45
  205. data/samples/rails/po/fr/{lang_helper.po → gettext_plugin.po} +4 -4
  206. data/samples/rails/po/{lang_helper.pot → gettext_plugin.pot} +4 -4
  207. data/samples/rails/po/ja/blog.po +64 -44
  208. data/samples/rails/po/ja/{lang_helper.po → gettext_plugin.po} +4 -4
  209. data/samples/rails/po/ko/blog.po +65 -46
  210. data/samples/rails/po/ko/{lang_helper.po → gettext_plugin.po} +5 -6
  211. data/samples/rails/po/nl/blog.po +115 -0
  212. data/samples/rails/po/nl/gettext_plugin.po +28 -0
  213. data/samples/rails/po/pt_BR/blog.po +109 -0
  214. data/samples/rails/po/pt_BR/gettext_plugin.po +27 -0
  215. data/samples/rails/public/images/rails.png +0 -0
  216. data/samples/rails/public/index.html +272 -71
  217. data/samples/rails/public/javascripts/controls.js +441 -166
  218. data/samples/rails/public/javascripts/dragdrop.js +261 -279
  219. data/samples/rails/public/javascripts/effects.js +657 -277
  220. data/samples/rails/public/javascripts/prototype.js +911 -223
  221. data/samples/rails/public/robots.txt +1 -0
  222. data/samples/rails/public/stylesheets/scaffold.css +1 -1
  223. data/samples/rails/script/about +3 -0
  224. data/samples/rails/script/breakpointer +3 -4
  225. data/samples/rails/script/console +3 -23
  226. data/samples/rails/script/destroy +3 -7
  227. data/samples/rails/script/generate +3 -7
  228. data/samples/rails/script/performance/benchmarker +3 -0
  229. data/samples/rails/script/performance/profiler +3 -0
  230. data/samples/rails/script/plugin +3 -0
  231. data/samples/rails/script/process/reaper +3 -0
  232. data/samples/rails/script/process/spawner +3 -0
  233. data/samples/rails/script/process/spinner +3 -0
  234. data/samples/rails/script/runner +3 -29
  235. data/samples/rails/script/server +3 -49
  236. data/samples/rails/vendor/plugins/gettext/init.rb +19 -0
  237. data/samples/rails/vendor/{lang_helper.rb → plugins/gettext/lib/gettext_plugin.rb} +15 -11
  238. data/src/poparser.ry +171 -0
  239. data/test/gettext_runner.rb +3 -1
  240. data/test/gettext_test.rb +56 -31
  241. data/test/gettext_test_cgi.rb +12 -0
  242. data/test/gettext_test_parser.rb +3 -0
  243. data/test/gettext_test_string.rb +14 -0
  244. data/test/locale/cr/LC_MESSAGES/plural.mo +0 -0
  245. data/test/locale/da/LC_MESSAGES/plural.mo +0 -0
  246. data/test/locale/da/LC_MESSAGES/plural_error.mo +0 -0
  247. data/test/locale/fr/LC_MESSAGES/plural.mo +0 -0
  248. data/test/locale/fr/LC_MESSAGES/plural_error.mo +0 -0
  249. data/test/locale/ir/LC_MESSAGES/plural.mo +0 -0
  250. data/test/locale/la/LC_MESSAGES/plural.mo +0 -0
  251. data/test/locale/li/LC_MESSAGES/plural.mo +0 -0
  252. data/test/locale/po/LC_MESSAGES/plural.mo +0 -0
  253. data/test/locale/sl/LC_MESSAGES/plural.mo +0 -0
  254. data/test/po/cr/plural.po +3 -3
  255. data/test/po/da/plural.po +2 -2
  256. data/test/po/da/plural_error.po +2 -1
  257. data/test/po/fr/plural.po +2 -2
  258. data/test/po/fr/plural_error.po +2 -1
  259. data/test/po/ir/plural.po +3 -3
  260. data/test/po/la/plural.po +3 -3
  261. data/test/po/li/plural.po +3 -3
  262. data/test/po/po/plural.po +3 -3
  263. data/test/po/sl/plural.po +4 -4
  264. data/test/test.sh +1 -0
  265. data/test/test_rubyparser.rb +20 -0
  266. metadata +678 -551
  267. data/README.ja +0 -115
  268. data/data/locale/de/LC_MESSAGES/rmsgfmt.mo +0 -0
  269. data/data/locale/es/LC_MESSAGES/rmsgfmt.mo +0 -0
  270. data/data/locale/fr/LC_MESSAGES/rmsgfmt.mo +0 -0
  271. data/data/locale/it/LC_MESSAGES/rmsgfmt.mo +0 -0
  272. data/data/locale/ja/LC_MESSAGES/rmsgfmt.mo +0 -0
  273. data/data/locale/ko/LC_MESSAGES/rmsgfmt.mo +0 -0
  274. data/data/locale/pt_BR/LC_MESSAGES/rmsgfmt.mo +0 -0
  275. data/data/locale/sv/LC_MESSAGES/rmsgfmt.mo +0 -0
  276. data/po/de/rmsgfmt.po +0 -45
  277. data/po/es/rmsgfmt.po +0 -43
  278. data/po/fr/rmsgfmt.po +0 -43
  279. data/po/it/rmsgfmt.po +0 -44
  280. data/po/ja/rmsgfmt.po +0 -43
  281. data/po/ko/rmsgfmt.po +0 -40
  282. data/po/pt_BR/rmsgfmt.po +0 -42
  283. data/po/rmsgfmt.pot +0 -40
  284. data/po/sv/rmsgfmt.po +0 -43
  285. data/samples/rails/locale/de/LC_MESSAGES/lang_helper.mo +0 -0
  286. data/samples/rails/locale/es/LC_MESSAGES/lang_helper.mo +0 -0
  287. data/samples/rails/locale/ko/LC_MESSAGES/lang_helper.mo +0 -0
  288. data/src/rmsgfmt.ry +0 -233
data/lib/gettext/rails.rb CHANGED
@@ -6,29 +6,54 @@
6
6
  You may redistribute it and/or modify it under the same
7
7
  license terms as Ruby.
8
8
 
9
- $Id: rails.rb,v 1.1 2005/08/27 18:52:20 mutoh Exp $
9
+ $Id: rails.rb,v 1.8 2005/12/28 17:32:58 mutoh Exp $
10
10
  =end
11
11
 
12
12
  require 'gettext'
13
13
  require 'gettext/cgi'
14
+ require 'active_record'
15
+ require 'active_support'
14
16
 
15
17
  module GetText
16
18
  module Rails
17
19
  include GetText
18
20
 
21
+ Rails = ::Rails
22
+
19
23
  alias :_bindtextdomain :bindtextdomain
20
24
 
21
- def bindtextdomain(domainname, _cgi = nil, locale = nil, charset = "UTF-8")
25
+ def bindtextdomain(domainname, _cgi = nil, locale = nil, charset = nil, with_model = true)
22
26
  set_cgi(_cgi) if _cgi
23
27
  @gettext_container_domainname = domainname
24
28
  path = File.join(RAILS_ROOT, "locale")
25
29
  _bindtextdomain(domainname, path, locale, charset)
30
+
31
+ bindtextdomain_to(ActiveRecord::Base, domainname) if with_model
32
+ end
33
+
34
+ def bindtextdomain_to(klass, domainname)
35
+ klass.class_eval {
36
+ include GetText::Rails
37
+ extend GetText::Rails
38
+ textdomain(domainname)
39
+
40
+ def self.human_attribute_name(attribute_key_name)
41
+ ret = ""
42
+ if self == ActiveRecord::Base
43
+ #Table name
44
+ ret = _(attribute_key_name.humanize)
45
+ else
46
+ ret = s_("#{self}|#{attribute_key_name.humanize}")
47
+ end
48
+ ret
49
+ end
50
+ }
26
51
  end
27
52
 
28
53
  def callersrc
54
+ @gettext_container_domainname = nil unless defined? @gettext_container_domainname
29
55
  @gettext_container_domainname
30
56
  end
31
-
32
57
  end
33
58
  end
34
59
 
@@ -36,5 +61,138 @@ module ActionController
36
61
  class Base
37
62
  helper GetText::Rails
38
63
  include GetText::Rails
64
+ extend GetText::Rails
65
+
66
+ @@gettext_domainname = nil
67
+ @@gettext_content_type = nil
68
+
69
+ prepend_before_filter :init_gettext
70
+
71
+ def init_gettext_main
72
+ bindtextdomain(@@gettext_domainname, request.cgi) #You need to pass CGI object first.
73
+ @headers["Content-Type"] = "#{@@gettext_content_type}; charset=#{GetText.output_charset}"
74
+ end
75
+
76
+ def init_gettext
77
+ init_gettext_main
78
+ ActiveRecord::Errors.class_eval{
79
+ # You need to call bindtextdomain here because ActiveRecord::Errors doesn't know
80
+ # what locale is used in.
81
+ GetText.bindtextdomain("rails")
82
+ }
83
+ end
84
+
85
+ def self.init_gettext(domainname, charset = "UTF-8", content_type = "text/html")
86
+ GetText.output_charset = charset
87
+ @@gettext_domainname = domainname
88
+ @@gettext_content_type = content_type
89
+ end
90
+ end
91
+ end
92
+
93
+ module ActiveRecord
94
+ class Errors
95
+ include GetText
96
+ extend GetText
97
+
98
+ RE_FIELD_NAME = /%\{fn\}/
99
+
100
+ # You need to define this here, because this values will be updated by application.
101
+ default_error_messages.update(
102
+ :inclusion => N_("%{fn} is not included in the list"),
103
+ :exclusion => N_("%{fn} is reserved"),
104
+ :invalid => N_("%{fn} is invalid"),
105
+ :confirmation => N_("%{fn} doesn't match confirmation"),
106
+ :accepted => N_("%{fn} must be accepted"),
107
+ :empty => N_("%{fn} can't be empty"),
108
+ :blank => N_("%{fn} can't be blank"),
109
+ :too_long => N_("%{fn} is too long (max is %d characters)"),
110
+ :too_short => N_("%{fn} is too short (min is %d characters)"),
111
+ :wrong_length => N_("%{fn} is the wrong length (should be %d characters)"),
112
+ :taken => N_("%{fn} has already been taken"),
113
+ :not_a_number => N_("%{fn} is not a number")
114
+ )
115
+
116
+ @@default_error_messages_d = {
117
+ :too_long => default_error_messages[:too_long],
118
+ :too_short => default_error_messages[:too_short],
119
+ :wrong_length => default_error_messages[:wrong_length]
120
+ }
121
+
122
+ def self.convert_validates_messages_of_validates_length_of
123
+ default_error_messages[:too_long] = _(@@default_error_messages_d[:too_long])
124
+ default_error_messages[:too_short] = _(@@default_error_messages_d[:too_short])
125
+ default_error_messages[:wrong_length] = _(@@default_error_messages_d[:wrong_length])
126
+ end
127
+
128
+ def full_messages
129
+ full_messages = []
130
+
131
+ @errors.each_key do |attr|
132
+ @errors[attr].each do |msg|
133
+ next if msg.nil?
134
+ if attr == "base"
135
+ full_messages << _(msg)
136
+ elsif RE_FIELD_NAME =~ msg
137
+ full_messages << _(msg) % {:fn => @base.class.human_attribute_name(attr)}
138
+ else
139
+ full_messages << @base.class.human_attribute_name(attr) + " " + msg
140
+ end
141
+ end
142
+ end
143
+ full_messages
144
+ end
39
145
  end
146
+
147
+ module Validations
148
+ module ClassMethods
149
+ alias :_validates_length_of :validates_length_of
150
+ def validates_length_of(*attrs)
151
+ ActiveRecord::Errors.convert_validates_messages_of_validates_length_of
152
+ _validates_length_of(*attrs)
153
+ end
154
+ end
155
+ end
156
+ end
157
+
158
+
159
+ module ActionView
160
+ module Helpers
161
+ module ActiveRecordHelper
162
+ module L10n
163
+ # Separate namespace for textdomain
164
+ include GetText
165
+ extend GetText
166
+ module_function
167
+ def error_messages_for(object, klass, options = {})
168
+ textdomain("rails")
169
+ options = options.symbolize_keys
170
+
171
+ unless object.errors.empty?
172
+ count = object.errors.count
173
+ record = ActiveRecord::Base.human_attribute_name(object.class.to_s)
174
+ klass.content_tag("div",
175
+ klass.content_tag(
176
+ options[:header_tag] || "h2",
177
+ n_("%{num} error prohibited this %{record} from being saved",
178
+ "%{num} errors prohibited this %{record} from being saved", count) %
179
+ {:num => count, :record => record}) +
180
+ klass.content_tag("p", n_("There were problems with the following field:",
181
+ "There were problems with the following fields:", count)) +
182
+ klass.content_tag("ul", object.errors.full_messages.collect { |msg| klass.content_tag("li", msg) }),
183
+ "id" => options[:id] || "errorExplanation", "class" => options[:class] || "errorExplanation"
184
+ )
185
+ end
186
+ end
187
+ end
188
+ def error_messages_for(object_name, options = {})
189
+ object = instance_variable_get("@#{object_name}")
190
+ L10n.error_messages_for(object, self, options)
191
+ end
192
+ end
193
+ end
194
+ end
195
+
196
+ Rails::Info.property("GetText version") do
197
+ GetText::VERSION
40
198
  end
@@ -24,23 +24,34 @@ module GetText
24
24
 
25
25
  # constant values
26
26
  VERSION = GetText::VERSION
27
- DATE = %w($Date: 2005/09/02 19:32:48 $)[1]
27
+ DATE = %w($Date: 2005/12/25 11:43:20 $)[1]
28
28
  MAX_LINE_LEN = 70
29
29
 
30
- EX_PARSERS = [
30
+ @ex_parsers = []
31
+ [
31
32
  ["glade.rb", "GladeParser"],
32
33
  ["erb.rb", "ErbParser"],
34
+ ["activerecord.rb", "ActiveRecordParser"],
35
+ # ["ripper.rb", "RipperParser"],
33
36
  ["ruby.rb", "RubyParser"] # Default parser.
34
- ]
35
-
36
- EX_PARSERS.each do |f, _|
37
- require File.join("gettext/parser/#{f}")
37
+ ].each do |f, klass|
38
+ begin
39
+ require File.join("gettext/parser/#{f}")
40
+ @ex_parsers << GetText.const_get(klass)
41
+ rescue
42
+ $stderr.puts _("'%{klass}' is ignored.") % {:klass => klass}
43
+ $stderr.puts $! if $DEBUG
44
+ end
38
45
  end
39
46
 
40
47
  module_function
41
48
 
42
49
  def generate_pot_header
43
- time = Time.now.strftime("%Y-%m-%d %H:%M%z")
50
+ time = Time.now.strftime("%Y-%m-%d %H:%M")
51
+ off = Time.now.utc_offset
52
+ sign = off <= 0 ? '-' : '+'
53
+ time += sprintf('%s%02d%02d', sign, *(off.abs / 60).divmod(60))
54
+
44
55
  %Q[# SOME DESCRIPTIVE TITLE.
45
56
  # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
46
57
  # This file is distributed under the same license as the PACKAGE package.
@@ -95,8 +106,7 @@ msgstr ""
95
106
  ary = []
96
107
  files.each do |file|
97
108
  begin
98
- EX_PARSERS.each do |_, c|
99
- klass = GetText.const_get(c)
109
+ @ex_parsers.each do |klass|
100
110
  if klass.target?(file)
101
111
  ary = klass.parse(file, ary)
102
112
  break
@@ -7,287 +7,19 @@
7
7
  license terms as Ruby.
8
8
  =end
9
9
 
10
- #
11
- # DO NOT MODIFY!!!!
12
- # This file is automatically generated by racc 1.4.4
13
- # from racc grammer file "src/rmsgfmt.ry".
14
- #
15
-
16
- require 'racc/parser'
17
-
18
-
19
- module GetText
20
-
21
- class PoParser < Racc::Parser
22
-
23
- module_eval <<'..end src/rmsgfmt.ry modeval..id0ade4036b6', 'src/rmsgfmt.ry', 90
24
- def unescape(orig)
25
- ret = orig.gsub(/\\n/, "\n")
26
- ret.gsub!(/\\t/, "\t")
27
- ret.gsub!(/\\r/, "\r")
28
- ret.gsub!(/\\"/, "\"")
29
- ret
30
- end
31
-
32
- def parse(str, data)
33
- @data = data
34
- @fuzzy = false
35
- str.strip!
36
- @q = []
37
- until str.empty? do
38
- case str
39
- when /\A\s+/
40
- str = $'
41
- when /\Amsgid_plural/
42
- @q.push [:MSGID_PLURAL, $&]
43
- str = $'
44
- when /\Amsgid/
45
- @q.push [:MSGID, $&]
46
- str = $'
47
- when /\Amsgstr/
48
- @q.push [:MSGSTR, $&]
49
- str = $'
50
- when /\A\[(\d+)\]/
51
- @q.push [:PLURAL_NUM, $1]
52
- str = $'
53
- when /\A\#~(.*)/
54
- $stderr.print _("Warning: obsolete msgid is existed.\n")
55
- $stderr.print " #{$&}\n"
56
- str = $'
57
- when /\A\#/
58
- @q.push [:COMMENT, $&]
59
- str = $'
60
- when /\A\"(.*)\"/
61
- @q.push [:STRING, $1]
62
- str = $'
63
- else
64
- c = str[0,1]
65
- @q.push [:STRING, c]
66
- str = str[1..-1]
67
- end
68
- end
69
- @q.push [false, '$end']
70
- if $DEBUG
71
- @q.each do |a,b|
72
- puts "[#{a}, #{b}]"
73
- end
74
- end
75
- @yydebug = true if $DEBUG
76
- do_parse
77
- end
78
-
79
- def next_token
80
- @q.shift
81
- end
82
-
83
- ..end src/rmsgfmt.ry modeval..id0ade4036b6
84
-
85
- ##### racc 1.4.4 generates ###
86
-
87
- racc_reduce_table = [
88
- 0, 0, :racc_error,
89
- 0, 9, :_reduce_none,
90
- 2, 9, :_reduce_none,
91
- 2, 9, :_reduce_none,
92
- 4, 11, :_reduce_4,
93
- 5, 11, :_reduce_5,
94
- 2, 13, :_reduce_6,
95
- 1, 13, :_reduce_none,
96
- 3, 14, :_reduce_8,
97
- 2, 10, :_reduce_9,
98
- 1, 10, :_reduce_none,
99
- 2, 12, :_reduce_11,
100
- 1, 12, :_reduce_12 ]
101
-
102
- racc_reduce_n = 13
103
-
104
- racc_shift_n = 22
105
-
106
- racc_action_table = [
107
- 3, 9, 4, 5, 12, 13, 11, 18, 11, 11,
108
- 9, 9, 9, 7, 11, 18, 20, 9, 11 ]
109
-
110
- racc_action_check = [
111
- 1, 13, 1, 1, 10, 10, 10, 14, 14, 8,
112
- 4, 12, 5, 3, 15, 16, 18, 20, 21 ]
113
-
114
- racc_action_pointer = [
115
- nil, 0, nil, 13, 4, 6, nil, nil, 3, nil,
116
- 0, nil, 5, -5, 2, 8, 10, nil, 9, nil,
117
- 11, 12 ]
118
-
119
- racc_action_default = [
120
- -1, -13, -3, -13, -10, -13, -2, 22, -9, -12,
121
- -13, -11, -13, -13, -13, -4, -5, -7, -13, -6,
122
- -13, -8 ]
123
-
124
- racc_goto_table = [
125
- 8, 10, 17, 2, 19, 6, 16, 1, 14, 15,
126
- nil, nil, nil, nil, nil, nil, 21 ]
127
-
128
- racc_goto_check = [
129
- 4, 4, 6, 3, 6, 2, 5, 1, 4, 4,
130
- nil, nil, nil, nil, nil, nil, 4 ]
131
-
132
- racc_goto_pointer = [
133
- nil, 7, 4, 2, -4, -8, -12 ]
134
-
135
- racc_goto_default = [
136
- nil, nil, nil, nil, nil, nil, nil ]
137
-
138
- racc_token_table = {
139
- false => 0,
140
- Object.new => 1,
141
- :COMMENT => 2,
142
- :MSGID => 3,
143
- :MSGID_PLURAL => 4,
144
- :MSGSTR => 5,
145
- :STRING => 6,
146
- :PLURAL_NUM => 7 }
147
-
148
- racc_use_result_var = true
149
-
150
- racc_nt_base = 8
151
-
152
- Racc_arg = [
153
- racc_action_table,
154
- racc_action_check,
155
- racc_action_default,
156
- racc_action_pointer,
157
- racc_goto_table,
158
- racc_goto_check,
159
- racc_goto_default,
160
- racc_goto_pointer,
161
- racc_nt_base,
162
- racc_reduce_table,
163
- racc_token_table,
164
- racc_shift_n,
165
- racc_reduce_n,
166
- racc_use_result_var ]
167
-
168
- Racc_token_to_s_table = [
169
- '$end',
170
- 'error',
171
- 'COMMENT',
172
- 'MSGID',
173
- 'MSGID_PLURAL',
174
- 'MSGSTR',
175
- 'STRING',
176
- 'PLURAL_NUM',
177
- '$start',
178
- 'msgfmt',
179
- 'comment',
180
- 'message',
181
- 'string_list',
182
- 'msgstr_plural',
183
- 'msgstr_plural_line']
184
-
185
- Racc_debug_parser = true
186
-
187
- ##### racc system variables end #####
188
-
189
- # reduce 0 omitted
190
-
191
- # reduce 1 omitted
192
-
193
- # reduce 2 omitted
194
-
195
- # reduce 3 omitted
196
-
197
- module_eval <<'.,.,', 'src/rmsgfmt.ry', 36
198
- def _reduce_4( val, _values, result )
199
- if @fuzzy
200
- if val[1] != ""
201
- $stderr.print _("Warning: fuzzy message was ignored.\n")
202
- $stderr.print " msgid '#{val[1]}'\n"
203
- else
204
- @data[""] = unescape(val[3])
205
- end
206
- @fuzzy = false
207
- else
208
- @data[unescape(val[1])] = unescape(val[3])
209
- end
210
- result = ""
211
- result
212
- end
213
- .,.,
214
-
215
- module_eval <<'.,.,', 'src/rmsgfmt.ry', 51
216
- def _reduce_5( val, _values, result )
217
- if @fuzzy
218
- if val[1] != ""
219
- $stderr.print _("Warning: fuzzy message was ignored.\n")
220
- $stderr.print "msgid = '#{val[1]}\n"
221
- else
222
- @data[""] = unescape(val[3])
223
- end
224
- @fuzzy = false
225
- else
226
- @data[unescape(val[1]) + "\000" + unescape(val[3])] = unescape(val[4])
227
- end
228
- result = ""
229
- result
230
- end
231
- .,.,
232
-
233
- module_eval <<'.,.,', 'src/rmsgfmt.ry', 58
234
- def _reduce_6( val, _values, result )
235
- result = val[0] + "\000" + val[1]
236
- result
237
- end
238
- .,.,
239
-
240
- # reduce 7 omitted
241
-
242
- module_eval <<'.,.,', 'src/rmsgfmt.ry', 66
243
- def _reduce_8( val, _values, result )
244
- result = val[2]
245
- result
246
- end
247
- .,.,
248
-
249
- module_eval <<'.,.,', 'src/rmsgfmt.ry', 73
250
- def _reduce_9( val, _values, result )
251
- @fuzzy = true if /fuzzy/ =~ val[1]
252
- result
253
- end
254
- .,.,
255
-
256
- # reduce 10 omitted
257
-
258
- module_eval <<'.,.,', 'src/rmsgfmt.ry', 81
259
- def _reduce_11( val, _values, result )
260
- result = val.delete_if{|item| item == ""}.join
261
- result
262
- end
263
- .,.,
264
-
265
- module_eval <<'.,.,', 'src/rmsgfmt.ry', 85
266
- def _reduce_12( val, _values, result )
267
- result = val[0]
268
- result
269
- end
270
- .,.,
271
-
272
- def _reduce_none( val, _values, result )
273
- result
274
- end
275
-
276
- end # class PoParser
277
-
278
- end # module GetText
279
-
280
10
  require 'optparse'
281
- require 'gettext'
282
11
  require 'fileutils'
283
-
284
- include GetText
285
- GetText.bindtextdomain("rmsgfmt")
12
+ require 'gettext'
13
+ require 'gettext/poparser'
286
14
 
287
15
  module GetText
16
+ GetText.bindtextdomain("rgettext")
17
+
288
18
  module RMsgfmt
19
+ extend GetText
20
+
289
21
  VERSION = GetText::VERSION
290
- DATE = %w($Date: 2005/09/03 09:54:02 $)[1]
22
+ DATE = %w($Date: 2005/10/22 10:49:59 $)[1]
291
23
 
292
24
  module_function
293
25
  def run(targetfile = nil, output_path = nil)