gettext 1.0.0-mswin32 → 1.1.0-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (301) hide show
  1. data/ChangeLog +193 -0
  2. data/NEWS +51 -1
  3. data/README +29 -11
  4. data/Rakefile +70 -56
  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/ext/gettext/gettext/_locale.BAK +86 -0
  27. data/ext/gettext/gettext/_locale.c +1 -1
  28. data/ext/gettext/gettext/_locale.exp +0 -0
  29. data/ext/gettext/gettext/_locale.lib +0 -0
  30. data/ext/gettext/gettext/_locale.obj +0 -0
  31. data/ext/gettext/gettext/_locale.pdb +0 -0
  32. data/ext/gettext/gettext/_locale.so +0 -0
  33. data/ext/gettext/gettext/mkmf.log +4 -4
  34. data/ext/gettext/gettext/vc70.pdb +0 -0
  35. data/lib/_locale.so +0 -0
  36. data/lib/gettext.rb +17 -4
  37. data/lib/gettext/cgi.rb +34 -19
  38. data/lib/gettext/locale.rb +3 -13
  39. data/lib/gettext/locale_default.rb +2 -2
  40. data/lib/gettext/locale_win32.rb +27 -7
  41. data/lib/gettext/mo.rb +6 -1
  42. data/lib/gettext/parser/activerecord.rb +115 -0
  43. data/lib/gettext/parser/glade.rb +3 -1
  44. data/lib/gettext/parser/ruby.rb +56 -57
  45. data/lib/gettext/poparser.rb +297 -0
  46. data/lib/gettext/rails.rb +161 -3
  47. data/lib/gettext/rgettext.rb +19 -9
  48. data/lib/gettext/rmsgfmt.rb +95 -363
  49. data/lib/gettext/rmsgmerge.rb +381 -0
  50. data/lib/gettext/string.rb +26 -0
  51. data/lib/gettext/textdomain.rb +21 -18
  52. data/lib/gettext/utils.rb +55 -0
  53. data/lib/gettext/version.rb +1 -1
  54. data/po/cs/rails.po +83 -0
  55. data/po/cs/rgettext.po +104 -0
  56. data/po/de/rails.po +79 -0
  57. data/po/de/rgettext.po +72 -21
  58. data/po/es/rails.po +80 -0
  59. data/po/es/rgettext.po +75 -19
  60. data/po/fr/rails.po +81 -0
  61. data/po/fr/rgettext.po +75 -19
  62. data/po/it/rgettext.po +68 -17
  63. data/po/ja/rails.po +78 -0
  64. data/po/ja/rgettext.po +71 -20
  65. data/po/ko/rails.po +77 -0
  66. data/po/ko/rgettext.po +74 -22
  67. data/po/nl/rails.po +80 -0
  68. data/po/nl/rgettext.po +102 -0
  69. data/po/pt_BR/rails.po +79 -0
  70. data/po/pt_BR/rgettext.po +77 -24
  71. data/po/rails.pot +80 -0
  72. data/po/rgettext.pot +63 -13
  73. data/po/sv/rgettext.po +63 -15
  74. data/samples/cgi/cookie.cgi +5 -0
  75. data/samples/cgi/helloerb1.cgi +4 -0
  76. data/samples/cgi/helloerb2.cgi +5 -0
  77. data/samples/cgi/index.cgi +5 -0
  78. data/samples/cgi/locale/cs/LC_MESSAGES/helloerb1.mo +0 -0
  79. data/samples/cgi/locale/cs/LC_MESSAGES/helloerb2.mo +0 -0
  80. data/samples/cgi/locale/cs/LC_MESSAGES/hellolib.mo +0 -0
  81. data/samples/cgi/locale/cs/LC_MESSAGES/main.mo +0 -0
  82. data/samples/cgi/locale/fr/LC_MESSAGES/main.mo +0 -0
  83. data/samples/cgi/locale/ko/LC_MESSAGES/helloerb1.mo +0 -0
  84. data/samples/cgi/locale/ko/LC_MESSAGES/helloerb2.mo +0 -0
  85. data/samples/cgi/locale/ko/LC_MESSAGES/hellolib.mo +0 -0
  86. data/samples/cgi/locale/ko/LC_MESSAGES/main.mo +0 -0
  87. data/samples/cgi/locale/nl/LC_MESSAGES/helloerb1.mo +0 -0
  88. data/samples/cgi/locale/nl/LC_MESSAGES/helloerb2.mo +0 -0
  89. data/samples/cgi/locale/nl/LC_MESSAGES/hellolib.mo +0 -0
  90. data/samples/cgi/locale/nl/LC_MESSAGES/main.mo +0 -0
  91. data/samples/cgi/locale/pt_BR/LC_MESSAGES/helloerb1.mo +0 -0
  92. data/samples/cgi/locale/pt_BR/LC_MESSAGES/helloerb2.mo +0 -0
  93. data/samples/cgi/locale/pt_BR/LC_MESSAGES/hellolib.mo +0 -0
  94. data/samples/cgi/locale/pt_BR/LC_MESSAGES/main.mo +0 -0
  95. data/samples/cgi/po/cs/helloerb1.po +66 -0
  96. data/samples/cgi/po/cs/helloerb2.po +52 -0
  97. data/samples/cgi/po/cs/hellolib.po +25 -0
  98. data/samples/cgi/po/cs/main.po +78 -0
  99. data/samples/cgi/po/fr/main.po +8 -8
  100. data/samples/cgi/po/ko/helloerb1.po +2 -3
  101. data/samples/cgi/po/ko/helloerb2.po +1 -2
  102. data/samples/cgi/po/ko/hellolib.po +1 -2
  103. data/samples/cgi/po/ko/main.po +2 -3
  104. data/samples/cgi/po/nl/helloerb1.po +60 -0
  105. data/samples/cgi/po/nl/helloerb2.po +52 -0
  106. data/samples/cgi/po/nl/hellolib.po +24 -0
  107. data/samples/cgi/po/nl/main.po +76 -0
  108. data/samples/cgi/po/pt_BR/helloerb1.po +59 -0
  109. data/samples/cgi/po/pt_BR/helloerb2.po +51 -0
  110. data/samples/cgi/po/pt_BR/hellolib.po +22 -0
  111. data/samples/cgi/po/pt_BR/main.po +75 -0
  112. data/samples/locale/cs/LC_MESSAGES/hello.mo +0 -0
  113. data/samples/locale/cs/LC_MESSAGES/hello2.mo +0 -0
  114. data/samples/locale/cs/LC_MESSAGES/hello_noop.mo +0 -0
  115. data/samples/locale/cs/LC_MESSAGES/hello_plural.mo +0 -0
  116. data/samples/locale/cs/LC_MESSAGES/helloglade2.mo +0 -0
  117. data/samples/locale/cs/LC_MESSAGES/hellogtk.mo +0 -0
  118. data/samples/locale/cs/LC_MESSAGES/hellotk.mo +0 -0
  119. data/samples/locale/fr/LC_MESSAGES/helloglade2.mo +0 -0
  120. data/samples/locale/ko/LC_MESSAGES/hello.mo +0 -0
  121. data/samples/locale/ko/LC_MESSAGES/hello2.mo +0 -0
  122. data/samples/locale/ko/LC_MESSAGES/hello_noop.mo +0 -0
  123. data/samples/locale/ko/LC_MESSAGES/hello_plural.mo +0 -0
  124. data/samples/locale/ko/LC_MESSAGES/helloglade2.mo +0 -0
  125. data/samples/locale/ko/LC_MESSAGES/hellogtk.mo +0 -0
  126. data/samples/locale/ko/LC_MESSAGES/hellotk.mo +0 -0
  127. data/samples/locale/nl/LC_MESSAGES/hello.mo +0 -0
  128. data/samples/locale/nl/LC_MESSAGES/hello2.mo +0 -0
  129. data/samples/locale/nl/LC_MESSAGES/hello_noop.mo +0 -0
  130. data/samples/locale/nl/LC_MESSAGES/hello_plural.mo +0 -0
  131. data/samples/locale/nl/LC_MESSAGES/helloglade2.mo +0 -0
  132. data/samples/locale/nl/LC_MESSAGES/hellogtk.mo +0 -0
  133. data/samples/locale/nl/LC_MESSAGES/hellotk.mo +0 -0
  134. data/samples/locale/pt_BR/LC_MESSAGES/hello.mo +0 -0
  135. data/samples/locale/pt_BR/LC_MESSAGES/hello2.mo +0 -0
  136. data/samples/locale/pt_BR/LC_MESSAGES/hello_noop.mo +0 -0
  137. data/samples/locale/pt_BR/LC_MESSAGES/hello_plural.mo +0 -0
  138. data/samples/locale/pt_BR/LC_MESSAGES/helloglade2.mo +0 -0
  139. data/samples/locale/pt_BR/LC_MESSAGES/hellogtk.mo +0 -0
  140. data/samples/locale/pt_BR/LC_MESSAGES/hellotk.mo +0 -0
  141. data/samples/po/cs/hello.po +23 -0
  142. data/samples/po/cs/hello2.po +31 -0
  143. data/samples/po/cs/hello_noop.po +27 -0
  144. data/samples/po/cs/hello_plural.po +26 -0
  145. data/samples/po/cs/helloglade2.po +37 -0
  146. data/samples/po/cs/hellogtk.po +23 -0
  147. data/samples/po/cs/hellotk.po +23 -0
  148. data/samples/po/fr/helloglade2.po +2 -2
  149. data/samples/po/hello.pot +1 -0
  150. data/samples/po/hello2.pot +1 -0
  151. data/samples/po/hello_noop.pot +2 -1
  152. data/samples/po/hello_plural.pot +6 -2
  153. data/samples/po/helloglade2.pot +8 -3
  154. data/samples/po/hellotk.pot +4 -0
  155. data/samples/po/ko/hello.po +1 -2
  156. data/samples/po/ko/hello2.po +1 -2
  157. data/samples/po/ko/hello_noop.po +1 -2
  158. data/samples/po/ko/hello_plural.po +1 -2
  159. data/samples/po/ko/helloglade2.po +2 -2
  160. data/samples/po/ko/hellogtk.po +1 -2
  161. data/samples/po/ko/hellotk.po +1 -2
  162. data/samples/po/nl/hello.po +24 -0
  163. data/samples/po/nl/hello2.po +32 -0
  164. data/samples/po/nl/hello_noop.po +28 -0
  165. data/samples/po/nl/hello_plural.po +26 -0
  166. data/samples/po/nl/helloglade2.po +31 -0
  167. data/samples/po/nl/hellogtk.po +24 -0
  168. data/samples/po/nl/hellotk.po +24 -0
  169. data/samples/po/pt_BR/hello.po +6 -5
  170. data/samples/po/pt_BR/hello2.po +6 -5
  171. data/samples/po/pt_BR/hello_noop.po +6 -5
  172. data/samples/po/pt_BR/hello_plural.po +6 -6
  173. data/samples/po/pt_BR/helloglade2.po +6 -5
  174. data/samples/po/pt_BR/hellogtk.po +6 -5
  175. data/samples/po/pt_BR/hellotk.po +6 -5
  176. data/samples/rails/README +21 -15
  177. data/samples/rails/Rakefile +10 -1
  178. data/samples/rails/app/controllers/application.rb +10 -18
  179. data/samples/rails/app/controllers/blog_controller.rb +1 -5
  180. data/samples/rails/app/helpers/blog_helper.rb +1 -1
  181. data/samples/rails/app/models/article.rb +15 -0
  182. data/samples/rails/app/views/blog/_form.rhtml +2 -2
  183. data/samples/rails/config/boot.rb +17 -0
  184. data/samples/rails/config/database.yml +6 -4
  185. data/samples/rails/config/environment.rb +40 -75
  186. data/samples/rails/config/environments/development.rb +12 -7
  187. data/samples/rails/config/environments/production.rb +17 -6
  188. data/samples/rails/config/environments/test.rb +8 -6
  189. data/samples/rails/locale/cs/LC_MESSAGES/blog.mo +0 -0
  190. data/samples/rails/locale/cs/LC_MESSAGES/gettext_plugin.mo +0 -0
  191. data/samples/rails/locale/de/LC_MESSAGES/blog.mo +0 -0
  192. data/samples/rails/locale/de/LC_MESSAGES/gettext_plugin.mo +0 -0
  193. data/samples/rails/locale/en/LC_MESSAGES/blog.mo +0 -0
  194. data/samples/rails/locale/es/LC_MESSAGES/blog.mo +0 -0
  195. data/samples/rails/locale/es/LC_MESSAGES/gettext_plugin.mo +0 -0
  196. data/samples/rails/locale/fr/LC_MESSAGES/blog.mo +0 -0
  197. data/samples/rails/locale/fr/LC_MESSAGES/{lang_helper.mo → gettext_plugin.mo} +0 -0
  198. data/samples/rails/locale/ja/LC_MESSAGES/blog.mo +0 -0
  199. data/samples/rails/locale/ja/LC_MESSAGES/{lang_helper.mo → gettext_plugin.mo} +0 -0
  200. data/samples/rails/locale/ko/LC_MESSAGES/blog.mo +0 -0
  201. data/samples/rails/locale/ko/LC_MESSAGES/gettext_plugin.mo +0 -0
  202. data/samples/rails/locale/nl/LC_MESSAGES/blog.mo +0 -0
  203. data/samples/rails/locale/nl/LC_MESSAGES/gettext_plugin.mo +0 -0
  204. data/samples/rails/locale/pt_BR/LC_MESSAGES/blog.mo +0 -0
  205. data/samples/rails/locale/pt_BR/LC_MESSAGES/gettext_plugin.mo +0 -0
  206. data/samples/rails/po/blog.pot +57 -37
  207. data/samples/rails/po/cs/blog.po +116 -0
  208. data/samples/rails/po/cs/gettext_plugin.po +29 -0
  209. data/samples/rails/po/de/blog.po +70 -51
  210. data/samples/rails/po/de/{lang_helper.po → gettext_plugin.po} +4 -5
  211. data/samples/rails/po/en/blog.po +111 -0
  212. data/samples/rails/po/es/blog.po +67 -47
  213. data/samples/rails/po/es/{lang_helper.po → gettext_plugin.po} +5 -5
  214. data/samples/rails/po/fr/blog.po +65 -45
  215. data/samples/rails/po/fr/{lang_helper.po → gettext_plugin.po} +4 -4
  216. data/samples/rails/po/{lang_helper.pot → gettext_plugin.pot} +4 -4
  217. data/samples/rails/po/ja/blog.po +64 -44
  218. data/samples/rails/po/ja/{lang_helper.po → gettext_plugin.po} +4 -4
  219. data/samples/rails/po/ko/blog.po +65 -46
  220. data/samples/rails/po/ko/{lang_helper.po → gettext_plugin.po} +5 -6
  221. data/samples/rails/po/nl/blog.po +115 -0
  222. data/samples/rails/po/nl/gettext_plugin.po +28 -0
  223. data/samples/rails/po/pt_BR/blog.po +109 -0
  224. data/samples/rails/po/pt_BR/gettext_plugin.po +27 -0
  225. data/samples/rails/public/images/rails.png +0 -0
  226. data/samples/rails/public/index.html +272 -71
  227. data/samples/rails/public/javascripts/controls.js +441 -166
  228. data/samples/rails/public/javascripts/dragdrop.js +261 -279
  229. data/samples/rails/public/javascripts/effects.js +657 -277
  230. data/samples/rails/public/javascripts/prototype.js +911 -223
  231. data/samples/rails/public/robots.txt +1 -0
  232. data/samples/rails/public/stylesheets/scaffold.css +1 -1
  233. data/samples/rails/script/about +3 -0
  234. data/samples/rails/script/breakpointer +3 -4
  235. data/samples/rails/script/console +3 -23
  236. data/samples/rails/script/destroy +3 -7
  237. data/samples/rails/script/generate +3 -7
  238. data/samples/rails/script/performance/benchmarker +3 -0
  239. data/samples/rails/script/performance/profiler +3 -0
  240. data/samples/rails/script/plugin +3 -0
  241. data/samples/rails/script/process/reaper +3 -0
  242. data/samples/rails/script/process/spawner +3 -0
  243. data/samples/rails/script/process/spinner +3 -0
  244. data/samples/rails/script/runner +3 -29
  245. data/samples/rails/script/server +3 -49
  246. data/samples/rails/vendor/plugins/gettext/init.rb +19 -0
  247. data/samples/rails/vendor/{lang_helper.rb → plugins/gettext/lib/gettext_plugin.rb} +15 -11
  248. data/src/poparser.ry +171 -0
  249. data/test/gettext_runner.rb +3 -1
  250. data/test/gettext_test.rb +56 -31
  251. data/test/gettext_test_cgi.rb +12 -0
  252. data/test/gettext_test_parser.rb +3 -0
  253. data/test/gettext_test_string.rb +14 -0
  254. data/test/locale/cr/LC_MESSAGES/plural.mo +0 -0
  255. data/test/locale/da/LC_MESSAGES/plural.mo +0 -0
  256. data/test/locale/da/LC_MESSAGES/plural_error.mo +0 -0
  257. data/test/locale/fr/LC_MESSAGES/plural.mo +0 -0
  258. data/test/locale/fr/LC_MESSAGES/plural_error.mo +0 -0
  259. data/test/locale/ir/LC_MESSAGES/plural.mo +0 -0
  260. data/test/locale/la/LC_MESSAGES/plural.mo +0 -0
  261. data/test/locale/li/LC_MESSAGES/plural.mo +0 -0
  262. data/test/locale/po/LC_MESSAGES/plural.mo +0 -0
  263. data/test/locale/sl/LC_MESSAGES/plural.mo +0 -0
  264. data/test/po/cr/plural.po +3 -3
  265. data/test/po/da/plural.po +2 -2
  266. data/test/po/da/plural_error.po +2 -1
  267. data/test/po/fr/plural.po +2 -2
  268. data/test/po/fr/plural_error.po +2 -1
  269. data/test/po/ir/plural.po +3 -3
  270. data/test/po/la/plural.po +3 -3
  271. data/test/po/li/plural.po +3 -3
  272. data/test/po/po/plural.po +3 -3
  273. data/test/po/sl/plural.po +4 -4
  274. data/test/test.sh +1 -0
  275. data/test/test_rubyparser.rb +20 -0
  276. data/test/{test_rubyparser_n.rb → test_rubyparser_N.rb} +0 -0
  277. metadata +163 -43
  278. data/README.ja +0 -115
  279. data/data/locale/de/LC_MESSAGES/rmsgfmt.mo +0 -0
  280. data/data/locale/es/LC_MESSAGES/rmsgfmt.mo +0 -0
  281. data/data/locale/fr/LC_MESSAGES/rmsgfmt.mo +0 -0
  282. data/data/locale/it/LC_MESSAGES/rmsgfmt.mo +0 -0
  283. data/data/locale/ja/LC_MESSAGES/rmsgfmt.mo +0 -0
  284. data/data/locale/ko/LC_MESSAGES/rmsgfmt.mo +0 -0
  285. data/data/locale/pt_BR/LC_MESSAGES/rmsgfmt.mo +0 -0
  286. data/data/locale/sv/LC_MESSAGES/rmsgfmt.mo +0 -0
  287. data/gettext-1.0.0-mswin32.gem +0 -0
  288. data/po/de/rmsgfmt.po +0 -45
  289. data/po/es/rmsgfmt.po +0 -43
  290. data/po/fr/rmsgfmt.po +0 -43
  291. data/po/it/rmsgfmt.po +0 -44
  292. data/po/ja/rmsgfmt.po +0 -43
  293. data/po/ko/rmsgfmt.po +0 -40
  294. data/po/pt_BR/rmsgfmt.po +0 -42
  295. data/po/rmsgfmt.pot +0 -40
  296. data/po/sv/rmsgfmt.po +0 -43
  297. data/samples/rails/locale/de/LC_MESSAGES/lang_helper.mo +0 -0
  298. data/samples/rails/locale/es/LC_MESSAGES/lang_helper.mo +0 -0
  299. data/samples/rails/locale/ko/LC_MESSAGES/lang_helper.mo +0 -0
  300. data/samples/rails/log/development.log +0 -378
  301. 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
@@ -1,363 +1,95 @@
1
- =begin
2
- rmsgfmt.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/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..ida199490b55', '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..ida199490b55
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
- require 'optparse'
281
- require 'gettext'
282
- require 'fileutils'
283
-
284
- include GetText
285
- GetText.bindtextdomain("rmsgfmt")
286
-
287
- module GetText
288
- module RMsgfmt
289
- VERSION = GetText::VERSION
290
- DATE = %w($Date: 2005/08/30 17:56:15 $)[1]
291
-
292
- module_function
293
- def run(targetfile = nil, output_path = nil)
294
- unless targetfile
295
- targetfile, output_path = check_options
296
- end
297
- unless targetfile
298
- raise ArgumentError, _("no input files")
299
- end
300
- unless output_path
301
- output_path = "messages.mo"
302
- end
303
-
304
- parser = PoParser.new
305
- data = MOFile.new
306
- parser.parse(File.open(targetfile).read, data)
307
- data.save_to_file(output_path)
308
- end
309
-
310
- def check_options
311
- output = nil
312
-
313
- opts = OptionParser.new
314
- opts.banner = _("Usage: %s input.po [-o output.mo]" % $0)
315
- opts.separator("")
316
- opts.separator(_("Generate binary message catalog from textual translation description."))
317
- opts.separator("")
318
- opts.separator(_("Specific options:"))
319
-
320
- opts.on("-o", "--output=FILE", _("write output to specified file")) do |out|
321
- output = out
322
- end
323
-
324
- opts.on_tail("--version", _("display version information and exit")) do
325
- puts "#{$0} #{VERSION} (#{DATE})"
326
- exit
327
- end
328
- opts.parse!(ARGV)
329
-
330
- if ARGV.size == 0
331
- puts opts.help
332
- exit 1
333
- end
334
-
335
- [ARGV[0], output]
336
- end
337
- end
338
-
339
- module_function
340
- def rmsgfmt(targetfile = nil, output_path = nil)
341
- RMsgfmt.run(targetfile, output_path)
342
- end
343
-
344
- def create_mofiles(verbose = false,
345
- podir = "./po", targetdir = "./data/locale",
346
- targetpath_rule = "%s/LC_MESSAGES")
347
-
348
- modir = File.join(targetdir, targetpath_rule)
349
- Dir.glob(File.join(podir, "*/*.po")) do |file|
350
- lang, basename = /\/([^\/]+?)\/(.*)\.po/.match(file[podir.size..-1]).to_a[1,2]
351
- outdir = modir % lang
352
- FileUtils.mkdir_p(outdir) unless File.directory?(outdir)
353
- rmsgfmt(file, File.join(outdir, "#{basename}.mo"))
354
- if verbose
355
- $stderr.puts %Q[#{file} -> #{File.join(outdir, "#{basename}.mo")}]
356
- end
357
- end
358
- end
359
- end
360
-
361
- if $0 == __FILE__ then
362
- GetText.rmsgfmt
363
- end
1
+ =begin
2
+ rmsgfmt.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
+ require 'optparse'
11
+ require 'fileutils'
12
+ require 'gettext'
13
+ require 'gettext/poparser'
14
+
15
+ module GetText
16
+ GetText.bindtextdomain("rgettext")
17
+
18
+ module RMsgfmt
19
+ extend GetText
20
+
21
+ VERSION = GetText::VERSION
22
+ DATE = %w($Date: 2005/10/22 10:49:59 $)[1]
23
+
24
+ module_function
25
+ def run(targetfile = nil, output_path = nil)
26
+ unless targetfile
27
+ targetfile, output_path = check_options
28
+ end
29
+ unless targetfile
30
+ raise ArgumentError, _("no input files")
31
+ end
32
+ unless output_path
33
+ output_path = "messages.mo"
34
+ end
35
+
36
+ parser = PoParser.new
37
+ data = MOFile.new
38
+ parser.parse(File.open(targetfile).read, data)
39
+ data.save_to_file(output_path)
40
+ end
41
+
42
+ def check_options
43
+ output = nil
44
+
45
+ opts = OptionParser.new
46
+ opts.banner = _("Usage: %s input.po [-o output.mo]" % $0)
47
+ opts.separator("")
48
+ opts.separator(_("Generate binary message catalog from textual translation description."))
49
+ opts.separator("")
50
+ opts.separator(_("Specific options:"))
51
+
52
+ opts.on("-o", "--output=FILE", _("write output to specified file")) do |out|
53
+ output = out
54
+ end
55
+
56
+ opts.on_tail("--version", _("display version information and exit")) do
57
+ puts "#{$0} #{VERSION} (#{DATE})"
58
+ exit
59
+ end
60
+ opts.parse!(ARGV)
61
+
62
+ if ARGV.size == 0
63
+ puts opts.help
64
+ exit 1
65
+ end
66
+
67
+ [ARGV[0], output]
68
+ end
69
+ end
70
+
71
+ module_function
72
+ def rmsgfmt(targetfile = nil, output_path = nil)
73
+ RMsgfmt.run(targetfile, output_path)
74
+ end
75
+
76
+ def create_mofiles(verbose = false,
77
+ podir = "./po", targetdir = "./data/locale",
78
+ targetpath_rule = "%s/LC_MESSAGES")
79
+
80
+ modir = File.join(targetdir, targetpath_rule)
81
+ Dir.glob(File.join(podir, "*/*.po")) do |file|
82
+ lang, basename = /\/([^\/]+?)\/(.*)\.po/.match(file[podir.size..-1]).to_a[1,2]
83
+ outdir = modir % lang
84
+ FileUtils.mkdir_p(outdir) unless File.directory?(outdir)
85
+ rmsgfmt(file, File.join(outdir, "#{basename}.mo"))
86
+ if verbose
87
+ $stderr.puts %Q[#{file} -> #{File.join(outdir, "#{basename}.mo")}]
88
+ end
89
+ end
90
+ end
91
+ end
92
+
93
+ if $0 == __FILE__ then
94
+ GetText.rmsgfmt
95
+ end