gettext 1.9.0 → 1.10.0

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 (328) hide show
  1. data/ChangeLog +122 -1
  2. data/NEWS +21 -0
  3. data/README +30 -22
  4. data/data/locale/bs/LC_MESSAGES/rails.mo +0 -0
  5. data/data/locale/bs/LC_MESSAGES/rgettext.mo +0 -0
  6. data/data/locale/ca/LC_MESSAGES/rails.mo +0 -0
  7. data/data/locale/ca/LC_MESSAGES/rgettext.mo +0 -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/el/LC_MESSAGES/rails.mo +0 -0
  13. data/data/locale/el/LC_MESSAGES/rgettext.mo +0 -0
  14. data/data/locale/eo/LC_MESSAGES/rails.mo +0 -0
  15. data/data/locale/eo/LC_MESSAGES/rgettext.mo +0 -0
  16. data/data/locale/es/LC_MESSAGES/rails.mo +0 -0
  17. data/data/locale/es/LC_MESSAGES/rgettext.mo +0 -0
  18. data/data/locale/et/LC_MESSAGES/rails.mo +0 -0
  19. data/data/locale/fr/LC_MESSAGES/rails.mo +0 -0
  20. data/data/locale/fr/LC_MESSAGES/rgettext.mo +0 -0
  21. data/data/locale/hr/LC_MESSAGES/rails.mo +0 -0
  22. data/data/locale/hr/LC_MESSAGES/rgettext.mo +0 -0
  23. data/data/locale/it/LC_MESSAGES/rails.mo +0 -0
  24. data/data/locale/it/LC_MESSAGES/rgettext.mo +0 -0
  25. data/data/locale/ja/LC_MESSAGES/rails.mo +0 -0
  26. data/data/locale/ja/LC_MESSAGES/rgettext.mo +0 -0
  27. data/data/locale/ko/LC_MESSAGES/rails.mo +0 -0
  28. data/data/locale/ko/LC_MESSAGES/rgettext.mo +0 -0
  29. data/data/locale/nb/LC_MESSAGES/rails.mo +0 -0
  30. data/data/locale/nb/LC_MESSAGES/rgettext.mo +0 -0
  31. data/data/locale/nl/LC_MESSAGES/rails.mo +0 -0
  32. data/data/locale/nl/LC_MESSAGES/rgettext.mo +0 -0
  33. data/data/locale/pt_BR/LC_MESSAGES/rails.mo +0 -0
  34. data/data/locale/pt_BR/LC_MESSAGES/rgettext.mo +0 -0
  35. data/data/locale/ru/LC_MESSAGES/rails.mo +0 -0
  36. data/data/locale/ru/LC_MESSAGES/rgettext.mo +0 -0
  37. data/data/locale/sv/LC_MESSAGES/rgettext.mo +0 -0
  38. data/data/locale/vi/LC_MESSAGES/rails.mo +0 -0
  39. data/data/locale/vi/LC_MESSAGES/rgettext.mo +0 -0
  40. data/data/locale/zh/LC_MESSAGES/rails.mo +0 -0
  41. data/data/locale/zh/LC_MESSAGES/rgettext.mo +0 -0
  42. data/data/locale/zh_TW/LC_MESSAGES/rails.mo +0 -0
  43. data/data/locale/zh_TW/LC_MESSAGES/rgettext.mo +0 -0
  44. data/lib/gettext.rb +119 -37
  45. data/lib/gettext/active_record.rb +51 -31
  46. data/lib/gettext/locale_win32.rb +2 -1
  47. data/lib/gettext/parser/active_record.rb +2 -2
  48. data/lib/gettext/parser/ruby.rb +2 -2
  49. data/lib/gettext/poparser.rb +19 -14
  50. data/lib/gettext/rails.rb +104 -50
  51. data/lib/gettext/rails_compat.rb +16 -0
  52. data/lib/gettext/rgettext.rb +37 -3
  53. data/lib/gettext/textdomain.rb +45 -6
  54. data/lib/gettext/utils.rb +7 -0
  55. data/lib/gettext/version.rb +1 -1
  56. data/po/bs/rails.po +148 -0
  57. data/po/bs/rgettext.po +131 -0
  58. data/po/ca/rails.po +45 -26
  59. data/po/ca/rgettext.po +21 -21
  60. data/po/cs/rails.po +46 -24
  61. data/po/cs/rgettext.po +21 -21
  62. data/po/de/rails.po +46 -27
  63. data/po/de/rgettext.po +21 -21
  64. data/po/el/rails.po +46 -25
  65. data/po/el/rgettext.po +22 -22
  66. data/po/eo/rails.po +49 -30
  67. data/po/eo/rgettext.po +21 -21
  68. data/po/es/rails.po +45 -24
  69. data/po/es/rgettext.po +21 -21
  70. data/po/et/rails.po +49 -30
  71. data/po/fr/rails.po +47 -28
  72. data/po/fr/rgettext.po +31 -29
  73. data/po/hr/rails.po +148 -0
  74. data/po/hr/rgettext.po +131 -0
  75. data/po/it/rails.po +42 -24
  76. data/po/it/rgettext.po +21 -21
  77. data/po/ja/rails.po +43 -25
  78. data/po/ja/rgettext.po +21 -21
  79. data/po/ko/rails.po +44 -24
  80. data/po/ko/rgettext.po +21 -21
  81. data/po/nb/rails.po +140 -0
  82. data/po/nb/rgettext.po +127 -0
  83. data/po/nl/rails.po +50 -30
  84. data/po/nl/rgettext.po +21 -21
  85. data/po/pt_BR/rails.po +48 -29
  86. data/po/pt_BR/rgettext.po +21 -21
  87. data/po/rails.pot +42 -24
  88. data/po/rgettext.pot +21 -21
  89. data/po/ru/rails.po +50 -31
  90. data/po/ru/rgettext.po +21 -21
  91. data/po/sv/rgettext.po +21 -21
  92. data/po/vi/rails.po +141 -0
  93. data/po/vi/rgettext.po +126 -0
  94. data/po/zh/rails.po +60 -43
  95. data/po/zh/rgettext.po +22 -22
  96. data/po/zh_TW/rails.po +61 -43
  97. data/po/zh_TW/rgettext.po +22 -22
  98. data/samples/cgi/locale/bs/LC_MESSAGES/helloerb1.mo +0 -0
  99. data/samples/cgi/locale/bs/LC_MESSAGES/helloerb2.mo +0 -0
  100. data/samples/cgi/locale/bs/LC_MESSAGES/hellolib.mo +0 -0
  101. data/samples/cgi/locale/bs/LC_MESSAGES/main.mo +0 -0
  102. data/samples/cgi/locale/ca/LC_MESSAGES/helloerb1.mo +0 -0
  103. data/samples/cgi/locale/ca/LC_MESSAGES/helloerb2.mo +0 -0
  104. data/samples/cgi/locale/de/LC_MESSAGES/helloerb1.mo +0 -0
  105. data/samples/cgi/locale/de/LC_MESSAGES/helloerb2.mo +0 -0
  106. data/samples/cgi/locale/hr/LC_MESSAGES/helloerb1.mo +0 -0
  107. data/samples/cgi/locale/hr/LC_MESSAGES/helloerb2.mo +0 -0
  108. data/samples/cgi/locale/hr/LC_MESSAGES/hellolib.mo +0 -0
  109. data/samples/cgi/locale/hr/LC_MESSAGES/main.mo +0 -0
  110. data/samples/cgi/locale/it/LC_MESSAGES/helloerb1.mo +0 -0
  111. data/samples/cgi/locale/it/LC_MESSAGES/helloerb2.mo +0 -0
  112. data/samples/cgi/locale/ko/LC_MESSAGES/helloerb1.mo +0 -0
  113. data/samples/cgi/locale/ko/LC_MESSAGES/helloerb2.mo +0 -0
  114. data/samples/cgi/locale/nb/LC_MESSAGES/helloerb1.mo +0 -0
  115. data/samples/cgi/locale/nb/LC_MESSAGES/helloerb2.mo +0 -0
  116. data/samples/cgi/locale/nb/LC_MESSAGES/hellolib.mo +0 -0
  117. data/samples/cgi/locale/nb/LC_MESSAGES/main.mo +0 -0
  118. data/samples/cgi/locale/vi/LC_MESSAGES/helloerb1.mo +0 -0
  119. data/samples/cgi/locale/vi/LC_MESSAGES/helloerb2.mo +0 -0
  120. data/samples/cgi/locale/vi/LC_MESSAGES/hellolib.mo +0 -0
  121. data/samples/cgi/locale/vi/LC_MESSAGES/main.mo +0 -0
  122. data/samples/cgi/po/bs/helloerb1.po +59 -0
  123. data/samples/cgi/po/bs/helloerb2.po +51 -0
  124. data/samples/cgi/po/bs/hellolib.po +23 -0
  125. data/samples/cgi/po/bs/main.po +83 -0
  126. data/samples/cgi/po/hr/helloerb1.po +59 -0
  127. data/samples/cgi/po/hr/helloerb2.po +51 -0
  128. data/samples/cgi/po/hr/hellolib.po +23 -0
  129. data/samples/cgi/po/hr/main.po +83 -0
  130. data/samples/cgi/po/nb/helloerb1.po +58 -0
  131. data/samples/cgi/po/nb/helloerb2.po +50 -0
  132. data/samples/cgi/po/nb/hellolib.po +22 -0
  133. data/samples/cgi/po/nb/main.po +82 -0
  134. data/samples/cgi/po/vi/helloerb1.po +65 -0
  135. data/samples/cgi/po/vi/helloerb2.po +52 -0
  136. data/samples/cgi/po/vi/hellolib.po +24 -0
  137. data/samples/cgi/po/vi/main.po +77 -0
  138. data/samples/locale/bs/LC_MESSAGES/hello.mo +0 -0
  139. data/samples/locale/bs/LC_MESSAGES/hello2.mo +0 -0
  140. data/samples/locale/bs/LC_MESSAGES/hello_noop.mo +0 -0
  141. data/samples/locale/bs/LC_MESSAGES/hello_plural.mo +0 -0
  142. data/samples/locale/bs/LC_MESSAGES/helloglade2.mo +0 -0
  143. data/samples/locale/bs/LC_MESSAGES/hellogtk.mo +0 -0
  144. data/samples/locale/bs/LC_MESSAGES/hellotk.mo +0 -0
  145. data/samples/locale/hr/LC_MESSAGES/hello.mo +0 -0
  146. data/samples/locale/hr/LC_MESSAGES/hello2.mo +0 -0
  147. data/samples/locale/hr/LC_MESSAGES/hello_noop.mo +0 -0
  148. data/samples/locale/hr/LC_MESSAGES/hello_plural.mo +0 -0
  149. data/samples/locale/hr/LC_MESSAGES/helloglade2.mo +0 -0
  150. data/samples/locale/hr/LC_MESSAGES/hellogtk.mo +0 -0
  151. data/samples/locale/hr/LC_MESSAGES/hellotk.mo +0 -0
  152. data/samples/locale/ja/LC_MESSAGES/hello_plural.mo +0 -0
  153. data/samples/locale/nb/LC_MESSAGES/hello.mo +0 -0
  154. data/samples/locale/nb/LC_MESSAGES/hello2.mo +0 -0
  155. data/samples/locale/nb/LC_MESSAGES/hello_noop.mo +0 -0
  156. data/samples/locale/nb/LC_MESSAGES/hello_plural.mo +0 -0
  157. data/samples/locale/nb/LC_MESSAGES/helloglade2.mo +0 -0
  158. data/samples/locale/nb/LC_MESSAGES/hellogtk.mo +0 -0
  159. data/samples/locale/nb/LC_MESSAGES/hellotk.mo +0 -0
  160. data/samples/locale/vi/LC_MESSAGES/hello.mo +0 -0
  161. data/samples/locale/vi/LC_MESSAGES/hello2.mo +0 -0
  162. data/samples/locale/vi/LC_MESSAGES/hello_noop.mo +0 -0
  163. data/samples/locale/vi/LC_MESSAGES/hello_plural.mo +0 -0
  164. data/samples/locale/vi/LC_MESSAGES/helloglade2.mo +0 -0
  165. data/samples/locale/vi/LC_MESSAGES/hellogtk.mo +0 -0
  166. data/samples/locale/vi/LC_MESSAGES/hellotk.mo +0 -0
  167. data/samples/po/bs/hello.po +23 -0
  168. data/samples/po/bs/hello2.po +31 -0
  169. data/samples/po/bs/hello_noop.po +27 -0
  170. data/samples/po/bs/hello_plural.po +26 -0
  171. data/samples/po/bs/helloglade2.po +31 -0
  172. data/samples/po/bs/hellogtk.po +23 -0
  173. data/samples/po/bs/hellotk.po +23 -0
  174. data/samples/po/hr/hello.po +23 -0
  175. data/samples/po/hr/hello2.po +31 -0
  176. data/samples/po/hr/hello_noop.po +27 -0
  177. data/samples/po/hr/hello_plural.po +26 -0
  178. data/samples/po/hr/helloglade2.po +31 -0
  179. data/samples/po/hr/hellogtk.po +23 -0
  180. data/samples/po/hr/hellotk.po +23 -0
  181. data/samples/po/ja/hello_plural.po +1 -1
  182. data/samples/po/nb/hello.po +22 -0
  183. data/samples/po/nb/hello2.po +31 -0
  184. data/samples/po/nb/hello_noop.po +26 -0
  185. data/samples/po/nb/hello_plural.po +24 -0
  186. data/samples/po/nb/helloglade2.po +30 -0
  187. data/samples/po/nb/hellogtk.po +22 -0
  188. data/samples/po/nb/hellotk.po +22 -0
  189. data/samples/po/vi/hello.po +23 -0
  190. data/samples/po/vi/hello2.po +31 -0
  191. data/samples/po/vi/hello_noop.po +27 -0
  192. data/samples/po/vi/hello_plural.po +26 -0
  193. data/samples/po/vi/helloglade2.po +38 -0
  194. data/samples/po/vi/hellogtk.po +23 -0
  195. data/samples/po/vi/hellotk.po +24 -0
  196. data/samples/rails/locale/bs/LC_MESSAGES/blog.mo +0 -0
  197. data/samples/rails/locale/en/LC_MESSAGES/blog.mo +0 -0
  198. data/samples/rails/locale/hr/LC_MESSAGES/blog.mo +0 -0
  199. data/samples/rails/locale/nb/LC_MESSAGES/blog.mo +0 -0
  200. data/samples/rails/locale/vi/LC_MESSAGES/blog.mo +0 -0
  201. data/samples/rails/po/bs/blog.po +106 -0
  202. data/samples/rails/po/hr/blog.po +106 -0
  203. data/samples/rails/po/nb/blog.po +104 -0
  204. data/samples/rails/po/vi/blog.po +110 -0
  205. data/samples/rails/vendor/plugins/gettext/locale/bs/LC_MESSAGES/gettext_plugin.mo +0 -0
  206. data/samples/rails/vendor/plugins/gettext/locale/hr/LC_MESSAGES/gettext_plugin.mo +0 -0
  207. data/samples/rails/vendor/plugins/gettext/locale/nb/LC_MESSAGES/gettext_plugin.mo +0 -0
  208. data/samples/rails/vendor/plugins/gettext/locale/vi/LC_MESSAGES/gettext_plugin.mo +0 -0
  209. data/samples/rails/vendor/plugins/gettext/po/bs/gettext_plugin.po +27 -0
  210. data/samples/rails/vendor/plugins/gettext/po/hr/gettext_plugin.po +27 -0
  211. data/samples/rails/vendor/plugins/gettext/po/nb/gettext_plugin.po +27 -0
  212. data/samples/rails/vendor/plugins/gettext/po/vi/gettext_plugin.po +28 -0
  213. data/src/poparser.ry +9 -4
  214. data/test/README +2 -0
  215. data/test/Rakefile +2 -0
  216. data/test/db/mysql.drop.sql +4 -0
  217. data/test/db/mysql.sql +44 -0
  218. data/test/gettext_test.rb +51 -13
  219. data/test/gettext_test_active_record.rb +33 -0
  220. data/test/gettext_test_parser.rb +5 -0
  221. data/test/gettext_test_rails_caching.rb +211 -0
  222. data/test/locale/da/LC_MESSAGES/plural_error.mo +0 -0
  223. data/test/locale/fr/LC_MESSAGES/plural.mo +0 -0
  224. data/test/locale/fr/LC_MESSAGES/plural_error.mo +0 -0
  225. data/test/locale/ja/LC_MESSAGES/active_record.mo +0 -0
  226. data/test/locale/ja/LC_MESSAGES/plural.mo +0 -0
  227. data/test/locale/ja/LC_MESSAGES/plural_error.mo +0 -0
  228. data/test/locale/ja/LC_MESSAGES/test_nsgettext.mo +0 -0
  229. data/test/locale/ja/LC_MESSAGES/test_sgettext.mo +0 -0
  230. data/test/locale/la/LC_MESSAGES/plural_error.mo +0 -0
  231. data/test/po/da/plural_error.po +3 -3
  232. data/test/po/fr/plural.po +6 -0
  233. data/test/po/fr/plural_error.po +3 -3
  234. data/test/po/ja/plural.po +6 -0
  235. data/test/po/ja/plural_error.po +2 -2
  236. data/test/po/ja/test_nsgettext.po +65 -0
  237. data/test/po/la/plural_error.po +3 -3
  238. data/test/rails/README +5 -0
  239. data/test/rails/Rakefile +35 -0
  240. data/test/rails/app/controllers/application.rb +8 -0
  241. data/test/rails/app/controllers/articles_controller.rb +61 -0
  242. data/test/rails/app/controllers/mailer_controller.rb +19 -0
  243. data/test/rails/app/helpers/application_helper.rb +3 -0
  244. data/test/rails/app/helpers/articles_helper.rb +2 -0
  245. data/test/rails/app/helpers/mailer_helper.rb +2 -0
  246. data/test/rails/app/models/article.rb +5 -0
  247. data/test/rails/app/models/mailer.rb +38 -0
  248. data/test/rails/app/models/user.rb +3 -0
  249. data/test/rails/app/views/articles/_form.rhtml +13 -0
  250. data/test/rails/app/views/articles/edit.rhtml +9 -0
  251. data/test/rails/app/views/articles/list.rhtml +30 -0
  252. data/test/rails/app/views/articles/list_fr.rhtml +1 -0
  253. data/test/rails/app/views/articles/multi_error_messages_for.rhtml +19 -0
  254. data/test/rails/app/views/articles/new.rhtml +8 -0
  255. data/test/rails/app/views/articles/show.rhtml +28 -0
  256. data/test/rails/app/views/layouts/application.rhtml +14 -0
  257. data/test/rails/app/views/layouts/mailer.rhtml +20 -0
  258. data/test/rails/app/views/mailer/coverpage.rhtml +6 -0
  259. data/test/rails/app/views/mailer/coverpage_fr.rhtml +6 -0
  260. data/test/rails/app/views/mailer/singlepart.rhtml +3 -0
  261. data/test/rails/app/views/mailer/singlepart_fr.rhtml +3 -0
  262. data/test/rails/config/boot.rb +45 -0
  263. data/test/rails/config/database.yml +36 -0
  264. data/test/rails/config/environment.rb +64 -0
  265. data/test/rails/config/environments/development.rb +21 -0
  266. data/test/rails/config/environments/production.rb +18 -0
  267. data/test/rails/config/environments/test.rb +19 -0
  268. data/test/rails/config/routes.rb +23 -0
  269. data/test/rails/db/schema.rb +27 -0
  270. data/test/rails/log/development.log +29 -0
  271. data/test/rails/log/test.log +329 -0
  272. data/test/rails/po/ja/rails_test.po +142 -0
  273. data/test/rails/po/rails_test.pot +147 -0
  274. data/test/rails/public/404.html +30 -0
  275. data/test/rails/public/500.html +30 -0
  276. data/test/rails/public/dispatch.cgi +10 -0
  277. data/test/rails/public/dispatch.fcgi +24 -0
  278. data/test/rails/public/dispatch.rb +10 -0
  279. data/test/rails/public/favicon.ico +0 -0
  280. data/test/rails/public/images/rails.png +0 -0
  281. data/test/rails/public/index.html +277 -0
  282. data/test/rails/public/javascripts/application.js +2 -0
  283. data/test/rails/public/javascripts/controls.js +833 -0
  284. data/test/rails/public/javascripts/dragdrop.js +942 -0
  285. data/test/rails/public/javascripts/effects.js +1088 -0
  286. data/test/rails/public/javascripts/prototype.js +2515 -0
  287. data/test/rails/public/robots.txt +1 -0
  288. data/test/rails/public/stylesheets/scaffold.css +74 -0
  289. data/test/rails/script/about +3 -0
  290. data/test/rails/script/breakpointer +3 -0
  291. data/test/rails/script/console +3 -0
  292. data/test/rails/script/destroy +3 -0
  293. data/test/rails/script/generate +3 -0
  294. data/test/rails/script/performance/benchmarker +3 -0
  295. data/test/rails/script/performance/profiler +3 -0
  296. data/test/rails/script/plugin +3 -0
  297. data/test/rails/script/process/inspector +3 -0
  298. data/test/rails/script/process/reaper +3 -0
  299. data/test/rails/script/process/spawner +3 -0
  300. data/test/rails/script/runner +3 -0
  301. data/test/rails/script/server +3 -0
  302. data/test/rails/test/fixtures/articles.yml +11 -0
  303. data/test/rails/test/functional/articles_controller_test.rb +109 -0
  304. data/test/rails/test/functional/mailer_controller_test.rb +93 -0
  305. data/test/rails/test/integration/general_stories_test.rb +58 -0
  306. data/test/rails/test/result/en/create_error.html +95 -0
  307. data/test/rails/test/result/en/list.html +65 -0
  308. data/test/rails/test/result/en/multi_error_messages_for.html +153 -0
  309. data/test/rails/test/result/en/multipart.html +67 -0
  310. data/test/rails/test/result/en/new.html +95 -0
  311. data/test/rails/test/result/en/show.html +50 -0
  312. data/test/rails/test/result/en/singlepart.html +10 -0
  313. data/test/rails/test/result/fr/list.html +15 -0
  314. data/test/rails/test/result/fr/multipart.html +67 -0
  315. data/test/rails/test/result/fr/singlepart.html +10 -0
  316. data/test/rails/test/result/ja/create_error.html +95 -0
  317. data/test/rails/test/result/ja/list.html +65 -0
  318. data/test/rails/test/result/ja/multi_error_messages_for.html +153 -0
  319. data/test/rails/test/result/ja/multipart.html +67 -0
  320. data/test/rails/test/result/ja/new.html +95 -0
  321. data/test/rails/test/result/ja/show.html +50 -0
  322. data/test/rails/test/result/ja/singlepart.html +10 -0
  323. data/test/rails/test/test_helper.rb +28 -0
  324. data/test/rails/test/unit/article_test.rb +18 -0
  325. data/test/test.sh +4 -0
  326. data/test/test_nsgettext.rb +44 -0
  327. data/test/test_rubyparser_n_.rb +10 -0
  328. metadata +587 -288
@@ -6,10 +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: active_record.rb,v 1.14 2007/01/21 15:16:06 mutoh Exp $
9
+ $Id: active_record.rb,v 1.21 2007/07/04 15:51:30 mutoh Exp $
10
10
  =end
11
11
  require 'gettext'
12
12
  require 'active_record'
13
+ require 'gettext/rails_compat'
13
14
 
14
15
  module ActiveRecord #:nodoc:
15
16
  class Migration
@@ -36,41 +37,61 @@ module ActiveRecord #:nodoc:
36
37
  attr_accessor :table_class
37
38
  alias :human_name_witout_localized :human_name
38
39
 
39
- def human_name
40
- table_class.human_attribute_name(@name)
40
+ def human_name_with_gettext
41
+ if table_class
42
+ table_class.human_attribute_name(@name)
43
+ else
44
+ @name.humanize
45
+ end
41
46
  end
47
+ alias_method_chain :human_name, :gettext
42
48
  end
43
49
  end
44
50
 
45
51
  module Validations # :nodoc:
46
- def self.real_included(base)
47
- base.extend ClassMethods
48
- base.class_eval{
49
- include GetText
50
- def gettext(str) #:nodoc:
51
- _(str)
52
- end
53
- def self.human_attribute_name(attribute_key_name) #:nodoc:
54
- s_("#{self}|#{attribute_key_name.humanize}")
55
- end
56
-
57
- def self.human_attribute_table_name_for_error(table_name) #:nodoc:
58
- _(table_name.gsub(/_/, " "))
59
- end
60
- }
61
- end
62
- if respond_to? :included
63
- def self.included(base) # :nodoc:
64
- super
65
- real_included(base)
52
+ class << self
53
+ def real_included(base)
54
+ base.extend ClassMethods
55
+ base.class_eval{
56
+ include GetText
57
+ def gettext(str) #:nodoc:
58
+ _(str)
59
+ end
60
+ class << self
61
+ def human_attribute_name_with_gettext(attribute_key_name) #:nodoc:
62
+ s_("#{self}|#{attribute_key_name.humanize}")
63
+ end
64
+ alias_method_chain :human_attribute_name, :gettext
65
+ def human_attribute_table_name_for_error(table_name) #:nodoc:
66
+ _(table_name.gsub(/_/, " "))
67
+ end
68
+ end
69
+ }
70
+ end
66
71
  end
67
- else
68
- # Since rails-1.2.0.
69
- def self.append_features(base) # :nodoc:
70
- super
71
- real_included(base)
72
+
73
+ if respond_to? :included
74
+ class << self
75
+ def included_with_gettext(base) # :nodoc:
76
+ unless base <= ActiveRecord::Base
77
+ included_without_gettext(base)
78
+ end
79
+ real_included(base)
80
+ end
81
+ alias_method_chain :included, :gettext
82
+ end
83
+ else
84
+ class << self
85
+ # Since rails-1.2.0.
86
+ def append_features_with_gettext(base) # :nodoc:
87
+ unless base <= ActiveRecord::Base
88
+ append_features_without_gettext(base)
89
+ end
90
+ real_included(base)
91
+ end
92
+ alias_method_chain :append_features, :gettext
93
+ end
72
94
  end
73
- end
74
95
 
75
96
  module ClassMethods #:nodoc:
76
97
  @@custom_error_messages_d = {}
@@ -137,10 +158,9 @@ end
137
158
  @columns = nil
138
159
  end
139
160
  unless @columns
140
- @columns = connection.columns(table_name, "#{name} Columns")
161
+ @columns = columns_without_gettext
141
162
  @columns.each {|column|
142
163
  column.table_class = self
143
- column.primary = column.name == primary_key
144
164
  }
145
165
  end
146
166
  @columns
@@ -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.15 2006/12/14 16:35:57 mutoh Exp $
9
+ $Id: locale_win32.rb,v 1.16 2007/07/03 16:57:07 mutoh Exp $
10
10
  =end
11
11
 
12
12
  require 'gettext/locale_table_win32'
@@ -26,6 +26,7 @@ module Locale
26
26
  # * Returns the charset of the locale
27
27
  def get_charset(locale)
28
28
  loc = LocaleTable.find{|v| v[1] == locale.to_win}
29
+ loc = LocaleTable.find{|v| v[1] =~ /^#{locale.language}-/} unless loc
29
30
  loc ? loc[2] : "CP1252"
30
31
  end
31
32
 
@@ -7,7 +7,7 @@
7
7
  You may redistribute it and/or modify it under the same
8
8
  license terms as Ruby.
9
9
 
10
- $Id: active_record.rb,v 1.5 2007/01/21 15:16:06 mutoh Exp $
10
+ $Id: active_record.rb,v 1.6 2007/07/03 01:58:47 mutoh Exp $
11
11
  =end
12
12
 
13
13
  require 'gettext'
@@ -141,7 +141,7 @@ module GetText
141
141
  ENV["RAILS_ENV"] = @config[:db_mode]
142
142
  require 'config/boot.rb'
143
143
  require 'config/environment.rb'
144
- require 'app/controllers/application.rb'
144
+ # require 'app/controllers/application.rb'
145
145
  rescue LoadError
146
146
  require_rails 'rubygems'
147
147
  if Kernel.respond_to? :gem
@@ -9,7 +9,7 @@
9
9
  You may redistribute it and/or modify it under the same
10
10
  license terms as Ruby.
11
11
 
12
- $Id: ruby.rb,v 1.9 2007/01/13 18:34:08 mutoh Exp $
12
+ $Id: ruby.rb,v 1.10 2007/07/02 16:40:18 mutoh Exp $
13
13
  =end
14
14
 
15
15
  require 'irb/ruby-lex.rb'
@@ -62,7 +62,7 @@ end
62
62
  module GetText
63
63
  module RubyParser
64
64
  ID = ['gettext', '_', 'N_', 'sgettext', 's_']
65
- PLURAL_ID = ['ngettext', 'n_', 'Nn_']
65
+ PLURAL_ID = ['ngettext', 'n_', 'Nn_', 'ns_', 'nsgettext']
66
66
 
67
67
  module_function
68
68
  def parse(file, targets = []) # :nodoc:
@@ -9,7 +9,7 @@
9
9
 
10
10
  #
11
11
  # DO NOT MODIFY!!!!
12
- # This file is automatically generated by racc 1.4.4
12
+ # This file is automatically generated by racc 1.4.5
13
13
  # from racc grammer file "src/poparser.ry".
14
14
  #
15
15
 
@@ -20,7 +20,7 @@ module GetText
20
20
 
21
21
  class PoParser < Racc::Parser
22
22
 
23
- module_eval <<'..end src/poparser.ry modeval..idf3e4511031', 'src/poparser.ry', 90
23
+ module_eval <<'..end src/poparser.ry modeval..id99edf64163', 'src/poparser.ry', 94
24
24
  include GetText
25
25
  GetText.bindtextdomain("rgettext")
26
26
 
@@ -56,7 +56,7 @@ module_eval <<'..end src/poparser.ry modeval..idf3e4511031', 'src/poparser.ry',
56
56
  @q.push [:PLURAL_NUM, $1]
57
57
  str = $'
58
58
  when /\A\#~(.*)/
59
- $stderr.print _("Warning: obsolete msgid is existed.\n")
59
+ $stderr.print _("Warning: obsolete msgid exists.\n")
60
60
  $stderr.print " #{$&}\n"
61
61
  @q.push [:COMMENT, $&]
62
62
  str = $'
@@ -92,9 +92,10 @@ module_eval <<'..end src/poparser.ry modeval..idf3e4511031', 'src/poparser.ry',
92
92
  end
93
93
 
94
94
  def on_message(msgid, msgstr)
95
- @data[msgid] = msgstr
96
-
97
- @data.set_comment(msgid, @comments.join("\n"))
95
+ if msgstr.size > 0
96
+ @data[msgid] = msgstr
97
+ @data.set_comment(msgid, @comments.join("\n"))
98
+ end
98
99
  @comments.clear
99
100
  end
100
101
 
@@ -103,9 +104,9 @@ module_eval <<'..end src/poparser.ry modeval..idf3e4511031', 'src/poparser.ry',
103
104
  @comments << comment
104
105
  end
105
106
 
106
- ..end src/poparser.ry modeval..idf3e4511031
107
+ ..end src/poparser.ry modeval..id99edf64163
107
108
 
108
- ##### racc 1.4.4 generates ###
109
+ ##### racc 1.4.5 generates ###
109
110
 
110
111
  racc_reduce_table = [
111
112
  0, 0, :racc_error,
@@ -252,37 +253,41 @@ module_eval <<'.,.,', 'src/poparser.ry', 51
252
253
  end
253
254
  .,.,
254
255
 
255
- module_eval <<'.,.,', 'src/poparser.ry', 58
256
+ module_eval <<'.,.,', 'src/poparser.ry', 62
256
257
  def _reduce_6( val, _values, result )
257
- result = val[0] + "\000" + val[1]
258
+ if val[0].size > 0
259
+ result = val[0] + "\000" + val[1]
260
+ else
261
+ result = ""
262
+ end
258
263
  result
259
264
  end
260
265
  .,.,
261
266
 
262
267
  # reduce 7 omitted
263
268
 
264
- module_eval <<'.,.,', 'src/poparser.ry', 66
269
+ module_eval <<'.,.,', 'src/poparser.ry', 70
265
270
  def _reduce_8( val, _values, result )
266
271
  result = val[2]
267
272
  result
268
273
  end
269
274
  .,.,
270
275
 
271
- module_eval <<'.,.,', 'src/poparser.ry', 73
276
+ module_eval <<'.,.,', 'src/poparser.ry', 77
272
277
  def _reduce_9( val, _values, result )
273
278
  on_comment(val[0])
274
279
  result
275
280
  end
276
281
  .,.,
277
282
 
278
- module_eval <<'.,.,', 'src/poparser.ry', 81
283
+ module_eval <<'.,.,', 'src/poparser.ry', 85
279
284
  def _reduce_10( val, _values, result )
280
285
  result = val.delete_if{|item| item == ""}.join
281
286
  result
282
287
  end
283
288
  .,.,
284
289
 
285
- module_eval <<'.,.,', 'src/poparser.ry', 85
290
+ module_eval <<'.,.,', 'src/poparser.ry', 89
286
291
  def _reduce_11( val, _values, result )
287
292
  result = val[0]
288
293
  result
data/lib/gettext/rails.rb CHANGED
@@ -6,11 +6,12 @@
6
6
  You may redistribute it and/or modify it under the same
7
7
  license terms as Ruby.
8
8
 
9
- $Id: rails.rb,v 1.55 2007/01/21 15:16:06 mutoh Exp $
9
+ $Id: rails.rb,v 1.63 2007/07/05 16:55:59 mutoh Exp $
10
10
  =end
11
11
 
12
12
  require 'gettext/cgi'
13
13
  require 'action_controller'
14
+ require 'gettext/rails_compat'
14
15
 
15
16
  module GetText
16
17
  # GetText::Rails supports Ruby on Rails.
@@ -237,11 +238,27 @@ module ActionController #:nodoc:
237
238
  end
238
239
 
239
240
  class TestRequest < AbstractRequest #:nodoc:
241
+ class GetTextMockCGI < CGI #:nodoc:
242
+ attr_accessor :stdinput, :stdoutput, :env_table
243
+
244
+ def initialize(env, input=nil)
245
+ self.env_table = env
246
+ self.stdinput = StringIO.new(input || "")
247
+ self.stdoutput = StringIO.new
248
+
249
+ super()
250
+ end
251
+ end
252
+
240
253
  @cgi = nil
241
254
  def cgi
242
255
  unless @cgi
243
- ENV['REQUEST_URI'] ||= "http://localhost:3000/"
244
- @cgi = CGI.new
256
+ @cgi = GetTextMockCGI.new("REQUEST_METHOD" => "GET",
257
+ "QUERY_STRING" => "",
258
+ "REQUEST_URI" => "/",
259
+ "HTTP_HOST" => "www.example.com",
260
+ "SERVER_PORT" => "80",
261
+ "HTTPS" => "off")
245
262
  end
246
263
  @cgi
247
264
  end
@@ -310,50 +327,64 @@ module ActionView #:nodoc:
310
327
  end
311
328
  @error_message_explanation = [single_msg, plural_msg]
312
329
  end
313
-
314
- def error_message_title #:nodoc:
315
- if @error_message_title
316
- [_(@error_message_title[0]), _(@error_message_title[1])]
317
- else
318
- nil
319
- end
320
- end
321
- def error_message_explanation #:nodoc:
322
- if @error_message_explanation
323
- [_(@error_message_explanation[0]), _(@error_message_explanation[1])]
324
- else
325
- nil
326
- end
327
- end
328
330
 
329
- def render_error_message(object, klass, record, count, options)
330
- message_title = @error_message_title
331
- message_explanation = @error_message_explanation
332
-
333
- klass.content_tag("div",
334
- klass.content_tag(
335
- options[:header_tag] || "h2",
336
- n_(message_title, count) % {:num => count, :record => record}
337
- ) +
338
- klass.content_tag("p", n_(message_explanation, count) % {:num => count}) +
339
- klass.content_tag("ul", object.errors.full_messages.collect { |msg| klass.content_tag("li", msg) }),
340
- "id" => options[:id] || "errorExplanation", "class" => options[:class] || "errorExplanation"
341
- )
342
- end
343
331
 
344
- def error_messages_for(object, object_name, klass, options = {})
345
- options = options.symbolize_keys
346
-
347
- if object && ! object.errors.empty?
348
- count = object.errors.count
349
- record = ActiveRecord::Base.human_attribute_table_name_for_error(object_name.to_s)
350
- render_error_message(object, klass, record, count, options)
351
- end
332
+ def error_messages_for(instance, objects, object_names, count, options)
333
+ record = ActiveRecord::Base.human_attribute_table_name_for_error(options[:object_name] || object_names[0].to_s)
334
+
335
+ message_title = instance.error_message_title(@error_message_title)
336
+ message_explanation = instance.error_message_explanation(@error_message_explanation)
337
+
338
+ html = {}
339
+ [:id, :class].each do |key|
340
+ if options.include?(key)
341
+ value = options[key]
342
+ html[key] = value unless value.blank?
343
+ else
344
+ html[key] = 'errorExplanation'
345
+ end
346
+ end
347
+
348
+ header_message = n_(message_title, count) % {:num => count, :record => record}
349
+ error_messages = objects.map {|object| object.errors.full_messages.map {|msg| instance.content_tag(:li, msg) } }
350
+
351
+ instance.content_tag(:div,
352
+ instance.content_tag(options[:header_tag] || :h2, header_message) <<
353
+ instance.content_tag(:p, n_(message_explanation, count) % {:num => count}) <<
354
+ instance.content_tag(:ul, error_messages),
355
+ html
356
+ )
352
357
  end
353
358
  end
354
- def error_messages_for(object_name, options = {})
355
- object = instance_variable_get("@#{object_name}")
356
- L10n.error_messages_for(object, object_name, self, options)
359
+
360
+ def error_message_title(msg) #:nodoc:
361
+ if msg
362
+ [_(msg[0]), _(msg[1])]
363
+ else
364
+ nil
365
+ end
366
+ end
367
+
368
+ def error_message_explanation(msg) #:nodoc:
369
+ if msg
370
+ [_(msg[0]), _(msg[1])]
371
+ else
372
+ nil
373
+ end
374
+ end
375
+
376
+ alias error_messages_for_without_localize error_messages_for #:nodoc:
377
+
378
+ def error_messages_for(*params)
379
+ options = params.last.is_a?(Hash) ? params.pop.symbolize_keys : {}
380
+ objects = params.collect {|object_name| instance_variable_get("@#{object_name}") }.compact
381
+ object_names = params.dup
382
+ count = objects.inject(0) {|sum, object| sum + object.errors.count }
383
+ if count.zero?
384
+ ''
385
+ else
386
+ L10n.error_messages_for(self, objects, object_names, count, options)
387
+ end
357
388
  end
358
389
  end
359
390
 
@@ -363,17 +394,19 @@ module ActionView #:nodoc:
363
394
 
364
395
  # This is FAKE constant. The messages are found by rgettext as the msgid.
365
396
  MESSAGESS = [N_('less than 5 seconds'), N_('less than 10 seconds'), N_('less than 20 seconds'),
366
- N_('half a minute'), N_('less than a minute')]
367
- MINUTES = [/^(\d+) minutes?$/, Nn_('1 minute', '%{num} minutes')]
368
- HOURS = [/^about (\d+) hours?$/, Nn_('about 1 hour', 'about %{num} hours')]
369
- DAYS = [/^(\d+) days?$/, Nn_('1 day', '%{num} days')]
397
+ N_('half a minute'), N_('less than a minute'), N_('about 1 month'),
398
+ N_('about 1 year'), N_('over 2 years')]
399
+ NMINUTES = [/^(\d+) minutes?$/, Nn_('1 minute', '%{num} minutes')]
400
+ NHOURS = [/^about (\d+) hours?$/, Nn_('about 1 hour', 'about %{num} hours')]
401
+ NDAYS = [/^(\d+) days?$/, Nn_('1 day', '%{num} days')]
402
+ NMONTHS = [/^(\d+) months?$/, Nn_('1 month', '%{num} months')]
370
403
 
371
404
  def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false)
372
405
  textdomain("rails")
373
406
 
374
407
  msg = distance_of_time_in_words_without_locale(from_time, to_time, include_seconds)
375
408
  match = false
376
- [MINUTES, HOURS, DAYS].each do |regexp, nn|
409
+ [NMINUTES, NHOURS, NDAYS, NMONTHS].each do |regexp, nn|
377
410
  if regexp =~ msg
378
411
  match = true
379
412
  msg = n_(nn, $1.to_i) % {:num => $1}
@@ -416,8 +449,29 @@ if defined? ActionMailer
416
449
  part.body = NKF.nkf('-j', part.body)
417
450
  end
418
451
  end
419
- @mail
452
+ @mail
453
+ end
454
+ end
455
+ end
456
+ end
457
+
458
+ module ActionController #:nodoc: all
459
+ module Caching
460
+ module Fragments
461
+ def fragment_cache_key_with_gettext(name)
462
+ fragment_cache_key_without_gettext(name).gsub('?', '.').gsub(/:/, ".") << "_#{Locale.current}"
463
+ end
464
+ alias_method_chain :fragment_cache_key, :gettext
465
+
466
+ def expire_fragment_with_gettext(name, options = nil)
467
+ return unless perform_caching
468
+
469
+ key = %r{#{fragment_cache_key_without_gettext(name).gsub('?', '.').gsub(/:/, ".")}}
470
+ self.class.benchmark "Expired fragments matching: #{key.source}" do
471
+ fragment_cache_store.delete_matched(key, options)
472
+ end
420
473
  end
474
+ alias_method_chain :expire_fragment, :gettext
421
475
  end
422
476
  end
423
477
  end
@@ -432,7 +486,7 @@ end
432
486
 
433
487
 
434
488
  if ::RAILS_ENV == "development"
435
- GetText::TextDomain.check_mo = true
489
+ GetText.cached = false
436
490
  end
437
491
 
438
492
  require 'gettext/active_record'