gettext 2.2.1 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (500) hide show
  1. data/COPYING +2 -1
  2. data/README.rdoc +9 -9
  3. data/Rakefile +94 -149
  4. data/bin/rmsgfmt +23 -20
  5. data/bin/rmsginit +29 -0
  6. data/bin/rmsgmerge +22 -20
  7. data/bin/rxgettext +24 -0
  8. data/doc/text/news.md +60 -0
  9. data/gettext.gemspec +7 -4
  10. data/lib/gettext.rb +3 -3
  11. data/lib/gettext/core_ext/string.rb +2 -1
  12. data/lib/gettext/runtime/locale_path.rb +6 -4
  13. data/lib/gettext/runtime/textdomain.rb +14 -8
  14. data/lib/gettext/runtime/textdomain_manager.rb +3 -3
  15. data/lib/gettext/task.rb +203 -0
  16. data/lib/gettext/tools.rb +33 -24
  17. data/lib/gettext/tools/msgfmt.rb +104 -0
  18. data/lib/gettext/tools/msginit.rb +363 -0
  19. data/lib/gettext/tools/msgmerge.rb +510 -0
  20. data/lib/gettext/tools/parser/ruby.rb +12 -17
  21. data/lib/gettext/tools/pomessage.rb +37 -4
  22. data/lib/gettext/tools/poparser.rb +27 -24
  23. data/lib/gettext/tools/xgettext.rb +327 -0
  24. data/lib/gettext/version.rb +2 -2
  25. data/po/bg/rgettext.po +2 -2
  26. data/po/bs/rgettext.po +2 -2
  27. data/po/ca/rgettext.po +2 -2
  28. data/po/cs/rgettext.po +2 -2
  29. data/po/de/gettext.po +668 -0
  30. data/po/de/gettext.po.bak +589 -0
  31. data/po/de/rgettext.po +2 -2
  32. data/po/el/gettext.po +571 -0
  33. data/po/el/rgettext.po +2 -2
  34. data/po/eo/rgettext.po +2 -2
  35. data/po/es/rgettext.po +2 -2
  36. data/po/et/rgettext.po +2 -2
  37. data/po/fr/gettext.po +589 -0
  38. data/po/fr/rgettext.po +2 -2
  39. data/po/gettext.pot +638 -0
  40. data/po/gettext.pot~ +638 -0
  41. data/po/hr/rgettext.po +2 -2
  42. data/po/hu/rgettext.po +2 -2
  43. data/po/it/gettext.po +589 -0
  44. data/po/it/rgettext.po +2 -2
  45. data/po/ja/gettext.po +591 -0
  46. data/po/ja/rgettext.po +112 -69
  47. data/po/ko/rgettext.po +2 -2
  48. data/po/lv/rgettext.po +2 -2
  49. data/po/nb/rgettext.po +2 -2
  50. data/po/nl/rgettext.po +2 -2
  51. data/po/pt_BR/rgettext.po +2 -2
  52. data/po/ru/rgettext.po +2 -2
  53. data/po/sr/rgettext.po +2 -2
  54. data/po/sv/rgettext.po +2 -2
  55. data/po/uk/gettext.po +571 -0
  56. data/po/uk/rgettext.po +2 -2
  57. data/po/vi/rgettext.po +2 -2
  58. data/po/zh/rgettext.po +2 -2
  59. data/po/zh_TW/rgettext.po +2 -2
  60. data/samples/README +2 -4
  61. data/samples/cgi/README +1 -1
  62. data/samples/cgi/cookie.cgi +1 -1
  63. data/samples/cgi/gettext.css +1 -1
  64. data/samples/cgi/helloerb.rhtml +1 -1
  65. data/samples/cgi/hellolib.rb +1 -1
  66. data/samples/cgi/http.rb +2 -2
  67. data/samples/cgi/index.cgi +1 -1
  68. data/samples/cgi/locale/bg/LC_MESSAGES/helloerb1.mo +0 -0
  69. data/samples/cgi/locale/bg/LC_MESSAGES/helloerb2.mo +0 -0
  70. data/samples/cgi/locale/bg/LC_MESSAGES/main.mo +0 -0
  71. data/samples/cgi/locale/bs/LC_MESSAGES/helloerb1.mo +0 -0
  72. data/samples/cgi/locale/bs/LC_MESSAGES/helloerb2.mo +0 -0
  73. data/samples/cgi/locale/bs/LC_MESSAGES/main.mo +0 -0
  74. data/samples/cgi/locale/ca/LC_MESSAGES/helloerb1.mo +0 -0
  75. data/samples/cgi/locale/ca/LC_MESSAGES/helloerb2.mo +0 -0
  76. data/samples/cgi/locale/ca/LC_MESSAGES/main.mo +0 -0
  77. data/samples/cgi/locale/cs/LC_MESSAGES/helloerb1.mo +0 -0
  78. data/samples/cgi/locale/cs/LC_MESSAGES/helloerb2.mo +0 -0
  79. data/samples/cgi/locale/cs/LC_MESSAGES/main.mo +0 -0
  80. data/samples/cgi/locale/de/LC_MESSAGES/helloerb1.mo +0 -0
  81. data/samples/cgi/locale/de/LC_MESSAGES/helloerb2.mo +0 -0
  82. data/samples/cgi/locale/de/LC_MESSAGES/main.mo +0 -0
  83. data/samples/cgi/locale/el/LC_MESSAGES/helloerb1.mo +0 -0
  84. data/samples/cgi/locale/el/LC_MESSAGES/helloerb2.mo +0 -0
  85. data/samples/cgi/locale/el/LC_MESSAGES/main.mo +0 -0
  86. data/samples/cgi/locale/eo/LC_MESSAGES/helloerb1.mo +0 -0
  87. data/samples/cgi/locale/eo/LC_MESSAGES/helloerb2.mo +0 -0
  88. data/samples/cgi/locale/eo/LC_MESSAGES/main.mo +0 -0
  89. data/samples/cgi/locale/es/LC_MESSAGES/helloerb1.mo +0 -0
  90. data/samples/cgi/locale/es/LC_MESSAGES/helloerb2.mo +0 -0
  91. data/samples/cgi/locale/es/LC_MESSAGES/main.mo +0 -0
  92. data/samples/cgi/locale/fr/LC_MESSAGES/helloerb1.mo +0 -0
  93. data/samples/cgi/locale/fr/LC_MESSAGES/helloerb2.mo +0 -0
  94. data/samples/cgi/locale/fr/LC_MESSAGES/main.mo +0 -0
  95. data/samples/cgi/locale/hr/LC_MESSAGES/helloerb1.mo +0 -0
  96. data/samples/cgi/locale/hr/LC_MESSAGES/helloerb2.mo +0 -0
  97. data/samples/cgi/locale/hr/LC_MESSAGES/main.mo +0 -0
  98. data/samples/cgi/locale/hu/LC_MESSAGES/helloerb1.mo +0 -0
  99. data/samples/cgi/locale/hu/LC_MESSAGES/helloerb2.mo +0 -0
  100. data/samples/cgi/locale/hu/LC_MESSAGES/main.mo +0 -0
  101. data/samples/cgi/locale/it/LC_MESSAGES/helloerb1.mo +0 -0
  102. data/samples/cgi/locale/it/LC_MESSAGES/helloerb2.mo +0 -0
  103. data/samples/cgi/locale/it/LC_MESSAGES/main.mo +0 -0
  104. data/samples/cgi/locale/ja/LC_MESSAGES/helloerb1.mo +0 -0
  105. data/samples/cgi/locale/ja/LC_MESSAGES/helloerb2.mo +0 -0
  106. data/samples/cgi/locale/ja/LC_MESSAGES/main.mo +0 -0
  107. data/samples/cgi/locale/ko/LC_MESSAGES/helloerb1.mo +0 -0
  108. data/samples/cgi/locale/ko/LC_MESSAGES/helloerb2.mo +0 -0
  109. data/samples/cgi/locale/ko/LC_MESSAGES/main.mo +0 -0
  110. data/samples/cgi/locale/lv/LC_MESSAGES/helloerb1.mo +0 -0
  111. data/samples/cgi/locale/lv/LC_MESSAGES/helloerb2.mo +0 -0
  112. data/samples/cgi/locale/lv/LC_MESSAGES/main.mo +0 -0
  113. data/samples/cgi/locale/nb/LC_MESSAGES/helloerb1.mo +0 -0
  114. data/samples/cgi/locale/nb/LC_MESSAGES/helloerb2.mo +0 -0
  115. data/samples/cgi/locale/nb/LC_MESSAGES/main.mo +0 -0
  116. data/samples/cgi/locale/nl/LC_MESSAGES/helloerb1.mo +0 -0
  117. data/samples/cgi/locale/nl/LC_MESSAGES/helloerb2.mo +0 -0
  118. data/samples/cgi/locale/nl/LC_MESSAGES/main.mo +0 -0
  119. data/samples/cgi/locale/pt_BR/LC_MESSAGES/helloerb1.mo +0 -0
  120. data/samples/cgi/locale/pt_BR/LC_MESSAGES/helloerb2.mo +0 -0
  121. data/samples/cgi/locale/pt_BR/LC_MESSAGES/main.mo +0 -0
  122. data/samples/cgi/locale/ru/LC_MESSAGES/helloerb1.mo +0 -0
  123. data/samples/cgi/locale/ru/LC_MESSAGES/helloerb2.mo +0 -0
  124. data/samples/cgi/locale/ru/LC_MESSAGES/main.mo +0 -0
  125. data/samples/cgi/locale/sr/LC_MESSAGES/helloerb1.mo +0 -0
  126. data/samples/cgi/locale/sr/LC_MESSAGES/helloerb2.mo +0 -0
  127. data/samples/cgi/locale/sr/LC_MESSAGES/main.mo +0 -0
  128. data/samples/cgi/locale/uk/LC_MESSAGES/helloerb1.mo +0 -0
  129. data/samples/cgi/locale/uk/LC_MESSAGES/helloerb2.mo +0 -0
  130. data/samples/cgi/locale/uk/LC_MESSAGES/main.mo +0 -0
  131. data/samples/cgi/locale/vi/LC_MESSAGES/helloerb1.mo +0 -0
  132. data/samples/cgi/locale/vi/LC_MESSAGES/helloerb2.mo +0 -0
  133. data/samples/cgi/locale/vi/LC_MESSAGES/main.mo +0 -0
  134. data/samples/cgi/locale/zh/LC_MESSAGES/helloerb1.mo +0 -0
  135. data/samples/cgi/locale/zh/LC_MESSAGES/helloerb2.mo +0 -0
  136. data/samples/cgi/locale/zh/LC_MESSAGES/main.mo +0 -0
  137. data/samples/cgi/locale/zh_TW/LC_MESSAGES/helloerb1.mo +0 -0
  138. data/samples/cgi/locale/zh_TW/LC_MESSAGES/helloerb2.mo +0 -0
  139. data/samples/cgi/locale/zh_TW/LC_MESSAGES/main.mo +0 -0
  140. data/samples/cgi/other.rhtml +1 -1
  141. data/samples/cgi/po/bg/helloerb1.po +4 -4
  142. data/samples/cgi/po/bg/helloerb2.po +4 -4
  143. data/samples/cgi/po/bg/hellolib.po +2 -2
  144. data/samples/cgi/po/bg/main.po +4 -4
  145. data/samples/cgi/po/bs/helloerb1.po +3 -3
  146. data/samples/cgi/po/bs/helloerb2.po +3 -3
  147. data/samples/cgi/po/bs/hellolib.po +2 -2
  148. data/samples/cgi/po/bs/main.po +3 -3
  149. data/samples/cgi/po/ca/helloerb1.po +4 -4
  150. data/samples/cgi/po/ca/helloerb2.po +4 -4
  151. data/samples/cgi/po/ca/hellolib.po +2 -2
  152. data/samples/cgi/po/ca/main.po +4 -4
  153. data/samples/cgi/po/cs/helloerb1.po +4 -4
  154. data/samples/cgi/po/cs/helloerb2.po +4 -4
  155. data/samples/cgi/po/cs/hellolib.po +2 -2
  156. data/samples/cgi/po/cs/main.po +4 -4
  157. data/samples/cgi/po/de/helloerb1.po +3 -3
  158. data/samples/cgi/po/de/helloerb2.po +3 -3
  159. data/samples/cgi/po/de/hellolib.po +2 -2
  160. data/samples/cgi/po/de/main.po +3 -3
  161. data/samples/cgi/po/el/helloerb1.po +3 -3
  162. data/samples/cgi/po/el/helloerb2.po +3 -3
  163. data/samples/cgi/po/el/hellolib.po +2 -2
  164. data/samples/cgi/po/el/main.po +3 -3
  165. data/samples/cgi/po/eo/helloerb1.po +3 -3
  166. data/samples/cgi/po/eo/helloerb2.po +3 -3
  167. data/samples/cgi/po/eo/hellolib.po +2 -2
  168. data/samples/cgi/po/eo/main.po +3 -3
  169. data/samples/cgi/po/es/helloerb1.po +4 -4
  170. data/samples/cgi/po/es/helloerb2.po +4 -4
  171. data/samples/cgi/po/es/hellolib.po +2 -2
  172. data/samples/cgi/po/es/main.po +4 -4
  173. data/samples/cgi/po/fr/helloerb1.po +4 -4
  174. data/samples/cgi/po/fr/helloerb2.po +4 -4
  175. data/samples/cgi/po/fr/hellolib.po +2 -2
  176. data/samples/cgi/po/fr/main.po +4 -4
  177. data/samples/cgi/po/hr/helloerb1.po +3 -3
  178. data/samples/cgi/po/hr/helloerb2.po +3 -3
  179. data/samples/cgi/po/hr/hellolib.po +2 -2
  180. data/samples/cgi/po/hr/main.po +3 -3
  181. data/samples/cgi/po/hu/helloerb1.po +4 -4
  182. data/samples/cgi/po/hu/helloerb2.po +4 -4
  183. data/samples/cgi/po/hu/hellolib.po +2 -2
  184. data/samples/cgi/po/hu/main.po +4 -4
  185. data/samples/cgi/po/it/helloerb1.po +3 -3
  186. data/samples/cgi/po/it/helloerb2.po +3 -3
  187. data/samples/cgi/po/it/hellolib.po +2 -2
  188. data/samples/cgi/po/it/main.po +3 -3
  189. data/samples/cgi/po/ja/helloerb1.po +4 -4
  190. data/samples/cgi/po/ja/helloerb2.po +4 -4
  191. data/samples/cgi/po/ja/hellolib.po +2 -2
  192. data/samples/cgi/po/ja/main.po +3 -3
  193. data/samples/cgi/po/ko/helloerb1.po +3 -3
  194. data/samples/cgi/po/ko/helloerb2.po +3 -3
  195. data/samples/cgi/po/ko/hellolib.po +2 -2
  196. data/samples/cgi/po/ko/main.po +3 -3
  197. data/samples/cgi/po/lv/helloerb1.po +4 -4
  198. data/samples/cgi/po/lv/helloerb2.po +4 -4
  199. data/samples/cgi/po/lv/hellolib.po +2 -2
  200. data/samples/cgi/po/lv/main.po +4 -4
  201. data/samples/cgi/po/nb/helloerb1.po +3 -3
  202. data/samples/cgi/po/nb/helloerb2.po +3 -3
  203. data/samples/cgi/po/nb/hellolib.po +2 -2
  204. data/samples/cgi/po/nb/main.po +3 -3
  205. data/samples/cgi/po/nl/helloerb1.po +4 -4
  206. data/samples/cgi/po/nl/helloerb2.po +4 -4
  207. data/samples/cgi/po/nl/hellolib.po +2 -2
  208. data/samples/cgi/po/nl/main.po +4 -4
  209. data/samples/cgi/po/pt_BR/helloerb1.po +4 -4
  210. data/samples/cgi/po/pt_BR/helloerb2.po +4 -4
  211. data/samples/cgi/po/pt_BR/hellolib.po +2 -2
  212. data/samples/cgi/po/pt_BR/main.po +4 -4
  213. data/samples/cgi/po/ru/helloerb1.po +4 -4
  214. data/samples/cgi/po/ru/helloerb2.po +4 -4
  215. data/samples/cgi/po/ru/hellolib.po +2 -2
  216. data/samples/cgi/po/ru/main.po +4 -4
  217. data/samples/cgi/po/sr/helloerb1.po +4 -4
  218. data/samples/cgi/po/sr/helloerb2.po +4 -4
  219. data/samples/cgi/po/sr/hellolib.po +2 -2
  220. data/samples/cgi/po/sr/main.po +4 -4
  221. data/samples/cgi/po/uk/helloerb1.po +4 -4
  222. data/samples/cgi/po/uk/helloerb2.po +4 -4
  223. data/samples/cgi/po/uk/hellolib.po +2 -2
  224. data/samples/cgi/po/uk/main.po +4 -4
  225. data/samples/cgi/po/vi/helloerb1.po +3 -3
  226. data/samples/cgi/po/vi/helloerb2.po +3 -3
  227. data/samples/cgi/po/vi/hellolib.po +2 -2
  228. data/samples/cgi/po/vi/main.po +3 -3
  229. data/samples/cgi/po/zh/helloerb1.po +4 -4
  230. data/samples/cgi/po/zh/helloerb2.po +4 -4
  231. data/samples/cgi/po/zh/hellolib.po +2 -2
  232. data/samples/cgi/po/zh/main.po +4 -4
  233. data/samples/cgi/po/zh_TW/helloerb1.po +4 -4
  234. data/samples/cgi/po/zh_TW/helloerb2.po +4 -4
  235. data/samples/cgi/po/zh_TW/hellolib.po +2 -2
  236. data/samples/cgi/po/zh_TW/main.po +4 -4
  237. data/samples/hello.rb +1 -1
  238. data/samples/hello2.rb +1 -1
  239. data/samples/hello_glade2.rb +1 -1
  240. data/samples/hello_gtk2.rb +2 -2
  241. data/samples/hello_noop.rb +1 -1
  242. data/samples/hello_plural.rb +1 -1
  243. data/samples/hello_tk.rb +1 -1
  244. data/samples/locale/bg/LC_MESSAGES/hello_gtk2.mo +0 -0
  245. data/samples/locale/bs/LC_MESSAGES/hello_gtk2.mo +0 -0
  246. data/samples/locale/ca/LC_MESSAGES/hello_gtk2.mo +0 -0
  247. data/samples/locale/cs/LC_MESSAGES/hello_gtk2.mo +0 -0
  248. data/samples/locale/de/LC_MESSAGES/hello_gtk2.mo +0 -0
  249. data/samples/locale/el/LC_MESSAGES/hello_gtk2.mo +0 -0
  250. data/samples/locale/eo/LC_MESSAGES/hello_gtk2.mo +0 -0
  251. data/samples/locale/es/LC_MESSAGES/hello_gtk2.mo +0 -0
  252. data/samples/locale/fr/LC_MESSAGES/hello_gtk2.mo +0 -0
  253. data/samples/locale/hr/LC_MESSAGES/hello_gtk2.mo +0 -0
  254. data/samples/locale/hu/LC_MESSAGES/hello_gtk2.mo +0 -0
  255. data/samples/locale/it/LC_MESSAGES/hello_gtk2.mo +0 -0
  256. data/samples/locale/ja/LC_MESSAGES/hello_gtk2.mo +0 -0
  257. data/samples/locale/ko/LC_MESSAGES/hello_gtk2.mo +0 -0
  258. data/samples/locale/lv/LC_MESSAGES/hello_gtk2.mo +0 -0
  259. data/samples/locale/nb/LC_MESSAGES/hello_gtk2.mo +0 -0
  260. data/samples/locale/nl/LC_MESSAGES/hello_gtk2.mo +0 -0
  261. data/samples/locale/pt_BR/LC_MESSAGES/hello_gtk2.mo +0 -0
  262. data/samples/locale/ru/LC_MESSAGES/hello_gtk2.mo +0 -0
  263. data/samples/locale/sr/LC_MESSAGES/hello_gtk2.mo +0 -0
  264. data/samples/locale/sv/LC_MESSAGES/hello_gtk2.mo +0 -0
  265. data/samples/locale/uk/LC_MESSAGES/hello_gtk2.mo +0 -0
  266. data/samples/locale/vi/LC_MESSAGES/hello_gtk2.mo +0 -0
  267. data/samples/locale/zh/LC_MESSAGES/hello_gtk2.mo +0 -0
  268. data/samples/locale/zh_TW/LC_MESSAGES/hello_gtk2.mo +0 -0
  269. data/samples/po/bg/hello.po +2 -2
  270. data/samples/po/bg/hello2.po +1 -1
  271. data/samples/po/bg/hello_glade2.po +1 -1
  272. data/samples/po/bg/{hello_gtk.po → hello_gtk2.po} +1 -1
  273. data/samples/po/bg/hello_noop.po +1 -1
  274. data/samples/po/bg/hello_plural.po +1 -1
  275. data/samples/po/bg/hello_tk.po +1 -1
  276. data/samples/po/bs/hello.po +2 -2
  277. data/samples/po/bs/hello2.po +1 -1
  278. data/samples/po/bs/hello_glade2.po +1 -1
  279. data/samples/po/bs/{hello_gtk.po → hello_gtk2.po} +1 -1
  280. data/samples/po/bs/hello_noop.po +1 -1
  281. data/samples/po/bs/hello_plural.po +1 -1
  282. data/samples/po/bs/hello_tk.po +1 -1
  283. data/samples/po/ca/hello.po +2 -2
  284. data/samples/po/ca/hello2.po +1 -1
  285. data/samples/po/ca/hello_glade2.po +1 -1
  286. data/samples/po/ca/{hello_gtk.po → hello_gtk2.po} +1 -1
  287. data/samples/po/ca/hello_noop.po +1 -1
  288. data/samples/po/ca/hello_plural.po +1 -1
  289. data/samples/po/ca/hello_tk.po +1 -1
  290. data/samples/po/cs/hello.po +1 -1
  291. data/samples/po/cs/hello_glade2.po +1 -1
  292. data/samples/po/cs/{hello_gtk.po → hello_gtk2.po} +0 -0
  293. data/samples/po/cs/hello_plural.po +1 -1
  294. data/samples/po/de/hello.po +1 -1
  295. data/samples/po/de/{hello_gtk.po → hello_gtk2.po} +0 -0
  296. data/samples/po/de/hello_plural.po +1 -1
  297. data/samples/po/el/hello.po +2 -2
  298. data/samples/po/el/hello2.po +1 -1
  299. data/samples/po/el/hello_glade2.po +1 -1
  300. data/samples/po/el/{hello_gtk.po → hello_gtk2.po} +1 -1
  301. data/samples/po/el/hello_noop.po +1 -1
  302. data/samples/po/el/hello_plural.po +1 -1
  303. data/samples/po/el/hello_tk.po +1 -1
  304. data/samples/po/eo/hello.po +2 -2
  305. data/samples/po/eo/hello2.po +1 -1
  306. data/samples/po/eo/hello_glade2.po +1 -1
  307. data/samples/po/eo/{hello_gtk.po → hello_gtk2.po} +1 -1
  308. data/samples/po/eo/hello_noop.po +1 -1
  309. data/samples/po/eo/hello_plural.po +1 -1
  310. data/samples/po/eo/hello_tk.po +1 -1
  311. data/samples/po/es/{hello_gtk.po → hello_gtk2.po} +0 -0
  312. data/samples/po/fr/{hello_gtk.po → hello_gtk2.po} +0 -0
  313. data/samples/po/hello.pot +13 -13
  314. data/samples/po/hello2.pot +17 -17
  315. data/samples/po/hello_glade2.pot +12 -13
  316. data/{test/pot/backslash.pot → samples/po/hello_gtk2.pot} +8 -6
  317. data/samples/po/hello_noop.pot +13 -13
  318. data/samples/po/hello_plural.pot +14 -15
  319. data/samples/po/hello_tk.pot +9 -10
  320. data/samples/po/hr/hello.po +2 -2
  321. data/samples/po/hr/hello2.po +1 -1
  322. data/samples/po/hr/hello_glade2.po +1 -1
  323. data/samples/po/hr/{hello_gtk.po → hello_gtk2.po} +1 -1
  324. data/samples/po/hr/hello_noop.po +1 -1
  325. data/samples/po/hr/hello_plural.po +1 -1
  326. data/samples/po/hr/hello_tk.po +1 -1
  327. data/samples/po/hu/hello.po +2 -2
  328. data/samples/po/hu/hello2.po +1 -1
  329. data/samples/po/hu/hello_glade2.po +1 -1
  330. data/samples/po/hu/{hello_gtk.po → hello_gtk2.po} +1 -1
  331. data/samples/po/hu/hello_noop.po +1 -1
  332. data/samples/po/hu/hello_plural.po +1 -1
  333. data/samples/po/hu/hello_tk.po +1 -1
  334. data/samples/po/it/hello.po +1 -1
  335. data/samples/po/it/{hello_gtk.po → hello_gtk2.po} +0 -0
  336. data/samples/po/ja/{hello_gtk.po → hello_gtk2.po} +0 -0
  337. data/samples/po/ko/{hello_gtk.po → hello_gtk2.po} +0 -0
  338. data/samples/po/ko/hello_plural.po +1 -1
  339. data/samples/po/lv/hello.po +2 -2
  340. data/samples/po/lv/hello2.po +1 -1
  341. data/samples/po/lv/hello_glade2.po +1 -1
  342. data/samples/po/lv/{hello_gtk.po → hello_gtk2.po} +1 -1
  343. data/samples/po/lv/hello_noop.po +1 -1
  344. data/samples/po/lv/hello_plural.po +1 -1
  345. data/samples/po/lv/hello_tk.po +1 -1
  346. data/samples/po/nb/hello.po +2 -2
  347. data/samples/po/nb/hello2.po +1 -1
  348. data/samples/po/nb/hello_glade2.po +1 -1
  349. data/samples/po/nb/{hello_gtk.po → hello_gtk2.po} +1 -1
  350. data/samples/po/nb/hello_noop.po +1 -1
  351. data/samples/po/nb/hello_plural.po +1 -1
  352. data/samples/po/nb/hello_tk.po +1 -1
  353. data/samples/po/nl/hello.po +2 -2
  354. data/samples/po/nl/hello2.po +1 -1
  355. data/samples/po/nl/hello_glade2.po +1 -1
  356. data/samples/po/nl/{hello_gtk.po → hello_gtk2.po} +1 -1
  357. data/samples/po/nl/hello_noop.po +1 -1
  358. data/samples/po/nl/hello_plural.po +1 -1
  359. data/samples/po/nl/hello_tk.po +1 -1
  360. data/samples/po/pt_BR/{hello_gtk.po → hello_gtk2.po} +0 -0
  361. data/samples/po/ru/hello.po +2 -2
  362. data/samples/po/ru/hello2.po +1 -1
  363. data/samples/po/ru/hello_glade2.po +1 -1
  364. data/samples/po/ru/{hello_gtk.po → hello_gtk2.po} +1 -1
  365. data/samples/po/ru/hello_noop.po +1 -1
  366. data/samples/po/ru/hello_plural.po +1 -1
  367. data/samples/po/ru/hello_tk.po +1 -1
  368. data/samples/po/sr/hello.po +2 -2
  369. data/samples/po/sr/hello2.po +1 -1
  370. data/samples/po/sr/hello_glade2.po +1 -1
  371. data/samples/po/sr/{hello_gtk.po → hello_gtk2.po} +1 -1
  372. data/samples/po/sr/hello_noop.po +1 -1
  373. data/samples/po/sr/hello_plural.po +1 -1
  374. data/samples/po/sr/hello_tk.po +1 -1
  375. data/samples/po/sv/{hello_gtk.po → hello_gtk2.po} +0 -0
  376. data/samples/po/uk/hello.po +2 -2
  377. data/samples/po/uk/hello2.po +1 -1
  378. data/samples/po/uk/hello_glade2.po +1 -1
  379. data/samples/po/uk/{hello_gtk.po → hello_gtk2.po} +1 -1
  380. data/samples/po/uk/hello_noop.po +1 -1
  381. data/samples/po/uk/hello_plural.po +1 -1
  382. data/samples/po/uk/hello_tk.po +1 -1
  383. data/samples/po/vi/hello.po +2 -2
  384. data/samples/po/vi/hello2.po +1 -1
  385. data/samples/po/vi/hello_glade2.po +1 -1
  386. data/samples/po/vi/{hello_gtk.po → hello_gtk2.po} +1 -1
  387. data/samples/po/vi/hello_noop.po +1 -1
  388. data/samples/po/vi/hello_plural.po +1 -1
  389. data/samples/po/vi/hello_tk.po +1 -1
  390. data/samples/po/zh/hello.po +2 -2
  391. data/samples/po/zh/hello2.po +1 -1
  392. data/samples/po/zh/hello_glade2.po +1 -1
  393. data/samples/po/zh/{hello_gtk.po → hello_gtk2.po} +1 -1
  394. data/samples/po/zh/hello_noop.po +1 -1
  395. data/samples/po/zh/hello_plural.po +1 -1
  396. data/samples/po/zh/hello_tk.po +1 -1
  397. data/samples/po/zh_TW/hello.po +2 -2
  398. data/samples/po/zh_TW/hello2.po +1 -1
  399. data/samples/po/zh_TW/hello_glade2.po +1 -1
  400. data/samples/po/zh_TW/{hello_gtk.po → hello_gtk2.po} +1 -1
  401. data/samples/po/zh_TW/hello_noop.po +1 -1
  402. data/samples/po/zh_TW/hello_plural.po +1 -1
  403. data/samples/po/zh_TW/hello_tk.po +1 -1
  404. data/src/poparser.ry +18 -14
  405. data/test/{testlib → fixtures}/N_.rb +0 -0
  406. data/test/{testlib/gettext.rb → fixtures/_.rb} +27 -1
  407. data/test/fixtures/_/one_line.rb +32 -0
  408. data/test/fixtures/backslash.rb +29 -0
  409. data/test/{testlib → fixtures}/erb.rhtml +0 -0
  410. data/test/{testlib → fixtures}/erb.rxml +0 -0
  411. data/test/{testlib → fixtures}/gladeparser.glade +0 -0
  412. data/test/{testlib → fixtures}/multi_textdomain.rb +0 -0
  413. data/test/{testlib/ngettext.rb → fixtures/n_.rb} +20 -1
  414. data/test/{testlib → fixtures}/non_ascii.rb +0 -0
  415. data/test/fixtures/np_.rb +51 -0
  416. data/test/{testlib/nsgettext.rb → fixtures/ns_.rb} +20 -2
  417. data/test/fixtures/ns_/custom.rb +32 -0
  418. data/test/fixtures/p_.rb +57 -0
  419. data/test/fixtures/s_.rb +66 -0
  420. data/test/fixtures/s_/custom.rb +32 -0
  421. data/test/{testlib → fixtures}/simple.rb +0 -0
  422. data/test/gettext-test-utils.rb +44 -0
  423. data/test/locale/ja/LC_MESSAGES/_.mo +0 -0
  424. data/test/locale/ja/LC_MESSAGES/backslash.mo +0 -0
  425. data/test/locale/ja/LC_MESSAGES/np_.mo +0 -0
  426. data/test/locale/ja/LC_MESSAGES/ns_.mo +0 -0
  427. data/test/locale/ja/LC_MESSAGES/p_.mo +0 -0
  428. data/test/locale/ja/LC_MESSAGES/s_.mo +0 -0
  429. data/test/parser/test_ruby.rb +121 -0
  430. data/test/po/_.pot +109 -0
  431. data/test/{pot/sgettext.pot → po/backslash.pot} +10 -4
  432. data/test/po/ja/_.po +114 -0
  433. data/test/po/ja/backslash.po +3 -3
  434. data/test/po/ja/non_ascii.po +1 -1
  435. data/test/po/ja/{npgettext.po → np_.po} +6 -6
  436. data/test/po/ja/{nsgettext.po → ns_.po} +16 -10
  437. data/test/po/ja/{pgettext.po → p_.po} +5 -5
  438. data/test/po/ja/{sgettext.po → s_.po} +0 -0
  439. data/test/{pot → po}/non_ascii.pot +7 -5
  440. data/test/{pot/npgettext.pot → po/np_.pot} +10 -9
  441. data/test/{pot/nsgettext.pot → po/ns_.pot} +20 -12
  442. data/test/{pot/pgettext.pot → po/p_.pot} +12 -10
  443. data/test/po/s_.pot +55 -0
  444. data/test/run-test.rb +5 -0
  445. data/test/test_class_info.rb +0 -1
  446. data/test/test_gettext.rb +49 -12
  447. data/test/test_locale_path.rb +1 -4
  448. data/test/test_mofile.rb +0 -1
  449. data/test/test_parser.rb +119 -88
  450. data/test/test_po_generation.rb +32 -9
  451. data/test/{test_pomessage.rb → test_po_message.rb} +18 -1
  452. data/test/test_po_parser.rb +117 -0
  453. data/test/test_string.rb +0 -2
  454. data/test/test_textdomain_bind.rb +0 -2
  455. data/test/test_textdomain_multi.rb +1 -2
  456. data/test/test_textdomain_toplevel.rb +0 -1
  457. data/test/test_thread.rb +0 -1
  458. data/test/tools/test_msginit.rb +351 -0
  459. data/test/tools/test_msgmerge.rb +202 -0
  460. data/test/tools/test_tools.rb +0 -2
  461. data/test/tools/test_xgettext.rb +154 -0
  462. metadata +822 -753
  463. data/bin/rgettext +0 -23
  464. data/data/locale/bg/LC_MESSAGES/rgettext.mo +0 -0
  465. data/data/locale/bs/LC_MESSAGES/rgettext.mo +0 -0
  466. data/data/locale/ca/LC_MESSAGES/rgettext.mo +0 -0
  467. data/data/locale/cs/LC_MESSAGES/rgettext.mo +0 -0
  468. data/data/locale/de/LC_MESSAGES/rgettext.mo +0 -0
  469. data/data/locale/el/LC_MESSAGES/rgettext.mo +0 -0
  470. data/data/locale/eo/LC_MESSAGES/rgettext.mo +0 -0
  471. data/data/locale/es/LC_MESSAGES/rgettext.mo +0 -0
  472. data/data/locale/et/LC_MESSAGES/rgettext.mo +0 -0
  473. data/data/locale/fr/LC_MESSAGES/rgettext.mo +0 -0
  474. data/data/locale/hr/LC_MESSAGES/rgettext.mo +0 -0
  475. data/data/locale/hu/LC_MESSAGES/rgettext.mo +0 -0
  476. data/data/locale/it/LC_MESSAGES/rgettext.mo +0 -0
  477. data/data/locale/ja/LC_MESSAGES/rgettext.mo +0 -0
  478. data/data/locale/ko/LC_MESSAGES/rgettext.mo +0 -0
  479. data/data/locale/lv/LC_MESSAGES/rgettext.mo +0 -0
  480. data/data/locale/nb/LC_MESSAGES/rgettext.mo +0 -0
  481. data/data/locale/nl/LC_MESSAGES/rgettext.mo +0 -0
  482. data/data/locale/pt_BR/LC_MESSAGES/rgettext.mo +0 -0
  483. data/data/locale/ru/LC_MESSAGES/rgettext.mo +0 -0
  484. data/data/locale/sr/LC_MESSAGES/rgettext.mo +0 -0
  485. data/data/locale/sv/LC_MESSAGES/rgettext.mo +0 -0
  486. data/data/locale/uk/LC_MESSAGES/rgettext.mo +0 -0
  487. data/data/locale/vi/LC_MESSAGES/rgettext.mo +0 -0
  488. data/data/locale/zh/LC_MESSAGES/rgettext.mo +0 -0
  489. data/data/locale/zh_TW/LC_MESSAGES/rgettext.mo +0 -0
  490. data/lib/gettext/tools/rgettext.rb +0 -251
  491. data/lib/gettext/tools/rmsgfmt.rb +0 -86
  492. data/lib/gettext/tools/rmsgmerge.rb +0 -500
  493. data/samples/makemo.rb +0 -6
  494. data/samples/po/hello_gtk.pot +0 -23
  495. data/samples/po/test.rb +0 -13
  496. data/test/testlib/backslash.rb +0 -12
  497. data/test/testlib/helper.rb +0 -13
  498. data/test/testlib/npgettext.rb +0 -33
  499. data/test/testlib/pgettext.rb +0 -38
  500. data/test/testlib/sgettext.rb +0 -48
data/bin/rgettext DELETED
@@ -1,23 +0,0 @@
1
- #! /usr/bin/ruby
2
- =begin
3
- rgettext - ruby version of xgettext
4
-
5
- Copyright (C) 2005-2009 Masao Mutoh
6
-
7
- You may redistribute it and/or modify it under the same
8
- license terms as Ruby.
9
-
10
- =end
11
-
12
- begin
13
- require 'gettext/rgettext'
14
- rescue LoadError
15
- begin
16
- require 'rubygems'
17
- require 'gettext/tools/rgettext'
18
- rescue LoadError
19
- raise 'Ruby-GetText-Package are not installed.'
20
- end
21
- end
22
-
23
- GetText.rgettext
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,251 +0,0 @@
1
- #! /usr/bin/env ruby
2
- =begin
3
- rgettext.rb - Generate a .pot file.
4
-
5
- Copyright (C) 2003-2010 Masao Mutoh
6
- Copyright (C) 2001,2002 Yasushi Shoji, Masao Mutoh
7
-
8
- Yasushi Shoji <yashi at atmark-techno.com>
9
- Masao Mutoh <mutomasa at gmail.com>
10
-
11
- You may redistribute it and/or modify it under the same
12
- license terms as Ruby or LGPL.
13
- =end
14
-
15
- require 'optparse'
16
- require 'gettext'
17
- require 'rbconfig'
18
-
19
- module GetText
20
-
21
- module RGetText #:nodoc:
22
- extend GetText
23
-
24
- bindtextdomain("rgettext")
25
-
26
- # constant values
27
- VERSION = GetText::VERSION
28
-
29
- @ex_parsers = []
30
- [
31
- ["glade.rb", "GladeParser"],
32
- ["erb.rb", "ErbParser"],
33
- # ["ripper.rb", "RipperParser"],
34
- ["ruby.rb", "RubyParser"] # Default parser.
35
- ].each do |f, klass|
36
- begin
37
- require "gettext/tools/parser/#{f}"
38
- @ex_parsers << GetText.const_get(klass)
39
- rescue
40
- $stderr.puts _("'%{klass}' is ignored.") % {:klass => klass}
41
- $stderr.puts $! if $DEBUG
42
- end
43
- end
44
-
45
- module_function
46
-
47
- # Add an option parser
48
- # the option parser module requires to have target?(file) and parser(file, ary) method.
49
- #
50
- # require 'gettext/tools/rgettext'
51
- # module FooParser
52
- # module_function
53
- # def target?(file)
54
- # File.extname(file) == '.foo' # *.foo file only.
55
- # end
56
- # def parse(file)
57
- # :
58
- # ary = []
59
- # # Simple message
60
- # po = PoMessage.new(:normal)
61
- # po.msgid = "hello"
62
- # po.sources = ["foo.rb:200", "bar.rb:300"]
63
- # po.add_comment("Comment for the message")
64
- # ary << po
65
- # # Plural message
66
- # po = PoMessage.new(:plural)
67
- # po.msgid = "An apple"
68
- # po.msgid_plural = "Apples"
69
- # po.sources = ["foo.rb:200", "bar.rb:300"]
70
- # ary << po
71
- # # Simple message with the message context
72
- # po = PoMessage.new(:msgctxt)
73
- # po.msgctxt = "context"
74
- # po.msgid = "hello"
75
- # po.sources = ["foo.rb:200", "bar.rb:300"]
76
- # ary << po
77
- # # Plural message with the message context.
78
- # po = PoMessage.new(:msgctxt_plural)
79
- # po.msgctxt = "context"
80
- # po.msgid = "An apple"
81
- # po.msgid_plural = "Apples"
82
- # po.sources = ["foo.rb:200", "bar.rb:300"]
83
- # ary << po
84
- # return ary
85
- # end
86
- # end
87
- #
88
- # GetText::RGetText.add_parser(FooParser)
89
- def add_parser(klass)
90
- @ex_parsers.insert(0, klass)
91
- end
92
-
93
- def generate_pot_header # :nodoc:
94
- time = Time.now.strftime("%Y-%m-%d %H:%M")
95
- off = Time.now.utc_offset
96
- sign = off <= 0 ? '-' : '+'
97
- time += sprintf('%s%02d%02d', sign, *(off.abs / 60).divmod(60))
98
-
99
- <<TITLE
100
- # SOME DESCRIPTIVE TITLE.
101
- # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
102
- # This file is distributed under the same license as the PACKAGE package.
103
- # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
104
- #
105
- #, fuzzy
106
- msgid ""
107
- msgstr ""
108
- "Project-Id-Version: PACKAGE VERSION\\n"
109
- "POT-Creation-Date: #{time}\\n"
110
- "PO-Revision-Date: #{time}\\n"
111
- "Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"
112
- "Language-Team: LANGUAGE <LL@li.org>\\n"
113
- "MIME-Version: 1.0\\n"
114
- "Content-Type: text/plain; charset=UTF-8\\n"
115
- "Content-Transfer-Encoding: 8bit\\n"
116
- "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n"
117
- TITLE
118
- end
119
-
120
- def generate_pot(paths) # :nodoc:
121
- pomessages = parse(paths)
122
- str = ""
123
- pomessages.each do |target|
124
- str << target.to_po_str
125
- end
126
- str
127
- end
128
-
129
- def parse(paths) # :nodoc:
130
- pomessages = []
131
- paths = [paths] if paths.kind_of? String
132
- paths.each do |path|
133
- begin
134
- @ex_parsers.each do |klass|
135
- if klass.target?(path)
136
- if klass.method(:parse).arity == 1
137
- targets = klass.parse(path)
138
- else
139
- # For backward compatibility.
140
- targets = klass.parse(path, [])
141
- end
142
-
143
- targets.each{|pomessage|
144
- if pomessage.kind_of? Array
145
- pomessage = PoMessage.new_from_ary(pomessage)
146
- end
147
-
148
- # Save the previous target.
149
- existing = pomessages.empty? ? nil : pomessages.index(pomessages.find {|t| t == pomessage})
150
- if existing
151
- pomessage = pomessages[existing].merge(pomessage)
152
- pomessages[existing] = pomessage
153
- else
154
- pomessages << pomessage
155
- end
156
- }
157
- break
158
- end
159
- end
160
- rescue
161
- puts _("Error parsing %{path}") % {:path => path}
162
- raise
163
- end
164
- end
165
- pomessages
166
- end
167
-
168
- def check_options # :nodoc:
169
- output = STDOUT
170
-
171
- opts = OptionParser.new
172
- opts.banner = _("Usage: %s input.rb [-r parser.rb] [-o output.pot]") % $0
173
- opts.separator("")
174
- opts.separator(_("Extract translatable strings from given input files."))
175
- opts.separator("")
176
- opts.separator(_("Specific options:"))
177
-
178
- opts.on("-o", "--output=FILE", _("write output to specified file")) do |out|
179
- unless FileTest.exist? out
180
- output = File.new(File.expand_path(out), "w+")
181
- else
182
- $stderr.puts(_("File '%s' already exists.") % out)
183
- exit 1
184
- end
185
- end
186
-
187
- opts.on("-r", "--require=library", _("require the library before executing rgettext")) do |out|
188
- require out
189
- end
190
-
191
- opts.on("-d", "--debug", _("run in debugging mode")) do
192
- $DEBUG = true
193
- end
194
-
195
- opts.on_tail("--version", _("display version information and exit")) do
196
- puts "#{$0} #{VERSION}"
197
- puts "#{File.join(Config::CONFIG["bindir"], Config::CONFIG["RUBY_INSTALL_NAME"])} #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
198
- exit
199
- end
200
-
201
- opts.parse!(ARGV)
202
-
203
- if ARGV.size == 0
204
- puts opts.help
205
- exit 1
206
- end
207
-
208
- [ARGV, output]
209
- end
210
-
211
- def run(paths = nil, out = STDOUT) # :nodoc:
212
- if paths.is_a? String
213
- paths = [paths]
214
- elsif ! paths
215
- paths, out = check_options
216
- end
217
- if paths.size == 0
218
- raise ArgumentError, _("no input files")
219
- end
220
- if out.is_a? String
221
- File.open(File.expand_path(out), "w+") do |file|
222
- file.puts generate_pot_header
223
- file.puts generate_pot(paths)
224
- end
225
- else
226
- out.puts generate_pot_header
227
- out.puts generate_pot(paths)
228
- end
229
- self
230
- end
231
- end
232
- extend self
233
- # Creates a po-file from targetfiles(ruby-script-files, .rhtml files, glade-2 XML files),
234
- # then output the result to out. If no parameter is set, it behaves same as command line tools(rgettet).
235
- #
236
- # This function is a part of GetText.create_pofiles.
237
- # Usually you don't need to call this function directly.
238
- #
239
- # * paths: An Array of po-file paths or nil.
240
- # * out: output IO or output path.
241
- # * Returns: self
242
- def rgettext(paths = nil, out = STDOUT)
243
- RGetText.run(paths, out)
244
- self
245
- end
246
- end
247
-
248
- if $0 == __FILE__
249
- GetText.rgettext
250
- # GetText.rgettext($0, "tmp.txt")
251
- end
@@ -1,86 +0,0 @@
1
- # encoding: utf-8
2
-
3
- =begin
4
- rmsgfmt.rb - Generate a .mo
5
-
6
- Copyright (C) 2003-2009 Masao Mutoh
7
-
8
- You may redistribute it and/or modify it under the same
9
- license terms as Ruby or LGPL.
10
- =end
11
-
12
- require 'optparse'
13
- require 'fileutils'
14
- require 'gettext'
15
- require 'gettext/tools/poparser'
16
- require 'rbconfig'
17
-
18
- module GetText
19
-
20
- module RMsgfmt #:nodoc:
21
- extend GetText
22
- extend self
23
-
24
- bindtextdomain "rgettext"
25
-
26
- def run(targetfile = nil, output_path = nil) # :nodoc:
27
- unless targetfile
28
- targetfile, output_path = check_options
29
- end
30
- unless targetfile
31
- raise ArgumentError, _("no input files")
32
- end
33
- unless output_path
34
- output_path = "messages.mo"
35
- end
36
-
37
- parser = PoParser.new
38
- data = MoFile.new
39
-
40
- parser.parse_file(targetfile, data)
41
- data.save_to_file(output_path)
42
- end
43
-
44
- def check_options # :nodoc:
45
- output = nil
46
-
47
- opts = OptionParser.new
48
- opts.banner = _("Usage: %s input.po [-o output.mo]" % $0)
49
- opts.separator("")
50
- opts.separator(_("Generate binary message catalog from textual translation description."))
51
- opts.separator("")
52
- opts.separator(_("Specific options:"))
53
-
54
- opts.on("-o", "--output=FILE", _("write output to specified file")) do |out|
55
- output = out
56
- end
57
-
58
- opts.on_tail("--version", _("display version information and exit")) do
59
- puts "#{$0} #{GetText::VERSION}"
60
- puts "#{File.join(Config::CONFIG["bindir"], Config::CONFIG["RUBY_INSTALL_NAME"])} #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
61
- exit
62
- end
63
- opts.parse!(ARGV)
64
-
65
- if ARGV.size == 0
66
- puts opts.help
67
- exit 1
68
- end
69
-
70
- [ARGV[0], output]
71
- end
72
- end
73
-
74
- # Creates a mo-file from a targetfile(po-file), then output the result to out.
75
- # If no parameter is set, it behaves same as command line tools(rmsgfmt).
76
- # * targetfile: An Array of po-files or nil.
77
- # * output_path: output path.
78
- # * Returns: the MoFile object.
79
- def rmsgfmt(targetfile = nil, output_path = nil)
80
- RMsgfmt.run(targetfile, output_path)
81
- end
82
- end
83
-
84
- if $0 == __FILE__ then
85
- GetText.rmsgfmt
86
- end
@@ -1,500 +0,0 @@
1
- # encoding: utf-8
2
-
3
- =begin
4
- rmsgmerge.rb - Merge old .po to new .po
5
-
6
- Copyright (C) 2005-2009 Masao Mutoh
7
- Copyright (C) 2005,2006 speakillof
8
-
9
- You may redistribute it and/or modify it under the same
10
- license terms as Ruby or LGPL.
11
- =end
12
-
13
- require 'optparse'
14
- require 'gettext'
15
- require 'gettext/tools/poparser'
16
- require 'rbconfig'
17
-
18
- module GetText
19
-
20
- module RMsgMerge
21
-
22
- class PoData #:nodoc:
23
-
24
- attr_reader :msgids
25
-
26
- def initialize
27
- @msgid2msgstr = {}
28
- @msgid2comment = {}
29
- @msgids = []
30
- end
31
-
32
- def set_comment(msgid_or_sym, comment)
33
- @msgid2comment[msgid_or_sym] = comment
34
- end
35
-
36
- def msgstr(msgid)
37
- @msgid2msgstr[msgid]
38
- end
39
-
40
- def comment(msgid)
41
- @msgid2comment[msgid]
42
- end
43
-
44
- def [](msgid)
45
- @msgid2msgstr[msgid]
46
- end
47
-
48
- def []=(msgid, msgstr)
49
- # Retain the order
50
- unless @msgid2msgstr[msgid]
51
- @msgids << msgid
52
- end
53
-
54
- @msgid2msgstr[msgid] = msgstr
55
- end
56
-
57
- def each_msgid
58
- arr = @msgids.delete_if{|i| Symbol === i or i == ''}
59
- arr.each do |i|
60
- yield i
61
- end
62
- end
63
-
64
- def msgid?(msgid)
65
- !(Symbol === msgid) and @msgid2msgstr[msgid] and (msgid != '')
66
- end
67
-
68
- # Is it necessary to implement this method?
69
- def search_msgid_fuzzy(msgid, used_msgids)
70
- nil
71
- end
72
-
73
- def nplural
74
- unless @msgid2msgstr['']
75
- return 0
76
- else
77
- if /\s*nplural\s*=\s*(\d+)/ =~ @msgid2msgstr['']
78
- return $1.to_i
79
- else
80
- return 0
81
- end
82
-
83
- end
84
- end
85
-
86
- def generate_po
87
- str = ''
88
- str << generate_po_header
89
-
90
- self.each_msgid do |id|
91
- str << self.generate_po_entry(id)
92
- end
93
-
94
- str << @msgid2comment[:last]
95
- str
96
- end
97
-
98
- def generate_po_header
99
- str = ""
100
-
101
- str << @msgid2comment[''].strip << "\n"
102
- str << 'msgid ""' << "\n"
103
- str << 'msgstr ""' << "\n"
104
- msgstr = @msgid2msgstr[''].gsub(/"/, '\"').gsub(/\r/, '')
105
- msgstr = msgstr.gsub(/^(.*)$/, '"\1\n"')
106
- str << msgstr
107
- str << "\n"
108
-
109
- str
110
- end
111
-
112
- def generate_po_entry(msgid)
113
- str = ""
114
- str << @msgid2comment[msgid]
115
- if str[-1] != "\n"[0]
116
- str << "\n"
117
- end
118
-
119
- id = msgid.gsub(/"/, '\"').gsub(/\r/, '')
120
- msgstr = @msgid2msgstr[msgid].gsub(/"/, '\"').gsub(/\r/, '')
121
-
122
- if id.include?("\000")
123
- ids = id.split(/\000/)
124
- str << "msgid " << __conv(ids[0]) << "\n"
125
- ids[1..-1].each do |single_id|
126
- str << "msgid_plural " << __conv(single_id) << "\n"
127
- end
128
-
129
- msgstr.split("\000").each_with_index do |m, n|
130
- str << "msgstr[#{n}] " << __conv(m) << "\n"
131
- end
132
- else
133
- str << "msgid " << __conv(id) << "\n"
134
- str << "msgstr " << __conv(msgstr) << "\n"
135
- end
136
-
137
- str << "\n"
138
- str
139
- end
140
-
141
- def __conv(str)
142
- s = ''
143
-
144
- if str.count("\n") > 1
145
- s << '""' << "\n"
146
- s << str.gsub(/^(.*)$/, '"\1\n"')
147
- else
148
- s << '"' << str.sub("\n", "\\n") << '"'
149
- end
150
-
151
- s.rstrip
152
- end
153
-
154
- end
155
-
156
- class Merger #:nodoc:
157
-
158
- # From GNU gettext source.
159
- #
160
- # Merge the reference with the definition: take the #. and
161
- # #: comments from the reference, take the # comments from
162
- # the definition, take the msgstr from the definition. Add
163
- # this merged entry to the output message list.
164
- DOT_COMMENT_RE = /\A#\./
165
- SEMICOLON_COMMENT_RE = /\A#\:/
166
- FUZZY_RE = /\A#\,/
167
- NOT_SPECIAL_COMMENT_RE = /\A#([^:.,]|\z)/
168
-
169
- CRLF_RE = /\r?\n/
170
- POT_DATE_EXTRACT_RE = /POT-Creation-Date:\s*(.*)?\s*$/
171
- POT_DATE_RE = /POT-Creation-Date:.*?$/
172
-
173
- def merge(definition, reference)
174
- # deep copy
175
- result = Marshal.load( Marshal.dump(reference) )
176
-
177
- used = []
178
- merge_header(result, definition)
179
-
180
- result.each_msgid do |msgid|
181
- if definition.msgid?(msgid)
182
- used << msgid
183
- merge_message(msgid, result, msgid, definition)
184
- elsif other_msgid = definition.search_msgid_fuzzy(msgid, used)
185
- used << other_msgid
186
- merge_fuzzy_message(msgid, result, other_msgid, definition)
187
- elsif msgid.index("\000") and ( reference.msgstr(msgid).gsub("\000", '') == '' )
188
- # plural
189
- result[msgid] = "\000" * definition.nplural
190
- else
191
- change_reference_comment(msgid, result)
192
- end
193
- end
194
-
195
- ###################################################################
196
- # msgids which are not used in reference are handled as obsolete. #
197
- ###################################################################
198
- last_comment = result.comment(:last) || ''
199
- definition.each_msgid do |msgid|
200
- unless used.include?(msgid)
201
- last_comment << "\n"
202
- last_comment << definition.generate_po_entry(msgid).strip.gsub(/^/, '#. ')
203
- last_comment << "\n"
204
- end
205
- end
206
- result.set_comment(:last, last_comment)
207
-
208
- result
209
- end
210
-
211
- def merge_message(msgid, target, def_msgid, definition)
212
- merge_comment(msgid, target, def_msgid, definition)
213
-
214
- ############################################
215
- # check mismatch of msgid and msgid_plural #
216
- ############################################
217
- def_msgstr = definition[def_msgid]
218
- if msgid.index("\000")
219
- if def_msgstr.index("\000")
220
- # OK
221
- target[msgid] = def_msgstr
222
- else
223
- # NG
224
- s = ''
225
- definition.nplural.times {
226
- s << def_msgstr
227
- s << "\000"
228
- }
229
- target[msgid] = s
230
- end
231
- else
232
- if def_msgstr.index("\000")
233
- # NG
234
- target[msgid] = def_msgstr.split("\000")[0]
235
- else
236
- # OK
237
- target[msgid] = def_msgstr
238
- end
239
- end
240
- end
241
-
242
- # for the future
243
- def merge_fuzzy_message(msgid, target, def_msgid, definition)
244
- merge_message(msgid, target, def_msgid, definition)
245
- end
246
-
247
- def merge_comment(msgid, target, def_msgid, definition)
248
- ref_comment = target.comment(msgid)
249
- def_comment = definition.comment(def_msgid)
250
-
251
- normal_comment = []
252
- dot_comment = []
253
- semi_comment = []
254
- is_fuzzy = false
255
-
256
- def_comment.split(CRLF_RE).each do |l|
257
- if NOT_SPECIAL_COMMENT_RE =~ l
258
- normal_comment << l
259
- end
260
- end
261
-
262
- ref_comment.split(CRLF_RE).each do |l|
263
- if DOT_COMMENT_RE =~ l
264
- dot_comment << l
265
- elsif SEMICOLON_COMMENT_RE =~ l
266
- semi_comment << l
267
- elsif FUZZY_RE =~ l
268
- is_fuzzy = true
269
- end
270
- end
271
-
272
- str = format_comment(normal_comment, dot_comment, semi_comment, is_fuzzy)
273
- target.set_comment(msgid, str)
274
- end
275
-
276
- def change_reference_comment(msgid, podata)
277
- normal_comment = []
278
- dot_comment = []
279
- semi_comment = []
280
- is_fuzzy = false
281
-
282
- podata.comment(msgid).split(CRLF_RE).each do |l|
283
- if DOT_COMMENT_RE =~ l
284
- dot_comment << l
285
- elsif SEMICOLON_COMMENT_RE =~ l
286
- semi_comment << l
287
- elsif FUZZY_RE =~ l
288
- is_fuzzy = true
289
- else
290
- normal_comment << l
291
- end
292
- end
293
-
294
- str = format_comment(normal_comment, dot_comment, semi_comment, is_fuzzy)
295
- podata.set_comment(msgid, str)
296
- end
297
-
298
- def format_comment(normal_comment, dot_comment, semi_comment, is_fuzzy)
299
- str = ''
300
-
301
- str << normal_comment.join("\n").gsub(/^#(\s*)/){|sss|
302
- if $1 == ""
303
- "# "
304
- else
305
- sss
306
- end
307
- }
308
- if normal_comment.size > 0
309
- str << "\n"
310
- end
311
-
312
- str << dot_comment.join("\n").gsub(/^#.(\s*)/){|sss|
313
- if $1 == ""
314
- "#. "
315
- else
316
- sss
317
- end
318
- }
319
- if dot_comment.size > 0
320
- str << "\n"
321
- end
322
-
323
- str << semi_comment.join("\n").gsub(/^#:\s*/, "#: ")
324
- if semi_comment.size > 0
325
- str << "\n"
326
- end
327
-
328
- if is_fuzzy
329
- str << "#, fuzzy\n"
330
- end
331
-
332
- str
333
- end
334
-
335
- def merge_header(target, definition)
336
- merge_comment('', target, '', definition)
337
-
338
- msg = target.msgstr('')
339
- def_msg = definition.msgstr('')
340
- if POT_DATE_EXTRACT_RE =~ msg
341
- time = $1
342
- def_msg = def_msg.sub(POT_DATE_RE, "POT-Creation-Date: #{time}")
343
- end
344
-
345
- target[''] = def_msg
346
- end
347
-
348
- end
349
-
350
- end
351
-
352
- end
353
-
354
- module GetText::RMsgMerge #:nodoc:
355
-
356
- class Config #:nodoc:
357
-
358
- attr_accessor :defpo, :refpot, :output, :fuzzy, :update
359
-
360
- # update mode options
361
- attr_accessor :backup, :suffix
362
-
363
- =begin
364
- The result is written back to def.po.
365
- --backup=CONTROL make a backup of def.po
366
- --suffix=SUFFIX override the usual backup suffix
367
- The version control method may be selected via the --backup option or through
368
- the VERSION_CONTROL environment variable. Here are the values:
369
- none, off never make backups (even if --backup is given)
370
- numbered, t make numbered backups
371
- existing, nil numbered if numbered backups exist, simple otherwise
372
- simple, never always make simple backups
373
- The backup suffix is `~', unless set with --suffix or the SIMPLE_BACKUP_SUFFIX
374
- environment variable.
375
- =end
376
-
377
- def initialize
378
- @output = STDOUT
379
- @fuzzy = nil
380
- @update = nil
381
- @backup = ENV["VERSION_CONTROL"]
382
- @suffix= ENV["SIMPLE_BACKUP_SUFFIX"] || "~"
383
- @input_dirs = ["."]
384
- end
385
-
386
- end
387
-
388
- end
389
-
390
- module GetText
391
-
392
- module RMsgMerge
393
- extend GetText
394
- extend self
395
-
396
- bindtextdomain("rgettext")
397
-
398
- # constant values
399
- VERSION = GetText::VERSION
400
- DATE = %w($Date: 2007/07/21 15:03:05 $)[1]
401
-
402
- def check_options(config)
403
- opts = OptionParser.new
404
- opts.banner = _("Usage: %s def.po ref.pot [-o output.pot]") % $0
405
- #opts.summary_width = 80
406
- opts.separator("")
407
- opts.separator(_("Merges two Uniforum style .po files together. The def.po file is an existing PO file with translations. The ref.pot file is the last created PO file with up-to-date source references. ref.pot is generally created by rgettext."))
408
- opts.separator("")
409
- opts.separator(_("Specific options:"))
410
-
411
- opts.on("-o", "--output=FILE", _("write output to specified file")) do |out|
412
- unless FileTest.exist? out
413
- config.output = out
414
- else
415
- #$stderr.puts(_("File '%s' has already existed.") % out)
416
- #exit 1
417
- end
418
- end
419
-
420
- #opts.on("-F", "--fuzzy-matching")
421
-
422
- opts.on_tail("--version", _("display version information and exit")) do
423
- puts "#{$0} #{VERSION} (#{DATE})"
424
- puts "#{File.join(::Config::CONFIG["bindir"], ::Config::CONFIG["RUBY_INSTALL_NAME"])} #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
425
- exit
426
- end
427
-
428
- opts.parse!(ARGV)
429
-
430
- if ARGV.size != 2
431
- puts opts.help
432
- exit 1
433
- end
434
-
435
- config.defpo = ARGV[0]
436
- config.refpot = ARGV[1]
437
- end
438
-
439
- def run(reference = nil, definition = nil, out = STDOUT)
440
- config = GetText::RMsgMerge::Config.new
441
- config.refpot = reference
442
- config.defpo = definition
443
- config.output = out
444
-
445
- check_options(config)
446
-
447
- if config.defpo.nil?
448
- raise ArgumentError, _("definition po is not given.")
449
- elsif config.refpot.nil?
450
- raise ArgumentError, _("reference pot is not given.")
451
- end
452
-
453
- parser = PoParser.new
454
- defpo = parser.parse_file(config.defpo, PoData.new, false)
455
- refpot = parser.parse_file(config.refstrrefstr, PoData.new, false)
456
-
457
- m = Merger.new
458
- result = m.merge(defpo, refpot)
459
- p result if $DEBUG
460
- print result.generate_po if $DEBUG
461
-
462
- begin
463
- if out.is_a? String
464
- File.open(File.expand_path(out), "w+") do |file|
465
- file.write(result.generate_po)
466
- end
467
- else
468
- out.puts(result.generate_po)
469
- end
470
- ensure
471
- out.close
472
- end
473
- end
474
-
475
- end
476
-
477
- end
478
-
479
-
480
-
481
- module GetText
482
-
483
- # Experimental
484
- def rmsgmerge(reference = nil, definition = nil, out = STDOUT)
485
- RMsgMerge.run(reference, definition, out)
486
- end
487
-
488
- end
489
-
490
-
491
-
492
- if $0 == __FILE__ then
493
- require 'pp'
494
-
495
- #parser = GetText::RMsgMerge::PoParser.new;
496
- #parser = GetText::PoParser.new;
497
- #pp parser.parse(ARGF.read)
498
-
499
- GetText.rmsgmerge
500
- end