gettext 3.0.0 → 3.0.1

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 (441) hide show
  1. data/Rakefile +23 -12
  2. data/doc/text/news.md +31 -0
  3. data/lib/gettext/po.rb +17 -7
  4. data/lib/gettext/po_entry.rb +212 -208
  5. data/lib/gettext/po_format.rb +28 -0
  6. data/lib/gettext/po_parser.rb +25 -25
  7. data/lib/gettext/text_domain.rb +10 -0
  8. data/lib/gettext/tools/msginit.rb +19 -1
  9. data/lib/gettext/tools/msgmerge.rb +122 -68
  10. data/lib/gettext/tools/task.rb +306 -87
  11. data/lib/gettext/tools/xgettext.rb +27 -1
  12. data/lib/gettext/version.rb +1 -1
  13. data/locale/bg/LC_MESSAGES/gettext.mo +0 -0
  14. data/locale/bs/LC_MESSAGES/gettext.mo +0 -0
  15. data/locale/ca/LC_MESSAGES/gettext.mo +0 -0
  16. data/locale/cs/LC_MESSAGES/gettext.mo +0 -0
  17. data/locale/de/LC_MESSAGES/gettext.mo +0 -0
  18. data/locale/el/LC_MESSAGES/gettext.mo +0 -0
  19. data/locale/eo/LC_MESSAGES/gettext.mo +0 -0
  20. data/locale/es/LC_MESSAGES/gettext.mo +0 -0
  21. data/locale/et/LC_MESSAGES/gettext.mo +0 -0
  22. data/locale/fr/LC_MESSAGES/gettext.mo +0 -0
  23. data/locale/hr/LC_MESSAGES/gettext.mo +0 -0
  24. data/locale/hu/LC_MESSAGES/gettext.mo +0 -0
  25. data/locale/it/LC_MESSAGES/gettext.mo +0 -0
  26. data/locale/ja/LC_MESSAGES/gettext.mo +0 -0
  27. data/locale/ko/LC_MESSAGES/gettext.mo +0 -0
  28. data/locale/lv/LC_MESSAGES/gettext.mo +0 -0
  29. data/locale/nb/LC_MESSAGES/gettext.mo +0 -0
  30. data/locale/nl/LC_MESSAGES/gettext.mo +0 -0
  31. data/locale/pt_BR/LC_MESSAGES/gettext.mo +0 -0
  32. data/locale/ru/LC_MESSAGES/gettext.mo +0 -0
  33. data/locale/sr/LC_MESSAGES/gettext.mo +0 -0
  34. data/locale/sv/LC_MESSAGES/gettext.mo +0 -0
  35. data/locale/uk/LC_MESSAGES/gettext.mo +0 -0
  36. data/locale/vi/LC_MESSAGES/gettext.mo +0 -0
  37. data/locale/zh/LC_MESSAGES/gettext.mo +0 -0
  38. data/locale/zh_TW/LC_MESSAGES/gettext.mo +0 -0
  39. data/po/bg/gettext.po +370 -284
  40. data/po/bs/gettext.po +378 -321
  41. data/po/ca/gettext.po +373 -284
  42. data/po/cs/gettext.po +371 -313
  43. data/po/de/gettext.po +380 -282
  44. data/po/el/gettext.po +377 -277
  45. data/po/eo/gettext.po +373 -275
  46. data/po/es/gettext.po +376 -277
  47. data/po/et/gettext.po +374 -274
  48. data/po/fr/gettext.po +380 -279
  49. data/po/gettext.pot +102 -70
  50. data/po/hr/gettext.po +371 -308
  51. data/po/hu/gettext.po +376 -276
  52. data/po/it/gettext.po +362 -269
  53. data/po/ja/gettext.po +338 -216
  54. data/po/ko/gettext.po +392 -266
  55. data/po/lv/gettext.po +377 -310
  56. data/po/nb/gettext.po +377 -278
  57. data/po/nl/gettext.po +371 -274
  58. data/po/pt_BR/gettext.po +376 -277
  59. data/po/ru/gettext.po +380 -311
  60. data/po/sr/gettext.po +378 -310
  61. data/po/sv/gettext.po +331 -258
  62. data/po/uk/gettext.po +380 -311
  63. data/po/vi/gettext.po +374 -275
  64. data/po/zh/gettext.po +397 -266
  65. data/po/zh_TW/gettext.po +397 -266
  66. data/samples/cgi/README +0 -2
  67. data/samples/cgi/locale/bg/LC_MESSAGES/helloerb1.mo +0 -0
  68. data/samples/cgi/locale/bg/LC_MESSAGES/helloerb2.mo +0 -0
  69. data/samples/cgi/locale/bg/LC_MESSAGES/hellolib.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/hellolib.mo +0 -0
  74. data/samples/cgi/locale/bs/LC_MESSAGES/main.mo +0 -0
  75. data/samples/cgi/locale/ca/LC_MESSAGES/helloerb1.mo +0 -0
  76. data/samples/cgi/locale/ca/LC_MESSAGES/helloerb2.mo +0 -0
  77. data/samples/cgi/locale/ca/LC_MESSAGES/hellolib.mo +0 -0
  78. data/samples/cgi/locale/ca/LC_MESSAGES/main.mo +0 -0
  79. data/samples/cgi/locale/cs/LC_MESSAGES/helloerb1.mo +0 -0
  80. data/samples/cgi/locale/cs/LC_MESSAGES/helloerb2.mo +0 -0
  81. data/samples/cgi/locale/cs/LC_MESSAGES/hellolib.mo +0 -0
  82. data/samples/cgi/locale/cs/LC_MESSAGES/main.mo +0 -0
  83. data/samples/cgi/locale/de/LC_MESSAGES/helloerb1.mo +0 -0
  84. data/samples/cgi/locale/de/LC_MESSAGES/helloerb2.mo +0 -0
  85. data/samples/cgi/locale/de/LC_MESSAGES/hellolib.mo +0 -0
  86. data/samples/cgi/locale/de/LC_MESSAGES/main.mo +0 -0
  87. data/samples/cgi/locale/el/LC_MESSAGES/helloerb1.mo +0 -0
  88. data/samples/cgi/locale/el/LC_MESSAGES/helloerb2.mo +0 -0
  89. data/samples/cgi/locale/el/LC_MESSAGES/hellolib.mo +0 -0
  90. data/samples/cgi/locale/el/LC_MESSAGES/main.mo +0 -0
  91. data/samples/cgi/locale/eo/LC_MESSAGES/helloerb1.mo +0 -0
  92. data/samples/cgi/locale/eo/LC_MESSAGES/helloerb2.mo +0 -0
  93. data/samples/cgi/locale/eo/LC_MESSAGES/hellolib.mo +0 -0
  94. data/samples/cgi/locale/eo/LC_MESSAGES/main.mo +0 -0
  95. data/samples/cgi/locale/es/LC_MESSAGES/helloerb1.mo +0 -0
  96. data/samples/cgi/locale/es/LC_MESSAGES/helloerb2.mo +0 -0
  97. data/samples/cgi/locale/es/LC_MESSAGES/hellolib.mo +0 -0
  98. data/samples/cgi/locale/es/LC_MESSAGES/main.mo +0 -0
  99. data/samples/cgi/locale/fr/LC_MESSAGES/helloerb1.mo +0 -0
  100. data/samples/cgi/locale/fr/LC_MESSAGES/helloerb2.mo +0 -0
  101. data/samples/cgi/locale/fr/LC_MESSAGES/hellolib.mo +0 -0
  102. data/samples/cgi/locale/fr/LC_MESSAGES/main.mo +0 -0
  103. data/samples/cgi/locale/hr/LC_MESSAGES/helloerb1.mo +0 -0
  104. data/samples/cgi/locale/hr/LC_MESSAGES/helloerb2.mo +0 -0
  105. data/samples/cgi/locale/hr/LC_MESSAGES/hellolib.mo +0 -0
  106. data/samples/cgi/locale/hr/LC_MESSAGES/main.mo +0 -0
  107. data/samples/cgi/locale/hu/LC_MESSAGES/helloerb1.mo +0 -0
  108. data/samples/cgi/locale/hu/LC_MESSAGES/helloerb2.mo +0 -0
  109. data/samples/cgi/locale/hu/LC_MESSAGES/hellolib.mo +0 -0
  110. data/samples/cgi/locale/hu/LC_MESSAGES/main.mo +0 -0
  111. data/samples/cgi/locale/it/LC_MESSAGES/helloerb1.mo +0 -0
  112. data/samples/cgi/locale/it/LC_MESSAGES/helloerb2.mo +0 -0
  113. data/samples/cgi/locale/it/LC_MESSAGES/hellolib.mo +0 -0
  114. data/samples/cgi/locale/it/LC_MESSAGES/main.mo +0 -0
  115. data/samples/cgi/locale/ja/LC_MESSAGES/helloerb1.mo +0 -0
  116. data/samples/cgi/locale/ja/LC_MESSAGES/helloerb2.mo +0 -0
  117. data/samples/cgi/locale/ja/LC_MESSAGES/hellolib.mo +0 -0
  118. data/samples/cgi/locale/ja/LC_MESSAGES/main.mo +0 -0
  119. data/samples/cgi/locale/ko/LC_MESSAGES/helloerb1.mo +0 -0
  120. data/samples/cgi/locale/ko/LC_MESSAGES/helloerb2.mo +0 -0
  121. data/samples/cgi/locale/ko/LC_MESSAGES/hellolib.mo +0 -0
  122. data/samples/cgi/locale/ko/LC_MESSAGES/main.mo +0 -0
  123. data/samples/cgi/locale/lv/LC_MESSAGES/helloerb1.mo +0 -0
  124. data/samples/cgi/locale/lv/LC_MESSAGES/helloerb2.mo +0 -0
  125. data/samples/cgi/locale/lv/LC_MESSAGES/hellolib.mo +0 -0
  126. data/samples/cgi/locale/lv/LC_MESSAGES/main.mo +0 -0
  127. data/samples/cgi/locale/nb/LC_MESSAGES/helloerb1.mo +0 -0
  128. data/samples/cgi/locale/nb/LC_MESSAGES/helloerb2.mo +0 -0
  129. data/samples/cgi/locale/nb/LC_MESSAGES/hellolib.mo +0 -0
  130. data/samples/cgi/locale/nb/LC_MESSAGES/main.mo +0 -0
  131. data/samples/cgi/locale/nl/LC_MESSAGES/helloerb1.mo +0 -0
  132. data/samples/cgi/locale/nl/LC_MESSAGES/helloerb2.mo +0 -0
  133. data/samples/cgi/locale/nl/LC_MESSAGES/hellolib.mo +0 -0
  134. data/samples/cgi/locale/nl/LC_MESSAGES/main.mo +0 -0
  135. data/samples/cgi/locale/pt_BR/LC_MESSAGES/helloerb1.mo +0 -0
  136. data/samples/cgi/locale/pt_BR/LC_MESSAGES/helloerb2.mo +0 -0
  137. data/samples/cgi/locale/pt_BR/LC_MESSAGES/hellolib.mo +0 -0
  138. data/samples/cgi/locale/pt_BR/LC_MESSAGES/main.mo +0 -0
  139. data/samples/cgi/locale/ru/LC_MESSAGES/helloerb1.mo +0 -0
  140. data/samples/cgi/locale/ru/LC_MESSAGES/helloerb2.mo +0 -0
  141. data/samples/cgi/locale/ru/LC_MESSAGES/hellolib.mo +0 -0
  142. data/samples/cgi/locale/ru/LC_MESSAGES/main.mo +0 -0
  143. data/samples/cgi/locale/sr/LC_MESSAGES/helloerb1.mo +0 -0
  144. data/samples/cgi/locale/sr/LC_MESSAGES/helloerb2.mo +0 -0
  145. data/samples/cgi/locale/sr/LC_MESSAGES/hellolib.mo +0 -0
  146. data/samples/cgi/locale/sr/LC_MESSAGES/main.mo +0 -0
  147. data/samples/cgi/locale/uk/LC_MESSAGES/helloerb1.mo +0 -0
  148. data/samples/cgi/locale/uk/LC_MESSAGES/helloerb2.mo +0 -0
  149. data/samples/cgi/locale/uk/LC_MESSAGES/hellolib.mo +0 -0
  150. data/samples/cgi/locale/uk/LC_MESSAGES/main.mo +0 -0
  151. data/samples/cgi/locale/vi/LC_MESSAGES/helloerb1.mo +0 -0
  152. data/samples/cgi/locale/vi/LC_MESSAGES/helloerb2.mo +0 -0
  153. data/samples/cgi/locale/vi/LC_MESSAGES/hellolib.mo +0 -0
  154. data/samples/cgi/locale/vi/LC_MESSAGES/main.mo +0 -0
  155. data/samples/cgi/locale/zh/LC_MESSAGES/helloerb1.mo +0 -0
  156. data/samples/cgi/locale/zh/LC_MESSAGES/helloerb2.mo +0 -0
  157. data/samples/cgi/locale/zh/LC_MESSAGES/hellolib.mo +0 -0
  158. data/samples/cgi/locale/zh/LC_MESSAGES/main.mo +0 -0
  159. data/samples/cgi/locale/zh_TW/LC_MESSAGES/helloerb1.mo +0 -0
  160. data/samples/cgi/locale/zh_TW/LC_MESSAGES/helloerb2.mo +0 -0
  161. data/samples/cgi/locale/zh_TW/LC_MESSAGES/hellolib.mo +0 -0
  162. data/samples/cgi/locale/zh_TW/LC_MESSAGES/main.mo +0 -0
  163. data/samples/locale/bg/LC_MESSAGES/hello.mo +0 -0
  164. data/samples/locale/bg/LC_MESSAGES/hello2.mo +0 -0
  165. data/samples/locale/bg/LC_MESSAGES/hello_glade2.mo +0 -0
  166. data/samples/locale/bg/LC_MESSAGES/hello_gtk2.mo +0 -0
  167. data/samples/locale/bg/LC_MESSAGES/hello_gtk_builder.mo +0 -0
  168. data/samples/locale/bg/LC_MESSAGES/hello_noop.mo +0 -0
  169. data/samples/locale/bg/LC_MESSAGES/hello_plural.mo +0 -0
  170. data/samples/locale/bg/LC_MESSAGES/hello_tk.mo +0 -0
  171. data/samples/locale/bs/LC_MESSAGES/hello.mo +0 -0
  172. data/samples/locale/bs/LC_MESSAGES/hello2.mo +0 -0
  173. data/samples/locale/bs/LC_MESSAGES/hello_glade2.mo +0 -0
  174. data/samples/locale/bs/LC_MESSAGES/hello_gtk2.mo +0 -0
  175. data/samples/locale/bs/LC_MESSAGES/hello_gtk_builder.mo +0 -0
  176. data/samples/locale/bs/LC_MESSAGES/hello_noop.mo +0 -0
  177. data/samples/locale/bs/LC_MESSAGES/hello_plural.mo +0 -0
  178. data/samples/locale/bs/LC_MESSAGES/hello_tk.mo +0 -0
  179. data/samples/locale/ca/LC_MESSAGES/hello.mo +0 -0
  180. data/samples/locale/ca/LC_MESSAGES/hello2.mo +0 -0
  181. data/samples/locale/ca/LC_MESSAGES/hello_glade2.mo +0 -0
  182. data/samples/locale/ca/LC_MESSAGES/hello_gtk2.mo +0 -0
  183. data/samples/locale/ca/LC_MESSAGES/hello_gtk_builder.mo +0 -0
  184. data/samples/locale/ca/LC_MESSAGES/hello_noop.mo +0 -0
  185. data/samples/locale/ca/LC_MESSAGES/hello_plural.mo +0 -0
  186. data/samples/locale/ca/LC_MESSAGES/hello_tk.mo +0 -0
  187. data/samples/locale/cs/LC_MESSAGES/hello.mo +0 -0
  188. data/samples/locale/cs/LC_MESSAGES/hello2.mo +0 -0
  189. data/samples/locale/cs/LC_MESSAGES/hello_glade2.mo +0 -0
  190. data/samples/locale/cs/LC_MESSAGES/hello_gtk2.mo +0 -0
  191. data/samples/locale/cs/LC_MESSAGES/hello_gtk_builder.mo +0 -0
  192. data/samples/locale/cs/LC_MESSAGES/hello_noop.mo +0 -0
  193. data/samples/locale/cs/LC_MESSAGES/hello_plural.mo +0 -0
  194. data/samples/locale/cs/LC_MESSAGES/hello_tk.mo +0 -0
  195. data/samples/locale/de/LC_MESSAGES/hello.mo +0 -0
  196. data/samples/locale/de/LC_MESSAGES/hello2.mo +0 -0
  197. data/samples/locale/de/LC_MESSAGES/hello_glade2.mo +0 -0
  198. data/samples/locale/de/LC_MESSAGES/hello_gtk2.mo +0 -0
  199. data/samples/locale/de/LC_MESSAGES/hello_gtk_builder.mo +0 -0
  200. data/samples/locale/de/LC_MESSAGES/hello_noop.mo +0 -0
  201. data/samples/locale/de/LC_MESSAGES/hello_plural.mo +0 -0
  202. data/samples/locale/de/LC_MESSAGES/hello_tk.mo +0 -0
  203. data/samples/locale/el/LC_MESSAGES/hello.mo +0 -0
  204. data/samples/locale/el/LC_MESSAGES/hello2.mo +0 -0
  205. data/samples/locale/el/LC_MESSAGES/hello_glade2.mo +0 -0
  206. data/samples/locale/el/LC_MESSAGES/hello_gtk2.mo +0 -0
  207. data/samples/locale/el/LC_MESSAGES/hello_gtk_builder.mo +0 -0
  208. data/samples/locale/el/LC_MESSAGES/hello_noop.mo +0 -0
  209. data/samples/locale/el/LC_MESSAGES/hello_plural.mo +0 -0
  210. data/samples/locale/el/LC_MESSAGES/hello_tk.mo +0 -0
  211. data/samples/locale/eo/LC_MESSAGES/hello.mo +0 -0
  212. data/samples/locale/eo/LC_MESSAGES/hello2.mo +0 -0
  213. data/samples/locale/eo/LC_MESSAGES/hello_glade2.mo +0 -0
  214. data/samples/locale/eo/LC_MESSAGES/hello_gtk2.mo +0 -0
  215. data/samples/locale/eo/LC_MESSAGES/hello_gtk_builder.mo +0 -0
  216. data/samples/locale/eo/LC_MESSAGES/hello_noop.mo +0 -0
  217. data/samples/locale/eo/LC_MESSAGES/hello_plural.mo +0 -0
  218. data/samples/locale/eo/LC_MESSAGES/hello_tk.mo +0 -0
  219. data/samples/locale/es/LC_MESSAGES/hello.mo +0 -0
  220. data/samples/locale/es/LC_MESSAGES/hello2.mo +0 -0
  221. data/samples/locale/es/LC_MESSAGES/hello_glade2.mo +0 -0
  222. data/samples/locale/es/LC_MESSAGES/hello_gtk2.mo +0 -0
  223. data/samples/locale/es/LC_MESSAGES/hello_gtk_builder.mo +0 -0
  224. data/samples/locale/es/LC_MESSAGES/hello_noop.mo +0 -0
  225. data/samples/locale/es/LC_MESSAGES/hello_plural.mo +0 -0
  226. data/samples/locale/es/LC_MESSAGES/hello_tk.mo +0 -0
  227. data/samples/locale/fr/LC_MESSAGES/hello.mo +0 -0
  228. data/samples/locale/fr/LC_MESSAGES/hello2.mo +0 -0
  229. data/samples/locale/fr/LC_MESSAGES/hello_glade2.mo +0 -0
  230. data/samples/locale/fr/LC_MESSAGES/hello_gtk2.mo +0 -0
  231. data/samples/locale/fr/LC_MESSAGES/hello_gtk_builder.mo +0 -0
  232. data/samples/locale/fr/LC_MESSAGES/hello_noop.mo +0 -0
  233. data/samples/locale/fr/LC_MESSAGES/hello_plural.mo +0 -0
  234. data/samples/locale/fr/LC_MESSAGES/hello_tk.mo +0 -0
  235. data/samples/locale/hr/LC_MESSAGES/hello.mo +0 -0
  236. data/samples/locale/hr/LC_MESSAGES/hello2.mo +0 -0
  237. data/samples/locale/hr/LC_MESSAGES/hello_glade2.mo +0 -0
  238. data/samples/locale/hr/LC_MESSAGES/hello_gtk2.mo +0 -0
  239. data/samples/locale/hr/LC_MESSAGES/hello_gtk_builder.mo +0 -0
  240. data/samples/locale/hr/LC_MESSAGES/hello_noop.mo +0 -0
  241. data/samples/locale/hr/LC_MESSAGES/hello_plural.mo +0 -0
  242. data/samples/locale/hr/LC_MESSAGES/hello_tk.mo +0 -0
  243. data/samples/locale/hu/LC_MESSAGES/hello.mo +0 -0
  244. data/samples/locale/hu/LC_MESSAGES/hello2.mo +0 -0
  245. data/samples/locale/hu/LC_MESSAGES/hello_glade2.mo +0 -0
  246. data/samples/locale/hu/LC_MESSAGES/hello_gtk2.mo +0 -0
  247. data/samples/locale/hu/LC_MESSAGES/hello_gtk_builder.mo +0 -0
  248. data/samples/locale/hu/LC_MESSAGES/hello_noop.mo +0 -0
  249. data/samples/locale/hu/LC_MESSAGES/hello_plural.mo +0 -0
  250. data/samples/locale/hu/LC_MESSAGES/hello_tk.mo +0 -0
  251. data/samples/locale/it/LC_MESSAGES/hello.mo +0 -0
  252. data/samples/locale/it/LC_MESSAGES/hello2.mo +0 -0
  253. data/samples/locale/it/LC_MESSAGES/hello_glade2.mo +0 -0
  254. data/samples/locale/it/LC_MESSAGES/hello_gtk2.mo +0 -0
  255. data/samples/locale/it/LC_MESSAGES/hello_gtk_builder.mo +0 -0
  256. data/samples/locale/it/LC_MESSAGES/hello_noop.mo +0 -0
  257. data/samples/locale/it/LC_MESSAGES/hello_plural.mo +0 -0
  258. data/samples/locale/it/LC_MESSAGES/hello_tk.mo +0 -0
  259. data/samples/locale/ja/LC_MESSAGES/hello.mo +0 -0
  260. data/samples/locale/ja/LC_MESSAGES/hello2.mo +0 -0
  261. data/samples/locale/ja/LC_MESSAGES/hello_glade2.mo +0 -0
  262. data/samples/locale/ja/LC_MESSAGES/hello_gtk2.mo +0 -0
  263. data/samples/locale/ja/LC_MESSAGES/hello_gtk_builder.mo +0 -0
  264. data/samples/locale/ja/LC_MESSAGES/hello_noop.mo +0 -0
  265. data/samples/locale/ja/LC_MESSAGES/hello_plural.mo +0 -0
  266. data/samples/locale/ja/LC_MESSAGES/hello_tk.mo +0 -0
  267. data/samples/locale/ko/LC_MESSAGES/hello.mo +0 -0
  268. data/samples/locale/ko/LC_MESSAGES/hello2.mo +0 -0
  269. data/samples/locale/ko/LC_MESSAGES/hello_glade2.mo +0 -0
  270. data/samples/locale/ko/LC_MESSAGES/hello_gtk2.mo +0 -0
  271. data/samples/locale/ko/LC_MESSAGES/hello_gtk_builder.mo +0 -0
  272. data/samples/locale/ko/LC_MESSAGES/hello_noop.mo +0 -0
  273. data/samples/locale/ko/LC_MESSAGES/hello_plural.mo +0 -0
  274. data/samples/locale/ko/LC_MESSAGES/hello_tk.mo +0 -0
  275. data/samples/locale/lv/LC_MESSAGES/hello.mo +0 -0
  276. data/samples/locale/lv/LC_MESSAGES/hello2.mo +0 -0
  277. data/samples/locale/lv/LC_MESSAGES/hello_glade2.mo +0 -0
  278. data/samples/locale/lv/LC_MESSAGES/hello_gtk2.mo +0 -0
  279. data/samples/locale/lv/LC_MESSAGES/hello_gtk_builder.mo +0 -0
  280. data/samples/locale/lv/LC_MESSAGES/hello_noop.mo +0 -0
  281. data/samples/locale/lv/LC_MESSAGES/hello_plural.mo +0 -0
  282. data/samples/locale/lv/LC_MESSAGES/hello_tk.mo +0 -0
  283. data/samples/locale/nb/LC_MESSAGES/hello.mo +0 -0
  284. data/samples/locale/nb/LC_MESSAGES/hello2.mo +0 -0
  285. data/samples/locale/nb/LC_MESSAGES/hello_glade2.mo +0 -0
  286. data/samples/locale/nb/LC_MESSAGES/hello_gtk2.mo +0 -0
  287. data/samples/locale/nb/LC_MESSAGES/hello_gtk_builder.mo +0 -0
  288. data/samples/locale/nb/LC_MESSAGES/hello_noop.mo +0 -0
  289. data/samples/locale/nb/LC_MESSAGES/hello_plural.mo +0 -0
  290. data/samples/locale/nb/LC_MESSAGES/hello_tk.mo +0 -0
  291. data/samples/locale/nl/LC_MESSAGES/hello.mo +0 -0
  292. data/samples/locale/nl/LC_MESSAGES/hello2.mo +0 -0
  293. data/samples/locale/nl/LC_MESSAGES/hello_glade2.mo +0 -0
  294. data/samples/locale/nl/LC_MESSAGES/hello_gtk2.mo +0 -0
  295. data/samples/locale/nl/LC_MESSAGES/hello_gtk_builder.mo +0 -0
  296. data/samples/locale/nl/LC_MESSAGES/hello_noop.mo +0 -0
  297. data/samples/locale/nl/LC_MESSAGES/hello_plural.mo +0 -0
  298. data/samples/locale/nl/LC_MESSAGES/hello_tk.mo +0 -0
  299. data/samples/locale/pt_BR/LC_MESSAGES/hello.mo +0 -0
  300. data/samples/locale/pt_BR/LC_MESSAGES/hello2.mo +0 -0
  301. data/samples/locale/pt_BR/LC_MESSAGES/hello_glade2.mo +0 -0
  302. data/samples/locale/pt_BR/LC_MESSAGES/hello_gtk2.mo +0 -0
  303. data/samples/locale/pt_BR/LC_MESSAGES/hello_gtk_builder.mo +0 -0
  304. data/samples/locale/pt_BR/LC_MESSAGES/hello_noop.mo +0 -0
  305. data/samples/locale/pt_BR/LC_MESSAGES/hello_plural.mo +0 -0
  306. data/samples/locale/pt_BR/LC_MESSAGES/hello_tk.mo +0 -0
  307. data/samples/locale/ru/LC_MESSAGES/hello.mo +0 -0
  308. data/samples/locale/ru/LC_MESSAGES/hello2.mo +0 -0
  309. data/samples/locale/ru/LC_MESSAGES/hello_glade2.mo +0 -0
  310. data/samples/locale/ru/LC_MESSAGES/hello_gtk2.mo +0 -0
  311. data/samples/locale/ru/LC_MESSAGES/hello_gtk_builder.mo +0 -0
  312. data/samples/locale/ru/LC_MESSAGES/hello_noop.mo +0 -0
  313. data/samples/locale/ru/LC_MESSAGES/hello_plural.mo +0 -0
  314. data/samples/locale/ru/LC_MESSAGES/hello_tk.mo +0 -0
  315. data/samples/locale/sr/LC_MESSAGES/hello.mo +0 -0
  316. data/samples/locale/sr/LC_MESSAGES/hello2.mo +0 -0
  317. data/samples/locale/sr/LC_MESSAGES/hello_glade2.mo +0 -0
  318. data/samples/locale/sr/LC_MESSAGES/hello_gtk2.mo +0 -0
  319. data/samples/locale/sr/LC_MESSAGES/hello_gtk_builder.mo +0 -0
  320. data/samples/locale/sr/LC_MESSAGES/hello_noop.mo +0 -0
  321. data/samples/locale/sr/LC_MESSAGES/hello_plural.mo +0 -0
  322. data/samples/locale/sr/LC_MESSAGES/hello_tk.mo +0 -0
  323. data/samples/locale/sv/LC_MESSAGES/hello.mo +0 -0
  324. data/samples/locale/sv/LC_MESSAGES/hello2.mo +0 -0
  325. data/samples/locale/sv/LC_MESSAGES/hello_glade2.mo +0 -0
  326. data/samples/locale/sv/LC_MESSAGES/hello_gtk2.mo +0 -0
  327. data/samples/locale/sv/LC_MESSAGES/hello_gtk_builder.mo +0 -0
  328. data/samples/locale/sv/LC_MESSAGES/hello_noop.mo +0 -0
  329. data/samples/locale/sv/LC_MESSAGES/hello_plural.mo +0 -0
  330. data/samples/locale/sv/LC_MESSAGES/hello_tk.mo +0 -0
  331. data/samples/locale/uk/LC_MESSAGES/hello.mo +0 -0
  332. data/samples/locale/uk/LC_MESSAGES/hello2.mo +0 -0
  333. data/samples/locale/uk/LC_MESSAGES/hello_glade2.mo +0 -0
  334. data/samples/locale/uk/LC_MESSAGES/hello_gtk2.mo +0 -0
  335. data/samples/locale/uk/LC_MESSAGES/hello_gtk_builder.mo +0 -0
  336. data/samples/locale/uk/LC_MESSAGES/hello_noop.mo +0 -0
  337. data/samples/locale/uk/LC_MESSAGES/hello_plural.mo +0 -0
  338. data/samples/locale/uk/LC_MESSAGES/hello_tk.mo +0 -0
  339. data/samples/locale/vi/LC_MESSAGES/hello.mo +0 -0
  340. data/samples/locale/vi/LC_MESSAGES/hello2.mo +0 -0
  341. data/samples/locale/vi/LC_MESSAGES/hello_glade2.mo +0 -0
  342. data/samples/locale/vi/LC_MESSAGES/hello_gtk2.mo +0 -0
  343. data/samples/locale/vi/LC_MESSAGES/hello_gtk_builder.mo +0 -0
  344. data/samples/locale/vi/LC_MESSAGES/hello_noop.mo +0 -0
  345. data/samples/locale/vi/LC_MESSAGES/hello_plural.mo +0 -0
  346. data/samples/locale/vi/LC_MESSAGES/hello_tk.mo +0 -0
  347. data/samples/locale/zh/LC_MESSAGES/hello.mo +0 -0
  348. data/samples/locale/zh/LC_MESSAGES/hello2.mo +0 -0
  349. data/samples/locale/zh/LC_MESSAGES/hello_glade2.mo +0 -0
  350. data/samples/locale/zh/LC_MESSAGES/hello_gtk2.mo +0 -0
  351. data/samples/locale/zh/LC_MESSAGES/hello_gtk_builder.mo +0 -0
  352. data/samples/locale/zh/LC_MESSAGES/hello_noop.mo +0 -0
  353. data/samples/locale/zh/LC_MESSAGES/hello_plural.mo +0 -0
  354. data/samples/locale/zh/LC_MESSAGES/hello_tk.mo +0 -0
  355. data/samples/locale/zh_TW/LC_MESSAGES/hello.mo +0 -0
  356. data/samples/locale/zh_TW/LC_MESSAGES/hello2.mo +0 -0
  357. data/samples/locale/zh_TW/LC_MESSAGES/hello_glade2.mo +0 -0
  358. data/samples/locale/zh_TW/LC_MESSAGES/hello_gtk2.mo +0 -0
  359. data/samples/locale/zh_TW/LC_MESSAGES/hello_gtk_builder.mo +0 -0
  360. data/samples/locale/zh_TW/LC_MESSAGES/hello_noop.mo +0 -0
  361. data/samples/locale/zh_TW/LC_MESSAGES/hello_plural.mo +0 -0
  362. data/samples/locale/zh_TW/LC_MESSAGES/hello_tk.mo +0 -0
  363. data/samples/po/bg/hello_gtk_builder.po +19 -0
  364. data/samples/po/bs/hello_gtk_builder.po +19 -0
  365. data/samples/po/ca/hello_gtk_builder.po +19 -0
  366. data/samples/po/cs/hello_gtk_builder.po +19 -0
  367. data/samples/po/de/hello_gtk_builder.po +19 -0
  368. data/samples/po/el/hello_gtk_builder.po +19 -0
  369. data/samples/po/eo/hello_gtk_builder.po +19 -0
  370. data/samples/po/es/hello_gtk_builder.po +19 -0
  371. data/samples/po/fr/hello_gtk_builder.po +19 -0
  372. data/samples/po/hello.pot +24 -0
  373. data/samples/po/hello2.pot +33 -0
  374. data/samples/po/hello_glade2.pot +31 -0
  375. data/samples/po/hello_gtk2.pot +23 -0
  376. data/samples/po/hello_gtk_builder.pot +20 -0
  377. data/samples/po/hello_noop.pot +27 -0
  378. data/samples/po/hello_plural.pot +27 -0
  379. data/samples/po/hello_tk.pot +23 -0
  380. data/samples/po/hr/hello_gtk_builder.po +19 -0
  381. data/samples/po/hu/hello_gtk_builder.po +19 -0
  382. data/samples/po/it/hello_gtk_builder.po +19 -0
  383. data/samples/po/ja/hello_gtk_builder.po +19 -0
  384. data/samples/po/ko/hello_gtk_builder.po +19 -0
  385. data/samples/po/lv/hello_gtk_builder.po +19 -0
  386. data/samples/po/nb/hello_gtk_builder.po +19 -0
  387. data/samples/po/nl/hello_gtk_builder.po +19 -0
  388. data/samples/po/pt_BR/hello_gtk_builder.po +19 -0
  389. data/samples/po/ru/hello_gtk_builder.po +19 -0
  390. data/samples/po/sr/hello_gtk_builder.po +19 -0
  391. data/samples/po/sv/hello_gtk_builder.po +19 -0
  392. data/samples/po/uk/hello_gtk_builder.po +19 -0
  393. data/samples/po/vi/hello_gtk_builder.po +19 -0
  394. data/samples/po/zh/hello_gtk_builder.po +19 -0
  395. data/samples/po/zh_TW/hello_gtk_builder.po +19 -0
  396. data/src/po_parser.ry +25 -25
  397. data/test/locale/cr/LC_MESSAGES/plural.mo +0 -0
  398. data/test/locale/da/LC_MESSAGES/plural.mo +0 -0
  399. data/test/locale/da/LC_MESSAGES/plural_error.mo +0 -0
  400. data/test/locale/fr/LC_MESSAGES/plural.mo +0 -0
  401. data/test/locale/fr/LC_MESSAGES/plural_error.mo +0 -0
  402. data/test/locale/fr/LC_MESSAGES/test1.mo +0 -0
  403. data/test/locale/fr/LC_MESSAGES/test2.mo +0 -0
  404. data/test/locale/ir/LC_MESSAGES/plural.mo +0 -0
  405. data/test/locale/ja/LC_MESSAGES/_.mo +0 -0
  406. data/test/locale/ja/LC_MESSAGES/backslash.mo +0 -0
  407. data/test/locale/ja/LC_MESSAGES/non_ascii.mo +0 -0
  408. data/test/locale/ja/LC_MESSAGES/np_.mo +0 -0
  409. data/test/locale/ja/LC_MESSAGES/ns_.mo +0 -0
  410. data/test/locale/ja/LC_MESSAGES/p_.mo +0 -0
  411. data/test/locale/ja/LC_MESSAGES/plural.mo +0 -0
  412. data/test/locale/ja/LC_MESSAGES/plural_error.mo +0 -0
  413. data/test/locale/ja/LC_MESSAGES/rubyparser.mo +0 -0
  414. data/test/locale/ja/LC_MESSAGES/s_.mo +0 -0
  415. data/test/locale/ja/LC_MESSAGES/test1.mo +0 -0
  416. data/test/locale/ja/LC_MESSAGES/test2.mo +0 -0
  417. data/test/locale/ja/LC_MESSAGES/test3.mo +0 -0
  418. data/test/locale/ja/LC_MESSAGES/untranslated.mo +0 -0
  419. data/test/locale/la/LC_MESSAGES/plural.mo +0 -0
  420. data/test/locale/la/LC_MESSAGES/plural_error.mo +0 -0
  421. data/test/locale/li/LC_MESSAGES/plural.mo +0 -0
  422. data/test/locale/li/LC_MESSAGES/plural_error.mo +0 -0
  423. data/test/locale/po/LC_MESSAGES/plural.mo +0 -0
  424. data/test/locale/sl/LC_MESSAGES/plural.mo +0 -0
  425. data/test/po/_.pot +162 -0
  426. data/test/po/backslash.pot +23 -0
  427. data/test/po/non_ascii.pot +23 -0
  428. data/test/po/np_.pot +48 -0
  429. data/test/po/ns_.pot +73 -0
  430. data/test/po/p_.pot +50 -0
  431. data/test/po/s_.pot +55 -0
  432. data/test/po/untranslated.pot +23 -0
  433. data/test/test_locale_path.rb +25 -3
  434. data/test/{tools/test_po.rb → test_po.rb} +217 -210
  435. data/test/test_po_entry.rb +107 -53
  436. data/test/test_text_domain.rb +38 -0
  437. data/test/tools/test_msgmerge.rb +206 -5
  438. data/test/tools/test_task.rb +287 -0
  439. data/test/tools/test_xgettext.rb +3 -1
  440. metadata +373 -4
  441. data/samples/cgi/Rakefile +0 -27
@@ -0,0 +1,28 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2012-2013 Kouhei Sutou <kou@clear-code.com>
4
+ #
5
+ # License: Ruby's or LGPL
6
+ #
7
+ # This library is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This library is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ module GetText
21
+ module POFormat
22
+ TRANSLATOR_COMMENT_MARK = "# "
23
+ EXTRACTED_COMMENT_MARK = "#."
24
+ FLAG_MARK = "#,"
25
+ PREVIOUS_COMMENT_MARK = "#|"
26
+ REFERENCE_COMMENT_MARK = "#:"
27
+ end
28
+ end
@@ -77,39 +77,39 @@ module_eval(<<'...end po_parser.ry/module_eval...', 'po_parser.ry', 123)
77
77
  until str.empty? do
78
78
  case str
79
79
  when /\A\s+/
80
- str = $'
80
+ str = $'
81
81
  when /\Amsgctxt/
82
- @q.push [:MSGCTXT, $&]
83
- str = $'
82
+ @q.push [:MSGCTXT, $&]
83
+ str = $'
84
84
  when /\Amsgid_plural/
85
- @q.push [:MSGID_PLURAL, $&]
86
- str = $'
85
+ @q.push [:MSGID_PLURAL, $&]
86
+ str = $'
87
87
  when /\Amsgid/
88
- @q.push [:MSGID, $&]
89
- str = $'
88
+ @q.push [:MSGID, $&]
89
+ str = $'
90
90
  when /\Amsgstr/
91
- @q.push [:MSGSTR, $&]
92
- str = $'
91
+ @q.push [:MSGSTR, $&]
92
+ str = $'
93
93
  when /\A\[(\d+)\]/
94
- @q.push [:PLURAL_NUM, $1]
95
- str = $'
94
+ @q.push [:PLURAL_NUM, $1]
95
+ str = $'
96
96
  when /\A\#~(.*)/
97
97
  if report_warning?
98
98
  $stderr.print _("Warning: obsolete msgid exists.\n")
99
99
  $stderr.print " #{$&}\n"
100
100
  end
101
- @q.push [:COMMENT, $&]
102
- str = $'
101
+ @q.push [:COMMENT, $&]
102
+ str = $'
103
103
  when /\A\#(.*)/
104
- @q.push [:COMMENT, $&]
105
- str = $'
104
+ @q.push [:COMMENT, $&]
105
+ str = $'
106
106
  when /\A\"(.*)\"/
107
- @q.push [:STRING, unescape_string($1)]
108
- str = $'
107
+ @q.push [:STRING, unescape_string($1)]
108
+ str = $'
109
109
  else
110
- #c = str[0,1]
111
- #@q.push [:STRING, c]
112
- str = str[1..-1]
110
+ #c = str[0,1]
111
+ #@q.push [:STRING, c]
112
+ str = str[1..-1]
113
113
  end
114
114
  end
115
115
  @q.push [false, "$end"]
@@ -184,15 +184,15 @@ module_eval(<<'...end po_parser.ry/module_eval...', 'po_parser.ry', 123)
184
184
  mark = $1
185
185
  content = $2
186
186
  case mark
187
- when POEntry::TRANSLATOR_COMMENT_MARK
187
+ when POFormat::TRANSLATOR_COMMENT_MARK
188
188
  @translator_comments << content
189
- when POEntry::EXTRACTED_COMMENT_MARK
189
+ when POFormat::EXTRACTED_COMMENT_MARK
190
190
  @extracted_comments << content
191
- when POEntry::REFERENCE_COMMENT_MARK
191
+ when POFormat::REFERENCE_COMMENT_MARK
192
192
  @references.concat(parse_references_line(content))
193
- when POEntry::FLAG_MARK
193
+ when POFormat::FLAG_MARK
194
194
  @flag << content
195
- when POEntry::PREVIOUS_COMMENT_MARK
195
+ when POFormat::PREVIOUS_COMMENT_MARK
196
196
  @previous << content
197
197
  else
198
198
  @comments << comment
@@ -164,10 +164,20 @@ module GetText
164
164
 
165
165
  if path
166
166
  charset = @output_charset || lang.charset || Locale.charset || "UTF-8"
167
+ charset = normalize_charset(charset)
167
168
  @mofiles[lang_key] = MO.open(path, charset)
168
169
  else
169
170
  @mofiles[lang_key] = :empty
170
171
  end
171
172
  end
173
+
174
+ def normalize_charset(charset)
175
+ case charset
176
+ when /\Autf8\z/i
177
+ "UTF-8"
178
+ else
179
+ charset
180
+ end
181
+ end
172
182
  end
173
183
  end
@@ -18,6 +18,7 @@
18
18
  # You should have received a copy of the GNU Lesser General Public License
19
19
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
20
20
 
21
+ require "etc"
21
22
  require "gettext"
22
23
  require "gettext/po_parser"
23
24
  require "gettext/tools/msgmerge"
@@ -200,7 +201,24 @@ module GetText
200
201
  end
201
202
 
202
203
  def guess_full_name
203
- ENV["USERNAME"]
204
+ full_name = guess_full_name_from_password_entry
205
+ full_name ||= ENV["USERNAME"]
206
+ full_name
207
+ end
208
+
209
+ def guess_full_name_from_password_entry
210
+ password_entry = find_password_entry
211
+ return nil if password_entry.nil?
212
+
213
+ full_name = password_entry.gecos.split(/,/).first.strip
214
+ full_name = nil if full_name.empty?
215
+ full_name
216
+ end
217
+
218
+ def find_password_entry
219
+ Etc.getpwuid
220
+ rescue ArgumentError
221
+ nil
204
222
  end
205
223
 
206
224
  def translator_mail
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  # Copyright (C) 2012-2013 Haruka Yoshihara <yoshihara@clear-code.com>
4
- # Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
4
+ # Copyright (C) 2012-2013 Kouhei Sutou <kou@clear-code.com>
5
5
  # Copyright (C) 2005-2009 Masao Mutoh
6
6
  # Copyright (C) 2005,2006 speakillof
7
7
  #
@@ -192,9 +192,16 @@ module GetText
192
192
  end
193
193
  end
194
194
 
195
- class Config #:nodoc:
195
+ # @private
196
+ class Config
197
+ include GetText
196
198
 
197
- attr_accessor :defpo, :refpot, :output, :fuzzy, :update
199
+ bindtextdomain("gettext")
200
+
201
+ attr_accessor :definition_po, :reference_pot
202
+ attr_accessor :output, :fuzzy, :update
203
+ attr_accessor :order
204
+ attr_accessor :po_format_options
198
205
 
199
206
  # update mode options
200
207
  attr_accessor :backup, :suffix
@@ -213,106 +220,153 @@ module GetText
213
220
  # the SIMPLE_BACKUP_SUFFIX environment variable.
214
221
 
215
222
  def initialize
223
+ @definition_po = nil
224
+ @reference_po = nil
225
+ @update = false
216
226
  @output = nil
227
+ @order = :references
228
+ @po_format_options = {
229
+ :max_line_width => POEntry::Formatter::DEFAULT_MAX_LINE_WIDTH,
230
+ }
217
231
  @fuzzy = nil
218
232
  @update = nil
219
233
  @backup = ENV["VERSION_CONTROL"]
220
234
  @suffix = ENV["SIMPLE_BACKUP_SUFFIX"] || "~"
221
235
  @input_dirs = ["."]
222
236
  end
223
- end
224
237
 
225
- class << self
226
- # Merge a po-file inluding translated messages and a new pot-file.
227
- # @param [Array<String>] arguments arguments for rmsgfmt.
228
- # @return [void]
229
- def run(*arguments)
230
- new.run(*arguments)
238
+ def parse(command_line)
239
+ parser = create_option_parser
240
+ rest = parser.parse(command_line)
241
+
242
+ if rest.size != 2
243
+ puts(parser.help)
244
+ exit(false)
245
+ end
246
+
247
+ @definition_po, @reference_pot = rest
248
+ @output = @definition_po if @update
231
249
  end
232
- end
233
250
 
234
- include GetText
251
+ private
252
+ def create_option_parser
253
+ parser = OptionParser.new
254
+ parser.banner =
255
+ _("Usage: %s [OPTIONS] definition.po reference.pot") % $0
256
+ #parser.summary_width = 80
257
+ parser.separator("")
258
+ description = _("Merges two Uniforum style .po files together. " +
259
+ "The definition.po file is an existing PO file " +
260
+ "with translations. The reference.pot file is " +
261
+ "the last created PO file with up-to-date source " +
262
+ "references. The reference.pot is generally " +
263
+ "created by rxgettext.")
264
+ parser.separator(description)
265
+ parser.separator("")
266
+ parser.separator(_("Specific options:"))
267
+
268
+ parser.on("-U", "--[no-]update",
269
+ _("Update definition.po")) do |update|
270
+ @update = update
271
+ end
235
272
 
236
- bindtextdomain("gettext")
273
+ parser.on("-o", "--output=FILE",
274
+ _("Write output to specified file")) do |output|
275
+ @output = output
276
+ end
237
277
 
238
- # constant values
239
- VERSION = GetText::VERSION
278
+ parser.on("--[no-]sort-output",
279
+ _("Generate sorted output")) do |sort|
280
+ @order = sort ? :references : nil
281
+ end
240
282
 
241
- def check_command_line_options(*options) #:nodoc:
242
- options, output = parse_arguments(*options)
283
+ parser.on("--[no-]sort-by-file",
284
+ _("Sort output by file location")) do |sort_by_file|
285
+ @order = sort_by_file ? :references : :msgid
286
+ end
243
287
 
244
- config = Config.new
245
- config.output = output
246
- config.defpo = options[0]
247
- config.refpot = options[1]
248
-
249
- if config.defpo.nil?
250
- raise ArgumentError, _("definition po is not given.")
251
- elsif config.refpot.nil?
252
- raise ArgumentError, _("reference pot is not given.")
253
- end
288
+ parser.on("--[no-]sort-by-msgid",
289
+ _("Sort output by msgid")) do |sort_by_msgid|
290
+ @order = sort_by_msgid ? :msgid : :references
291
+ end
254
292
 
255
- config
256
- end
293
+ parser.on("--[no-]location",
294
+ _("Preserve '#: FILENAME:LINE' lines")) do |location|
295
+ @po_format_options[:include_reference_comment] = location
296
+ end
257
297
 
258
- def parse_arguments(*options) #:nodoc:
259
- parser = OptionParser.new
260
- parser.banner = _("Usage: %s def.po ref.pot [-o output.pot]") % $0
261
- #parser.summary_width = 80
262
- parser.separator("")
263
- description = _("Merges two Uniforum style .po files together. " +
264
- "The def.po file is an existing PO file with " +
265
- "translations. The ref.pot file is the last " +
266
- "created PO file with up-to-date source " +
267
- "references. ref.pot is generally created by " +
268
- "rgettext.")
269
- parser.separator(description)
270
- parser.separator("")
271
- parser.separator(_("Specific options:"))
272
-
273
- output = nil
274
-
275
- parser.on("-o", "--output=FILE",
276
- _("write output to specified file")) do |out|
277
- output = out
278
- end
298
+ parser.on("--width=WIDTH", Integer,
299
+ _("Set output page width"),
300
+ "(#{@po_format_options[:max_line_width]})") do |width|
301
+ @po_format_options[:max_line_width] = width
302
+ end
279
303
 
280
- #parser.on("-F", "--fuzzy-matching")
304
+ parser.on("--[no-]wrap",
305
+ _("Break long message lines, longer than the output page width, into several lines"),
306
+ "(#{@po_format_options[:max_line_width] >= 0})") do |wrap|
307
+ if wrap
308
+ max_line_width = POEntry::Formatter::DEFAULT_MAX_LINE_WIDTH
309
+ else
310
+ max_line_width = -1
311
+ end
312
+ @po_format_options[:max_line_width] = max_line_width
313
+ end
281
314
 
282
- parser.on("-h", "--help", _("Display this help and exit")) do
283
- puts(parser.help)
284
- exit(true)
285
- end
315
+ #parser.on("-F", "--fuzzy-matching")
286
316
 
287
- parser.on_tail("--version", _("display version information and exit")) do
288
- puts(VERSION)
289
- exit(true)
290
- end
317
+ parser.on("-h", "--help", _("Display this help and exit")) do
318
+ puts(parser.help)
319
+ exit(true)
320
+ end
291
321
 
292
- parser.parse!(options)
322
+ parser.on_tail("--version",
323
+ _("Display version information and exit")) do
324
+ puts(GetText::VERSION)
325
+ exit(true)
326
+ end
293
327
 
294
- [options, output]
328
+ parser
329
+ end
295
330
  end
296
331
 
297
- def run(*options) #:nodoc:
298
- config = check_command_line_options(*options)
332
+ class << self
333
+ # (see #run)
334
+ #
335
+ # This method is provided just for convenience. It equals to
336
+ # `new.run(*command_line)`.
337
+ def run(*command_line)
338
+ new.run(*command_line)
339
+ end
340
+ end
341
+
342
+ # Merge a po-file inluding translated messages and a new pot-file.
343
+ #
344
+ # @param [Array<String>] command_line
345
+ # command line arguments for rmsgmerge.
346
+ # @return [void]
347
+ def run(*command_line)
348
+ config = Config.new
349
+ config.parse(command_line)
299
350
 
300
351
  parser = POParser.new
301
352
  parser.ignore_fuzzy = false
302
- defpo = parser.parse_file(config.defpo, PO.new)
303
- refpot = parser.parse_file(config.refpot, PO.new)
353
+ definition_po = PO.new
354
+ reference_pot = PO.new
355
+ parser.parse_file(config.definition_po, definition_po)
356
+ parser.parse_file(config.reference_pot, reference_pot)
304
357
 
305
358
  merger = Merger.new
306
- result = merger.merge(defpo, refpot)
359
+ result = merger.merge(definition_po, reference_pot)
360
+ result.order = config.order
307
361
  p result if $DEBUG
308
362
  print result.generate_po if $DEBUG
309
363
 
310
364
  if config.output.is_a?(String)
311
365
  File.open(File.expand_path(config.output), "w+") do |file|
312
- file.write(result.to_s)
366
+ file.write(result.to_s(config.po_format_options))
313
367
  end
314
368
  else
315
- puts(result.to_s)
369
+ puts(result.to_s(config.po_format_options))
316
370
  end
317
371
  end
318
372
  end
@@ -23,33 +23,147 @@ require "gettext/tools"
23
23
  module GetText
24
24
  module Tools
25
25
  class Task
26
+ class Error < StandardError
27
+ end
28
+
29
+ class ValidationError < Error
30
+ attr_reader :reasons
31
+ def initialize(reasons)
32
+ @reasons = reasons
33
+ lines = []
34
+ lines << "invalid configurations:"
35
+ @reasons.each do |variable, reason|
36
+ lines << "#{variable}: #{reason}"
37
+ end
38
+ super(lines.join("\n"))
39
+ end
40
+ end
41
+
26
42
  include GetText
27
43
  include Rake::DSL
28
44
 
29
- attr_accessor :locales, :po_base_directory, :mo_base_directory, :domain
30
- attr_accessor :namespace_prefix, :files
45
+ class << self
46
+ # Define gettext related Rake tasks. Normally, use this method
47
+ # to define tasks because this method is a convenient API.
48
+ #
49
+ # See accessor APIs how to configure this task.
50
+ #
51
+ # See {#define} for what task is defined.
52
+ #
53
+ # @example Recommended usage
54
+ # require "gettext/tools/task"
55
+ # # Recommended usage
56
+ # GetText::Tools::Task.define do |task|
57
+ # task.spec = spec
58
+ # # ...
59
+ # end
60
+ # # Low level API
61
+ # task = GetText::Tools::Task.new
62
+ # task.spec = spec
63
+ # # ...
64
+ # task.define
65
+ #
66
+ # @yield [task] Gives the newely created task to the block.
67
+ # @yieldparam [GetText::Tools::Task] task The task that should be
68
+ # configured.
69
+ # @see {#define}
70
+ # @return [void]
71
+ def define
72
+ task = new
73
+ yield(task)
74
+ task.define
75
+ end
76
+ end
77
+
78
+ # @return [Gem::Specification, nil] Package information associated
79
+ # with the task.
80
+ attr_reader :spec
81
+
82
+ # @return [String, nil] Package name for messages.
83
+ attr_accessor :package_name
84
+
85
+ # @return [String, nil] Package version for messages.
86
+ attr_accessor :package_version
87
+
88
+ # It is a required parameter.
89
+ #
90
+ # @return [Array<String>] Supported locales. It is filled from
91
+ # {#po_base_directory} by default.
92
+ attr_accessor :locales
93
+ attr_accessor :po_base_directory
94
+ # @return [String] Base directory that has generated MOs. MOs
95
+ # are generated into
96
+ # `#{mo_base_directory}/#{locale}/LC_MESSAGES/#{domain}.mo`.
97
+ attr_accessor :mo_base_directory
98
+ # It is a required parameter.
99
+ #
100
+ # @return [Array<String>] Files that have messages.
101
+ attr_accessor :files
102
+ # It is a required parameter.
103
+ #
104
+ # @return [String] Text domain
105
+ attr_accessor :domain
106
+ attr_accessor :namespace_prefix
31
107
  # @return [Array<String>] Command line options for extracting messages
32
108
  # from sources.
33
109
  # @see GetText::Tools::XGetText
34
110
  # @see `rxgettext --help`
35
- attr_reader :xgettext_options
36
- def initialize(spec)
111
+ attr_accessor :xgettext_options
112
+
113
+ # @return [Array<String>] Command line options for merging PO with the
114
+ # latest POT.
115
+ # @see GetText::Tools::MsgMerge
116
+ # @see `rmsgmerge --help`
117
+ attr_accessor :msgmerge_options
118
+
119
+ # @return [Bool]
120
+ # @see #enable_description? For details.
121
+ attr_writer :enable_description
122
+
123
+ # @return [Bool]
124
+ # @see #enable_po? For details.
125
+ attr_writer :enable_po
126
+
127
+ # @param [Gem::Specification, nil] spec Package information associated
128
+ # with the task. Some information are extracted from the spec.
129
+ # @see #spec= What information are extracted from the spec.
130
+ def initialize(spec=nil)
131
+ initialize_variables
132
+ self.spec = spec
133
+ if spec
134
+ yield(self) if block_given?
135
+ warn("Use #{self.class.name}.define instead of #{self.class.name}.new(spec).")
136
+ define
137
+ end
138
+ end
139
+
140
+ # Sets package infromation by Gem::Specification. Here is a list
141
+ # for information extracted from the spec:
142
+ #
143
+ # * {#package_name}
144
+ # * {#package_version}
145
+ # * {#domain}
146
+ # * {#files}
147
+ #
148
+ # @param [Gem::Specification] spec package information for the
149
+ # i18n application.
150
+ def spec=(spec)
37
151
  @spec = spec
38
- @locales = []
39
- @po_base_directory = "po"
40
- @mo_base_directory = "."
41
- @files = target_files
42
- @domain = @spec.name
43
- @namespace_prefix = nil
44
- @xgettext_options = []
45
- yield(self) if block_given?
46
- @locales = detect_locales if @locales.empty?
47
- raise("must set locales: #{inspect}") if @locales.empty?
48
- define
152
+ return if @spec.nil?
153
+
154
+ @package_name = spec.name
155
+ @package_version = spec.version.to_s
156
+ @domain ||= spec.name
157
+ @files += target_files
49
158
  end
50
159
 
51
- private
160
+ # Define tasks from configured parameters.
161
+ #
162
+ # TODO: List defined Rake tasks.
52
163
  def define
164
+ ensure_variables
165
+ validate
166
+
53
167
  define_file_tasks
54
168
  if namespace_prefix
55
169
  namespace_recursive namespace_prefix do
@@ -60,97 +174,202 @@ module GetText
60
174
  end
61
175
  end
62
176
 
177
+ # If it is true, each task has description. Otherwise, all tasks
178
+ # doesn't have description.
179
+ #
180
+ # @return [Bool]
181
+ # @since 3.0.1
182
+ def enable_description?
183
+ @enable_description
184
+ end
185
+
186
+ # If it is true, PO related tasks are defined. Otherwise, they
187
+ # are not defined.
188
+ #
189
+ # This parameter is useful to manage PO written by hand.
190
+ #
191
+ # @return [Bool]
192
+ # @since 3.0.1
193
+ def enable_po?
194
+ @enable_po
195
+ end
196
+
197
+ private
198
+ def initialize_variables
199
+ @spec = nil
200
+ @package_name = nil
201
+ @package_version = nil
202
+ @locales = []
203
+ @po_base_directory = "po"
204
+ @mo_base_directory = "locale"
205
+ @files = []
206
+ @domain = nil
207
+ @namespace_prefix = nil
208
+ @xgettext_options = []
209
+ @msgmerge_options = []
210
+ @enable_description = true
211
+ @enable_po = true
212
+ end
213
+
214
+ def ensure_variables
215
+ @locales = detect_locales if @locales.empty?
216
+ end
217
+
218
+ def validate
219
+ reasons = {}
220
+ if @locales.empty?
221
+ reasons["locales"] = "must set one or more locales"
222
+ end
223
+ if @enable_po and @files.empty?
224
+ reasons["files"] = "must set one or more files"
225
+ end
226
+ if @domain.nil?
227
+ reasons["domain"] = "must set domain"
228
+ end
229
+ raise ValidationError.new(reasons) unless reasons.empty?
230
+ end
231
+
232
+ def desc(*args)
233
+ return unless @enable_description
234
+ super
235
+ end
236
+
63
237
  def define_file_tasks
64
- unless files.empty?
65
- pot_dependencies = files.dup
66
- unless File.exist?(po_base_directory)
67
- directory po_base_directory
68
- pot_dependencies << po_base_directory
238
+ define_pot_file_task
239
+
240
+ locales.each do |locale|
241
+ define_po_file_task(locale)
242
+ define_mo_file_task(locale)
243
+ end
244
+ end
245
+
246
+ def define_pot_file_task
247
+ return unless @enable_po
248
+
249
+ pot_dependencies = files.dup
250
+ unless File.exist?(po_base_directory)
251
+ directory po_base_directory
252
+ pot_dependencies << po_base_directory
253
+ end
254
+ file pot_file => pot_dependencies do
255
+ command_line = [
256
+ "--output", pot_file,
257
+ ]
258
+ if package_name
259
+ command_line.concat(["--package-name", package_name])
69
260
  end
70
- file pot_file => pot_dependencies do
71
- command_line = [
72
- "--package-name", @spec.name,
73
- "--package-version", @spec.version.to_s,
74
- "--output", pot_file,
75
- ]
76
- command_line.concat(@xgettext_options)
77
- command_line.concat(files)
78
- GetText::Tools::XGetText.run(*command_line)
261
+ if package_version
262
+ command_line.concat(["--package-version", package_version])
79
263
  end
264
+ command_line.concat(@xgettext_options)
265
+ command_line.concat(files)
266
+ GetText::Tools::XGetText.run(*command_line)
80
267
  end
268
+ end
81
269
 
82
- locales.each do |locale|
83
- _po_file = po_file(locale)
84
- unless files.empty?
85
- po_dependencies = [pot_file]
86
- _po_directory = po_directory(locale)
87
- unless File.exist?(_po_directory)
88
- directory _po_directory
89
- po_dependencies << _po_directory
90
- end
91
- file _po_file => po_dependencies do
92
- if File.exist?(_po_file)
93
- GetText::Tools::MsgMerge.run(po_file(locale), pot_file,
94
- "--output", _po_file)
95
- else
96
- GetText::Tools::MsgInit.run("--input", pot_file,
97
- "--output", _po_file,
98
- "--locale", locale.to_s)
99
- end
100
- end
101
- end
270
+ def define_po_file_task(locale)
271
+ return unless @enable_po
102
272
 
103
- mo_dependencies = [_po_file]
104
- _mo_directory = mo_directory(locale)
105
- unless File.exist?(_mo_directory)
106
- directory _mo_directory
107
- mo_dependencies << _mo_directory
108
- end
109
- _mo_file = mo_file(locale)
110
- file _mo_file => mo_dependencies do
111
- GetText::Tools::MsgFmt.run(_po_file, "--output", _mo_file)
273
+ _po_file = po_file(locale)
274
+ po_dependencies = [pot_file]
275
+ _po_directory = po_directory(locale)
276
+ unless File.exist?(_po_directory)
277
+ directory _po_directory
278
+ po_dependencies << _po_directory
279
+ end
280
+ file _po_file => po_dependencies do
281
+ if File.exist?(_po_file)
282
+ command_line = [
283
+ "--update",
284
+ ]
285
+ command_line.concat(@msgmerge_options)
286
+ command_line.concat([_po_file, pot_file])
287
+ GetText::Tools::MsgMerge.run(*command_line)
288
+ else
289
+ GetText::Tools::MsgInit.run("--input", pot_file,
290
+ "--output", _po_file,
291
+ "--locale", locale.to_s)
112
292
  end
113
293
  end
114
294
  end
115
295
 
296
+ def define_mo_file_task(locale)
297
+ _po_file = po_file(locale)
298
+ mo_dependencies = [_po_file]
299
+ _mo_directory = mo_directory(locale)
300
+ unless File.exist?(_mo_directory)
301
+ directory _mo_directory
302
+ mo_dependencies << _mo_directory
303
+ end
304
+ _mo_file = mo_file(locale)
305
+ file _mo_file => mo_dependencies do
306
+ GetText::Tools::MsgFmt.run(_po_file, "--output", _mo_file)
307
+ end
308
+ end
309
+
116
310
  def define_named_tasks
117
311
  namespace :gettext do
118
- namespace :pot do
119
- desc "Create #{pot_file}"
120
- task :create => pot_file
312
+ if @enable_po
313
+ define_pot_tasks
314
+ define_po_tasks
121
315
  end
122
316
 
123
- namespace :po do
124
- update_tasks = []
125
- @locales.each do |locale|
126
- namespace locale do
127
- desc "Update #{po_file(locale)}"
128
- task :update => po_file(locale)
129
- update_tasks << (current_scope + ["update"]).join(":")
130
- end
131
- end
317
+ define_mo_tasks
318
+ end
132
319
 
133
- desc "Update *.po"
134
- task :update => update_tasks
135
- end
320
+ desc "Update *.mo"
321
+ task :gettext => (current_scope + ["gettext", "mo", "update"]).join(":")
322
+ end
323
+
324
+ def define_pot_tasks
325
+ namespace :pot do
326
+ desc "Create #{pot_file}"
327
+ task :create => pot_file
328
+ end
329
+ end
136
330
 
137
- namespace :mo do
138
- update_tasks = []
139
- @locales.each do |locale|
140
- namespace locale do
141
- desc "Update #{mo_file(locale)}"
142
- task :update => mo_file(locale)
143
- update_tasks << (current_scope + ["update"]).join(":")
144
- end
331
+ def define_po_tasks
332
+ namespace :po do
333
+ desc "Add a new locale"
334
+ task :add, [:locale] do |_task, args|
335
+ locale = args.locale || ENV["LOCALE"]
336
+ if locale.nil?
337
+ raise "specify locale name by " +
338
+ "'rake #{_task.name}[${LOCALE}]' or " +
339
+ "rake #{_task.name} LOCALE=${LOCALE}'"
145
340
  end
341
+ define_po_file_task(locale)
342
+ Rake::Task[po_file(locale)].invoke
343
+ end
146
344
 
147
- desc "Update *.mo"
148
- task :update => update_tasks
345
+ update_tasks = []
346
+ @locales.each do |locale|
347
+ namespace locale do
348
+ desc "Update #{po_file(locale)}"
349
+ task :update => po_file(locale)
350
+ update_tasks << (current_scope + ["update"]).join(":")
351
+ end
149
352
  end
353
+
354
+ desc "Update *.po"
355
+ task :update => update_tasks
150
356
  end
357
+ end
151
358
 
152
- desc "Update *.mo"
153
- task :gettext => (current_scope + ["gettext", "mo", "update"]).join(":")
359
+ def define_mo_tasks
360
+ namespace :mo do
361
+ update_tasks = []
362
+ @locales.each do |locale|
363
+ namespace locale do
364
+ desc "Update #{mo_file(locale)}"
365
+ task :update => mo_file(locale)
366
+ update_tasks << (current_scope + ["update"]).join(":")
367
+ end
368
+ end
369
+
370
+ desc "Update *.mo"
371
+ task :update => update_tasks
372
+ end
154
373
  end
155
374
 
156
375
  def pot_file
@@ -166,7 +385,7 @@ module GetText
166
385
  end
167
386
 
168
387
  def mo_directory(locale)
169
- File.join(mo_base_directory, "locale", locale.to_s, "LC_MESSAGES")
388
+ File.join(mo_base_directory, locale.to_s, "LC_MESSAGES")
170
389
  end
171
390
 
172
391
  def mo_file(locale)