fair-gettext 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (366) hide show
  1. data/COPYING +56 -0
  2. data/ChangeLog-1 +2016 -0
  3. data/NEWS-1 +414 -0
  4. data/benchmark/1.93.0.txt +8 -0
  5. data/benchmark/2.0.0.txt +8 -0
  6. data/benchmark/2.0.4.txt +11 -0
  7. data/benchmark/2.1.0.txt +11 -0
  8. data/benchmark/benchmark.rb +68 -0
  9. data/benchmark/test.rb +28 -0
  10. data/data/locale/bg/LC_MESSAGES/rgettext.mo +0 -0
  11. data/data/locale/bs/LC_MESSAGES/rgettext.mo +0 -0
  12. data/data/locale/ca/LC_MESSAGES/rgettext.mo +0 -0
  13. data/data/locale/cs/LC_MESSAGES/rgettext.mo +0 -0
  14. data/data/locale/de/LC_MESSAGES/rgettext.mo +0 -0
  15. data/data/locale/el/LC_MESSAGES/rgettext.mo +0 -0
  16. data/data/locale/eo/LC_MESSAGES/rgettext.mo +0 -0
  17. data/data/locale/es/LC_MESSAGES/rgettext.mo +0 -0
  18. data/data/locale/et/LC_MESSAGES/rgettext.mo +0 -0
  19. data/data/locale/fr/LC_MESSAGES/rgettext.mo +0 -0
  20. data/data/locale/hr/LC_MESSAGES/rgettext.mo +0 -0
  21. data/data/locale/hu/LC_MESSAGES/rgettext.mo +0 -0
  22. data/data/locale/it/LC_MESSAGES/rgettext.mo +0 -0
  23. data/data/locale/ja/LC_MESSAGES/rgettext.mo +0 -0
  24. data/data/locale/ko/LC_MESSAGES/rgettext.mo +0 -0
  25. data/data/locale/lv/LC_MESSAGES/rgettext.mo +0 -0
  26. data/data/locale/nb/LC_MESSAGES/rgettext.mo +0 -0
  27. data/data/locale/nl/LC_MESSAGES/rgettext.mo +0 -0
  28. data/data/locale/pt_BR/LC_MESSAGES/rgettext.mo +0 -0
  29. data/data/locale/ru/LC_MESSAGES/rgettext.mo +0 -0
  30. data/data/locale/sr/LC_MESSAGES/rgettext.mo +0 -0
  31. data/data/locale/sv/LC_MESSAGES/rgettext.mo +0 -0
  32. data/data/locale/ua/LC_MESSAGES/rgettext.mo +0 -0
  33. data/data/locale/vi/LC_MESSAGES/rgettext.mo +0 -0
  34. data/data/locale/zh/LC_MESSAGES/rgettext.mo +0 -0
  35. data/data/locale/zh_TW/LC_MESSAGES/rgettext.mo +0 -0
  36. data/gettext-2.0.0.gem +0 -0
  37. data/gettext.gemspec +2 -3
  38. data/lib/gettext/runtime/class_info.rb +67 -0
  39. data/lib/gettext/runtime/locale_path.rb +122 -0
  40. data/lib/gettext/runtime/mofile.rb +330 -0
  41. data/lib/gettext/runtime/textdomain.rb +177 -0
  42. data/lib/gettext/runtime/textdomain_group.rb +24 -0
  43. data/lib/gettext/runtime/textdomain_manager.rb +211 -0
  44. data/lib/gettext/tools.rb +38 -31
  45. data/lib/gettext/tools/parser/erb.rb +52 -0
  46. data/lib/gettext/tools/parser/glade.rb +98 -0
  47. data/lib/gettext/tools/parser/ruby.rb +226 -0
  48. data/lib/gettext/tools/pomessage.rb +197 -0
  49. data/lib/gettext/tools/poparser.rb +356 -0
  50. data/lib/gettext/tools/rgettext.rb +55 -33
  51. data/replace.rb +8 -0
  52. data/samples/cgi/locale/bg/LC_MESSAGES/helloerb1.mo +0 -0
  53. data/samples/cgi/locale/bg/LC_MESSAGES/helloerb2.mo +0 -0
  54. data/samples/cgi/locale/bg/LC_MESSAGES/hellolib.mo +0 -0
  55. data/samples/cgi/locale/bg/LC_MESSAGES/main.mo +0 -0
  56. data/samples/cgi/locale/bs/LC_MESSAGES/helloerb1.mo +0 -0
  57. data/samples/cgi/locale/bs/LC_MESSAGES/helloerb2.mo +0 -0
  58. data/samples/cgi/locale/bs/LC_MESSAGES/hellolib.mo +0 -0
  59. data/samples/cgi/locale/bs/LC_MESSAGES/main.mo +0 -0
  60. data/samples/cgi/locale/ca/LC_MESSAGES/helloerb1.mo +0 -0
  61. data/samples/cgi/locale/ca/LC_MESSAGES/helloerb2.mo +0 -0
  62. data/samples/cgi/locale/ca/LC_MESSAGES/hellolib.mo +0 -0
  63. data/samples/cgi/locale/ca/LC_MESSAGES/main.mo +0 -0
  64. data/samples/cgi/locale/cs/LC_MESSAGES/helloerb1.mo +0 -0
  65. data/samples/cgi/locale/cs/LC_MESSAGES/helloerb2.mo +0 -0
  66. data/samples/cgi/locale/cs/LC_MESSAGES/hellolib.mo +0 -0
  67. data/samples/cgi/locale/cs/LC_MESSAGES/main.mo +0 -0
  68. data/samples/cgi/locale/de/LC_MESSAGES/helloerb1.mo +0 -0
  69. data/samples/cgi/locale/de/LC_MESSAGES/helloerb2.mo +0 -0
  70. data/samples/cgi/locale/de/LC_MESSAGES/hellolib.mo +0 -0
  71. data/samples/cgi/locale/de/LC_MESSAGES/main.mo +0 -0
  72. data/samples/cgi/locale/el/LC_MESSAGES/helloerb1.mo +0 -0
  73. data/samples/cgi/locale/el/LC_MESSAGES/helloerb2.mo +0 -0
  74. data/samples/cgi/locale/el/LC_MESSAGES/hellolib.mo +0 -0
  75. data/samples/cgi/locale/el/LC_MESSAGES/main.mo +0 -0
  76. data/samples/cgi/locale/eo/LC_MESSAGES/helloerb1.mo +0 -0
  77. data/samples/cgi/locale/eo/LC_MESSAGES/helloerb2.mo +0 -0
  78. data/samples/cgi/locale/eo/LC_MESSAGES/hellolib.mo +0 -0
  79. data/samples/cgi/locale/eo/LC_MESSAGES/main.mo +0 -0
  80. data/samples/cgi/locale/es/LC_MESSAGES/helloerb1.mo +0 -0
  81. data/samples/cgi/locale/es/LC_MESSAGES/helloerb2.mo +0 -0
  82. data/samples/cgi/locale/es/LC_MESSAGES/hellolib.mo +0 -0
  83. data/samples/cgi/locale/es/LC_MESSAGES/main.mo +0 -0
  84. data/samples/cgi/locale/fr/LC_MESSAGES/helloerb1.mo +0 -0
  85. data/samples/cgi/locale/fr/LC_MESSAGES/helloerb2.mo +0 -0
  86. data/samples/cgi/locale/fr/LC_MESSAGES/hellolib.mo +0 -0
  87. data/samples/cgi/locale/fr/LC_MESSAGES/main.mo +0 -0
  88. data/samples/cgi/locale/hr/LC_MESSAGES/helloerb1.mo +0 -0
  89. data/samples/cgi/locale/hr/LC_MESSAGES/helloerb2.mo +0 -0
  90. data/samples/cgi/locale/hr/LC_MESSAGES/hellolib.mo +0 -0
  91. data/samples/cgi/locale/hr/LC_MESSAGES/main.mo +0 -0
  92. data/samples/cgi/locale/hu/LC_MESSAGES/helloerb1.mo +0 -0
  93. data/samples/cgi/locale/hu/LC_MESSAGES/helloerb2.mo +0 -0
  94. data/samples/cgi/locale/hu/LC_MESSAGES/hellolib.mo +0 -0
  95. data/samples/cgi/locale/hu/LC_MESSAGES/main.mo +0 -0
  96. data/samples/cgi/locale/it/LC_MESSAGES/helloerb1.mo +0 -0
  97. data/samples/cgi/locale/it/LC_MESSAGES/helloerb2.mo +0 -0
  98. data/samples/cgi/locale/it/LC_MESSAGES/hellolib.mo +0 -0
  99. data/samples/cgi/locale/it/LC_MESSAGES/main.mo +0 -0
  100. data/samples/cgi/locale/ja/LC_MESSAGES/helloerb1.mo +0 -0
  101. data/samples/cgi/locale/ja/LC_MESSAGES/helloerb2.mo +0 -0
  102. data/samples/cgi/locale/ja/LC_MESSAGES/hellolib.mo +0 -0
  103. data/samples/cgi/locale/ja/LC_MESSAGES/main.mo +0 -0
  104. data/samples/cgi/locale/ko/LC_MESSAGES/helloerb1.mo +0 -0
  105. data/samples/cgi/locale/ko/LC_MESSAGES/helloerb2.mo +0 -0
  106. data/samples/cgi/locale/ko/LC_MESSAGES/hellolib.mo +0 -0
  107. data/samples/cgi/locale/ko/LC_MESSAGES/main.mo +0 -0
  108. data/samples/cgi/locale/lv/LC_MESSAGES/helloerb1.mo +0 -0
  109. data/samples/cgi/locale/lv/LC_MESSAGES/helloerb2.mo +0 -0
  110. data/samples/cgi/locale/lv/LC_MESSAGES/hellolib.mo +0 -0
  111. data/samples/cgi/locale/lv/LC_MESSAGES/main.mo +0 -0
  112. data/samples/cgi/locale/nb/LC_MESSAGES/helloerb1.mo +0 -0
  113. data/samples/cgi/locale/nb/LC_MESSAGES/helloerb2.mo +0 -0
  114. data/samples/cgi/locale/nb/LC_MESSAGES/hellolib.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/hellolib.mo +0 -0
  119. data/samples/cgi/locale/nl/LC_MESSAGES/main.mo +0 -0
  120. data/samples/cgi/locale/pt_BR/LC_MESSAGES/helloerb1.mo +0 -0
  121. data/samples/cgi/locale/pt_BR/LC_MESSAGES/helloerb2.mo +0 -0
  122. data/samples/cgi/locale/pt_BR/LC_MESSAGES/hellolib.mo +0 -0
  123. data/samples/cgi/locale/pt_BR/LC_MESSAGES/main.mo +0 -0
  124. data/samples/cgi/locale/ru/LC_MESSAGES/helloerb1.mo +0 -0
  125. data/samples/cgi/locale/ru/LC_MESSAGES/helloerb2.mo +0 -0
  126. data/samples/cgi/locale/ru/LC_MESSAGES/hellolib.mo +0 -0
  127. data/samples/cgi/locale/ru/LC_MESSAGES/main.mo +0 -0
  128. data/samples/cgi/locale/sr/LC_MESSAGES/helloerb1.mo +0 -0
  129. data/samples/cgi/locale/sr/LC_MESSAGES/helloerb2.mo +0 -0
  130. data/samples/cgi/locale/sr/LC_MESSAGES/hellolib.mo +0 -0
  131. data/samples/cgi/locale/sr/LC_MESSAGES/main.mo +0 -0
  132. data/samples/cgi/locale/ua/LC_MESSAGES/helloerb1.mo +0 -0
  133. data/samples/cgi/locale/ua/LC_MESSAGES/helloerb2.mo +0 -0
  134. data/samples/cgi/locale/ua/LC_MESSAGES/hellolib.mo +0 -0
  135. data/samples/cgi/locale/ua/LC_MESSAGES/main.mo +0 -0
  136. data/samples/cgi/locale/vi/LC_MESSAGES/helloerb1.mo +0 -0
  137. data/samples/cgi/locale/vi/LC_MESSAGES/helloerb2.mo +0 -0
  138. data/samples/cgi/locale/vi/LC_MESSAGES/hellolib.mo +0 -0
  139. data/samples/cgi/locale/vi/LC_MESSAGES/main.mo +0 -0
  140. data/samples/cgi/locale/zh/LC_MESSAGES/helloerb1.mo +0 -0
  141. data/samples/cgi/locale/zh/LC_MESSAGES/helloerb2.mo +0 -0
  142. data/samples/cgi/locale/zh/LC_MESSAGES/hellolib.mo +0 -0
  143. data/samples/cgi/locale/zh/LC_MESSAGES/main.mo +0 -0
  144. data/samples/cgi/locale/zh_TW/LC_MESSAGES/helloerb1.mo +0 -0
  145. data/samples/cgi/locale/zh_TW/LC_MESSAGES/helloerb2.mo +0 -0
  146. data/samples/cgi/locale/zh_TW/LC_MESSAGES/hellolib.mo +0 -0
  147. data/samples/cgi/locale/zh_TW/LC_MESSAGES/main.mo +0 -0
  148. data/samples/cgi/po/bg/#main.po# +84 -0
  149. data/samples/locale/bg/LC_MESSAGES/hello.mo +0 -0
  150. data/samples/locale/bg/LC_MESSAGES/hello2.mo +0 -0
  151. data/samples/locale/bg/LC_MESSAGES/hello_glade2.mo +0 -0
  152. data/samples/locale/bg/LC_MESSAGES/hello_gtk.mo +0 -0
  153. data/samples/locale/bg/LC_MESSAGES/hello_noop.mo +0 -0
  154. data/samples/locale/bg/LC_MESSAGES/hello_plural.mo +0 -0
  155. data/samples/locale/bg/LC_MESSAGES/hello_tk.mo +0 -0
  156. data/samples/locale/bs/LC_MESSAGES/hello.mo +0 -0
  157. data/samples/locale/bs/LC_MESSAGES/hello2.mo +0 -0
  158. data/samples/locale/bs/LC_MESSAGES/hello_glade2.mo +0 -0
  159. data/samples/locale/bs/LC_MESSAGES/hello_gtk.mo +0 -0
  160. data/samples/locale/bs/LC_MESSAGES/hello_noop.mo +0 -0
  161. data/samples/locale/bs/LC_MESSAGES/hello_plural.mo +0 -0
  162. data/samples/locale/bs/LC_MESSAGES/hello_tk.mo +0 -0
  163. data/samples/locale/ca/LC_MESSAGES/hello.mo +0 -0
  164. data/samples/locale/ca/LC_MESSAGES/hello2.mo +0 -0
  165. data/samples/locale/ca/LC_MESSAGES/hello_glade2.mo +0 -0
  166. data/samples/locale/ca/LC_MESSAGES/hello_gtk.mo +0 -0
  167. data/samples/locale/ca/LC_MESSAGES/hello_noop.mo +0 -0
  168. data/samples/locale/ca/LC_MESSAGES/hello_plural.mo +0 -0
  169. data/samples/locale/ca/LC_MESSAGES/hello_tk.mo +0 -0
  170. data/samples/locale/cs/LC_MESSAGES/hello.mo +0 -0
  171. data/samples/locale/cs/LC_MESSAGES/hello2.mo +0 -0
  172. data/samples/locale/cs/LC_MESSAGES/hello_glade2.mo +0 -0
  173. data/samples/locale/cs/LC_MESSAGES/hello_gtk.mo +0 -0
  174. data/samples/locale/cs/LC_MESSAGES/hello_noop.mo +0 -0
  175. data/samples/locale/cs/LC_MESSAGES/hello_plural.mo +0 -0
  176. data/samples/locale/cs/LC_MESSAGES/hello_tk.mo +0 -0
  177. data/samples/locale/de/LC_MESSAGES/hello.mo +0 -0
  178. data/samples/locale/de/LC_MESSAGES/hello2.mo +0 -0
  179. data/samples/locale/de/LC_MESSAGES/hello_glade2.mo +0 -0
  180. data/samples/locale/de/LC_MESSAGES/hello_gtk.mo +0 -0
  181. data/samples/locale/de/LC_MESSAGES/hello_noop.mo +0 -0
  182. data/samples/locale/de/LC_MESSAGES/hello_plural.mo +0 -0
  183. data/samples/locale/de/LC_MESSAGES/hello_tk.mo +0 -0
  184. data/samples/locale/el/LC_MESSAGES/hello.mo +0 -0
  185. data/samples/locale/el/LC_MESSAGES/hello2.mo +0 -0
  186. data/samples/locale/el/LC_MESSAGES/hello_glade2.mo +0 -0
  187. data/samples/locale/el/LC_MESSAGES/hello_gtk.mo +0 -0
  188. data/samples/locale/el/LC_MESSAGES/hello_noop.mo +0 -0
  189. data/samples/locale/el/LC_MESSAGES/hello_plural.mo +0 -0
  190. data/samples/locale/el/LC_MESSAGES/hello_tk.mo +0 -0
  191. data/samples/locale/eo/LC_MESSAGES/hello.mo +0 -0
  192. data/samples/locale/eo/LC_MESSAGES/hello2.mo +0 -0
  193. data/samples/locale/eo/LC_MESSAGES/hello_glade2.mo +0 -0
  194. data/samples/locale/eo/LC_MESSAGES/hello_gtk.mo +0 -0
  195. data/samples/locale/eo/LC_MESSAGES/hello_noop.mo +0 -0
  196. data/samples/locale/eo/LC_MESSAGES/hello_plural.mo +0 -0
  197. data/samples/locale/eo/LC_MESSAGES/hello_tk.mo +0 -0
  198. data/samples/locale/es/LC_MESSAGES/hello.mo +0 -0
  199. data/samples/locale/es/LC_MESSAGES/hello2.mo +0 -0
  200. data/samples/locale/es/LC_MESSAGES/hello_glade2.mo +0 -0
  201. data/samples/locale/es/LC_MESSAGES/hello_gtk.mo +0 -0
  202. data/samples/locale/es/LC_MESSAGES/hello_noop.mo +0 -0
  203. data/samples/locale/es/LC_MESSAGES/hello_plural.mo +0 -0
  204. data/samples/locale/es/LC_MESSAGES/hello_tk.mo +0 -0
  205. data/samples/locale/fr/LC_MESSAGES/hello.mo +0 -0
  206. data/samples/locale/fr/LC_MESSAGES/hello2.mo +0 -0
  207. data/samples/locale/fr/LC_MESSAGES/hello_glade2.mo +0 -0
  208. data/samples/locale/fr/LC_MESSAGES/hello_gtk.mo +0 -0
  209. data/samples/locale/fr/LC_MESSAGES/hello_noop.mo +0 -0
  210. data/samples/locale/fr/LC_MESSAGES/hello_plural.mo +0 -0
  211. data/samples/locale/fr/LC_MESSAGES/hello_tk.mo +0 -0
  212. data/samples/locale/hr/LC_MESSAGES/hello.mo +0 -0
  213. data/samples/locale/hr/LC_MESSAGES/hello2.mo +0 -0
  214. data/samples/locale/hr/LC_MESSAGES/hello_glade2.mo +0 -0
  215. data/samples/locale/hr/LC_MESSAGES/hello_gtk.mo +0 -0
  216. data/samples/locale/hr/LC_MESSAGES/hello_noop.mo +0 -0
  217. data/samples/locale/hr/LC_MESSAGES/hello_plural.mo +0 -0
  218. data/samples/locale/hr/LC_MESSAGES/hello_tk.mo +0 -0
  219. data/samples/locale/hu/LC_MESSAGES/hello.mo +0 -0
  220. data/samples/locale/hu/LC_MESSAGES/hello2.mo +0 -0
  221. data/samples/locale/hu/LC_MESSAGES/hello_glade2.mo +0 -0
  222. data/samples/locale/hu/LC_MESSAGES/hello_gtk.mo +0 -0
  223. data/samples/locale/hu/LC_MESSAGES/hello_noop.mo +0 -0
  224. data/samples/locale/hu/LC_MESSAGES/hello_plural.mo +0 -0
  225. data/samples/locale/hu/LC_MESSAGES/hello_tk.mo +0 -0
  226. data/samples/locale/it/LC_MESSAGES/hello.mo +0 -0
  227. data/samples/locale/it/LC_MESSAGES/hello2.mo +0 -0
  228. data/samples/locale/it/LC_MESSAGES/hello_glade2.mo +0 -0
  229. data/samples/locale/it/LC_MESSAGES/hello_gtk.mo +0 -0
  230. data/samples/locale/it/LC_MESSAGES/hello_noop.mo +0 -0
  231. data/samples/locale/it/LC_MESSAGES/hello_plural.mo +0 -0
  232. data/samples/locale/it/LC_MESSAGES/hello_tk.mo +0 -0
  233. data/samples/locale/ja/LC_MESSAGES/hello.mo +0 -0
  234. data/samples/locale/ja/LC_MESSAGES/hello2.mo +0 -0
  235. data/samples/locale/ja/LC_MESSAGES/hello_glade2.mo +0 -0
  236. data/samples/locale/ja/LC_MESSAGES/hello_gtk.mo +0 -0
  237. data/samples/locale/ja/LC_MESSAGES/hello_noop.mo +0 -0
  238. data/samples/locale/ja/LC_MESSAGES/hello_plural.mo +0 -0
  239. data/samples/locale/ja/LC_MESSAGES/hello_tk.mo +0 -0
  240. data/samples/locale/ko/LC_MESSAGES/hello.mo +0 -0
  241. data/samples/locale/ko/LC_MESSAGES/hello2.mo +0 -0
  242. data/samples/locale/ko/LC_MESSAGES/hello_glade2.mo +0 -0
  243. data/samples/locale/ko/LC_MESSAGES/hello_gtk.mo +0 -0
  244. data/samples/locale/ko/LC_MESSAGES/hello_noop.mo +0 -0
  245. data/samples/locale/ko/LC_MESSAGES/hello_plural.mo +0 -0
  246. data/samples/locale/ko/LC_MESSAGES/hello_tk.mo +0 -0
  247. data/samples/locale/lv/LC_MESSAGES/hello.mo +0 -0
  248. data/samples/locale/lv/LC_MESSAGES/hello2.mo +0 -0
  249. data/samples/locale/lv/LC_MESSAGES/hello_glade2.mo +0 -0
  250. data/samples/locale/lv/LC_MESSAGES/hello_gtk.mo +0 -0
  251. data/samples/locale/lv/LC_MESSAGES/hello_noop.mo +0 -0
  252. data/samples/locale/lv/LC_MESSAGES/hello_plural.mo +0 -0
  253. data/samples/locale/lv/LC_MESSAGES/hello_tk.mo +0 -0
  254. data/samples/locale/nb/LC_MESSAGES/hello.mo +0 -0
  255. data/samples/locale/nb/LC_MESSAGES/hello2.mo +0 -0
  256. data/samples/locale/nb/LC_MESSAGES/hello_glade2.mo +0 -0
  257. data/samples/locale/nb/LC_MESSAGES/hello_gtk.mo +0 -0
  258. data/samples/locale/nb/LC_MESSAGES/hello_noop.mo +0 -0
  259. data/samples/locale/nb/LC_MESSAGES/hello_plural.mo +0 -0
  260. data/samples/locale/nb/LC_MESSAGES/hello_tk.mo +0 -0
  261. data/samples/locale/nl/LC_MESSAGES/hello.mo +0 -0
  262. data/samples/locale/nl/LC_MESSAGES/hello2.mo +0 -0
  263. data/samples/locale/nl/LC_MESSAGES/hello_glade2.mo +0 -0
  264. data/samples/locale/nl/LC_MESSAGES/hello_gtk.mo +0 -0
  265. data/samples/locale/nl/LC_MESSAGES/hello_noop.mo +0 -0
  266. data/samples/locale/nl/LC_MESSAGES/hello_plural.mo +0 -0
  267. data/samples/locale/nl/LC_MESSAGES/hello_tk.mo +0 -0
  268. data/samples/locale/pt_BR/LC_MESSAGES/hello.mo +0 -0
  269. data/samples/locale/pt_BR/LC_MESSAGES/hello2.mo +0 -0
  270. data/samples/locale/pt_BR/LC_MESSAGES/hello_glade2.mo +0 -0
  271. data/samples/locale/pt_BR/LC_MESSAGES/hello_gtk.mo +0 -0
  272. data/samples/locale/pt_BR/LC_MESSAGES/hello_noop.mo +0 -0
  273. data/samples/locale/pt_BR/LC_MESSAGES/hello_plural.mo +0 -0
  274. data/samples/locale/pt_BR/LC_MESSAGES/hello_tk.mo +0 -0
  275. data/samples/locale/ru/LC_MESSAGES/hello.mo +0 -0
  276. data/samples/locale/ru/LC_MESSAGES/hello2.mo +0 -0
  277. data/samples/locale/ru/LC_MESSAGES/hello_glade2.mo +0 -0
  278. data/samples/locale/ru/LC_MESSAGES/hello_gtk.mo +0 -0
  279. data/samples/locale/ru/LC_MESSAGES/hello_noop.mo +0 -0
  280. data/samples/locale/ru/LC_MESSAGES/hello_plural.mo +0 -0
  281. data/samples/locale/ru/LC_MESSAGES/hello_tk.mo +0 -0
  282. data/samples/locale/sr/LC_MESSAGES/hello.mo +0 -0
  283. data/samples/locale/sr/LC_MESSAGES/hello2.mo +0 -0
  284. data/samples/locale/sr/LC_MESSAGES/hello_glade2.mo +0 -0
  285. data/samples/locale/sr/LC_MESSAGES/hello_gtk.mo +0 -0
  286. data/samples/locale/sr/LC_MESSAGES/hello_noop.mo +0 -0
  287. data/samples/locale/sr/LC_MESSAGES/hello_plural.mo +0 -0
  288. data/samples/locale/sr/LC_MESSAGES/hello_tk.mo +0 -0
  289. data/samples/locale/sv/LC_MESSAGES/hello.mo +0 -0
  290. data/samples/locale/sv/LC_MESSAGES/hello2.mo +0 -0
  291. data/samples/locale/sv/LC_MESSAGES/hello_glade2.mo +0 -0
  292. data/samples/locale/sv/LC_MESSAGES/hello_gtk.mo +0 -0
  293. data/samples/locale/sv/LC_MESSAGES/hello_noop.mo +0 -0
  294. data/samples/locale/sv/LC_MESSAGES/hello_plural.mo +0 -0
  295. data/samples/locale/sv/LC_MESSAGES/hello_tk.mo +0 -0
  296. data/samples/locale/ua/LC_MESSAGES/hello.mo +0 -0
  297. data/samples/locale/ua/LC_MESSAGES/hello2.mo +0 -0
  298. data/samples/locale/ua/LC_MESSAGES/hello_glade2.mo +0 -0
  299. data/samples/locale/ua/LC_MESSAGES/hello_gtk.mo +0 -0
  300. data/samples/locale/ua/LC_MESSAGES/hello_noop.mo +0 -0
  301. data/samples/locale/ua/LC_MESSAGES/hello_plural.mo +0 -0
  302. data/samples/locale/ua/LC_MESSAGES/hello_tk.mo +0 -0
  303. data/samples/locale/vi/LC_MESSAGES/hello.mo +0 -0
  304. data/samples/locale/vi/LC_MESSAGES/hello2.mo +0 -0
  305. data/samples/locale/vi/LC_MESSAGES/hello_glade2.mo +0 -0
  306. data/samples/locale/vi/LC_MESSAGES/hello_gtk.mo +0 -0
  307. data/samples/locale/vi/LC_MESSAGES/hello_noop.mo +0 -0
  308. data/samples/locale/vi/LC_MESSAGES/hello_plural.mo +0 -0
  309. data/samples/locale/vi/LC_MESSAGES/hello_tk.mo +0 -0
  310. data/samples/locale/zh/LC_MESSAGES/hello.mo +0 -0
  311. data/samples/locale/zh/LC_MESSAGES/hello2.mo +0 -0
  312. data/samples/locale/zh/LC_MESSAGES/hello_glade2.mo +0 -0
  313. data/samples/locale/zh/LC_MESSAGES/hello_gtk.mo +0 -0
  314. data/samples/locale/zh/LC_MESSAGES/hello_noop.mo +0 -0
  315. data/samples/locale/zh/LC_MESSAGES/hello_plural.mo +0 -0
  316. data/samples/locale/zh/LC_MESSAGES/hello_tk.mo +0 -0
  317. data/samples/locale/zh_TW/LC_MESSAGES/hello.mo +0 -0
  318. data/samples/locale/zh_TW/LC_MESSAGES/hello2.mo +0 -0
  319. data/samples/locale/zh_TW/LC_MESSAGES/hello_glade2.mo +0 -0
  320. data/samples/locale/zh_TW/LC_MESSAGES/hello_gtk.mo +0 -0
  321. data/samples/locale/zh_TW/LC_MESSAGES/hello_noop.mo +0 -0
  322. data/samples/locale/zh_TW/LC_MESSAGES/hello_plural.mo +0 -0
  323. data/samples/locale/zh_TW/LC_MESSAGES/hello_tk.mo +0 -0
  324. data/test.rb +33 -0
  325. data/test/locale/cr/LC_MESSAGES/plural.mo +0 -0
  326. data/test/locale/da/LC_MESSAGES/plural.mo +0 -0
  327. data/test/locale/da/LC_MESSAGES/plural_error.mo +0 -0
  328. data/test/locale/fr/LC_MESSAGES/plural.mo +0 -0
  329. data/test/locale/fr/LC_MESSAGES/plural_error.mo +0 -0
  330. data/test/locale/fr/LC_MESSAGES/test1.mo +0 -0
  331. data/test/locale/fr/LC_MESSAGES/test2.mo +0 -0
  332. data/test/locale/ir/LC_MESSAGES/plural.mo +0 -0
  333. data/test/locale/ja/LC_MESSAGES/npgettext.mo +0 -0
  334. data/test/locale/ja/LC_MESSAGES/nsgettext.mo +0 -0
  335. data/test/locale/ja/LC_MESSAGES/pgettext.mo +0 -0
  336. data/test/locale/ja/LC_MESSAGES/plural.mo +0 -0
  337. data/test/locale/ja/LC_MESSAGES/plural_error.mo +0 -0
  338. data/test/locale/ja/LC_MESSAGES/rubyparser.mo +0 -0
  339. data/test/locale/ja/LC_MESSAGES/sgettext.mo +0 -0
  340. data/test/locale/ja/LC_MESSAGES/test1.mo +0 -0
  341. data/test/locale/ja/LC_MESSAGES/test2.mo +0 -0
  342. data/test/locale/ja/LC_MESSAGES/test3.mo +0 -0
  343. data/test/locale/la/LC_MESSAGES/plural.mo +0 -0
  344. data/test/locale/la/LC_MESSAGES/plural_error.mo +0 -0
  345. data/test/locale/li/LC_MESSAGES/plural.mo +0 -0
  346. data/test/locale/li/LC_MESSAGES/plural_error.mo +0 -0
  347. data/test/locale/po/LC_MESSAGES/plural.mo +0 -0
  348. data/test/locale/sl/LC_MESSAGES/plural.mo +0 -0
  349. data/test/po/ja/test3.po +19 -0
  350. data/test/po/li/plural_error.po +27 -0
  351. data/test/test_locale_path.rb +50 -0
  352. data/test/test_po_generation.rb +20 -0
  353. data/test/test_pomessage.rb +99 -0
  354. data/test/test_textdomain_bind.rb +37 -0
  355. data/test/test_thread.rb +41 -0
  356. data/test/tools/files/app.pot +0 -0
  357. data/test/tools/files/de/app.po +0 -0
  358. data/test/tools/files/en/app.po +0 -0
  359. data/test/tools/files/en/test.po +21 -0
  360. data/test/tools/files/simple_1.po +2 -0
  361. data/test/tools/files/simple_2.po +2 -0
  362. data/test/tools/files/simple_translation.rb +1 -0
  363. data/test/tools/files/version.po +7 -0
  364. data/test/tools/test.pot +21 -0
  365. data/test/tools/test_tools.rb +61 -0
  366. metadata +710 -348
@@ -0,0 +1,177 @@
1
+ =begin
2
+ textdomain.rb - GetText::Textdomain
3
+
4
+ Copyright (C) 2001-2009 Masao Mutoh
5
+ Copyright (C) 2001-2003 Masahiro Sakai
6
+
7
+ Masahiro Sakai <s01397ms@sfc.keio.ac.jp>
8
+ Masao Mutoh <mutomasa at gmail.com>
9
+
10
+ You may redistribute it and/or modify it under the same
11
+ license terms as Ruby or LGPL.
12
+ =end
13
+
14
+ require 'gettext/core_ext/string'
15
+ require 'gettext/runtime/mofile'
16
+ require 'gettext/runtime/locale_path'
17
+
18
+ module GetText
19
+ # GetText::TextDomain class manages mo-files of a textdomain.
20
+ #
21
+ # Usually, you don't need to use this class directly.
22
+ #
23
+ # Notice: This class is unstable. APIs will be changed.
24
+ class TextDomain
25
+
26
+ attr_reader :output_charset
27
+ attr_reader :mofiles
28
+ attr_reader :name
29
+
30
+ @@cached = ! $DEBUG
31
+ # Cache the mo-file or not.
32
+ # Default is true. If $DEBUG is set then false.
33
+ def self.cached?
34
+ @@cached
35
+ end
36
+
37
+ # Set to cache the mo-file or not.
38
+ # * val: true if cached, otherwise false.
39
+ def self.cached=(val)
40
+ @@cached = val
41
+ end
42
+
43
+ # Add default locale path. Usually you should use GetText.add_default_locale_path instead.
44
+ # * path: a new locale path. (e.g.) "/usr/share/locale/%{lang}/LC_MESSAGES/%{name}.mo"
45
+ # ('locale' => "ja_JP", 'name' => "textdomain")
46
+ # * Returns: the new DEFAULT_LOCALE_PATHS
47
+ def self.add_default_locale_path(path)
48
+ warn "Deprecated. Use GetText::LocalePath.add_default_rule instead."
49
+ LocalePath.add_default_rule(path)
50
+ end
51
+
52
+ # Creates a new GetText::TextDomain.
53
+ # * name: the textdomain name.
54
+ # * topdir: the locale path ("%{topdir}/%{lang}/LC_MESSAGES/%{name}.mo") or nil.
55
+ # * output_charset: output charset.
56
+ # * Returns: a newly created GetText::TextDomain object.
57
+ def initialize(name, topdir = nil, output_charset = nil)
58
+ @name, @output_charset = name, output_charset
59
+
60
+ @locale_path = LocalePath.new(@name, topdir)
61
+ @mofiles = {}
62
+ end
63
+
64
+ # Translates the translated string.
65
+ # * lang: Locale::Tag::Simple's subclass.
66
+ # * msgid: the original message.
67
+ # * Returns: the translated string or nil.
68
+ def translate_singluar_message(lang, msgid)
69
+ return "" if msgid == "" or msgid.nil?
70
+
71
+ lang_key = lang.to_s
72
+
73
+ mofile = nil
74
+ if self.class.cached?
75
+ mofile = @mofiles[lang_key]
76
+ end
77
+ unless mofile
78
+ mofile = load_mo(lang)
79
+ end
80
+
81
+ if (! mofile) or (mofile ==:empty)
82
+ return nil
83
+ end
84
+
85
+ msgstr = mofile[msgid]
86
+ if msgstr and (msgstr.size > 0)
87
+ msgstr
88
+ elsif msgid.include?("\000")
89
+ # Check "aaa\000bbb" and show warning but return the singluar part.
90
+ ret = nil
91
+ msgid_single = msgid.split("\000")[0]
92
+ mofile.each{|key, val|
93
+ if key =~ /^#{Regexp.quote(msgid_single)}\000/
94
+ # Usually, this is not caused to make po-files from rgettext.
95
+ warn %Q[Warning: n_("#{msgid_single}", "#{msgid.split("\000")[1]}") and n_("#{key.gsub(/\000/, '", "')}") are duplicated.]
96
+ ret = val
97
+ break
98
+ end
99
+ }
100
+ ret
101
+ else
102
+ ret = nil
103
+ mofile.each{|key, val|
104
+ if key =~ /^#{Regexp.quote(msgid)}\000/
105
+ ret = val.split("\000")[0]
106
+ break
107
+ end
108
+ }
109
+ ret
110
+ end
111
+ end
112
+
113
+ DEFAULT_PLURAL_CALC = Proc.new{|n| n != 1}
114
+ DEFAULT_SINGLE_CALC = Proc.new{|n| 0}
115
+
116
+ # Translates the translated string.
117
+ # * lang: Locale::Tag::Simple's subclass.
118
+ # * msgid: the original message.
119
+ # * msgid_plural: the original message(plural).
120
+ # * Returns: the translated string as an Array ([[msgstr1, msgstr2, ...], cond]) or nil.
121
+ def translate_plural_message(lang, msgid, msgid_plural) #:nodoc:
122
+ key = msgid + "\000" + msgid_plural
123
+ msg = translate_singluar_message(lang, key)
124
+ ret = nil
125
+ if ! msg
126
+ ret = nil
127
+ elsif msg.include?("\000")
128
+ # [[msgstr[0], msgstr[1], msgstr[2],...], cond]
129
+ mofile = @mofiles[lang.to_posix.to_s]
130
+ cond = (mofile and mofile != :empty) ? mofile.plural_as_proc : DEFAULT_PLURAL_CALC
131
+ ret = [msg.split("\000"), cond]
132
+ else
133
+ ret = [[msg], DEFAULT_SINGLE_CALC]
134
+ end
135
+ ret
136
+ end
137
+
138
+ # Clear cached mofiles.
139
+ def clear
140
+ @mofiles = {}
141
+ end
142
+
143
+ # Set output_charset.
144
+ # * charset: output charset.
145
+ def output_charset=(charset)
146
+ @output_charset = charset
147
+ clear
148
+ end
149
+
150
+ private
151
+ # Load a mo-file from the file.
152
+ # lang is the subclass of Locale::Tag::Simple.
153
+ def load_mo(lang)
154
+ lang = lang.to_posix unless lang.kind_of? Locale::Tag::Posix
155
+ lang_key = lang.to_s
156
+
157
+ mofile = @mofiles[lang_key]
158
+ if mofile
159
+ if mofile == :empty
160
+ return :empty
161
+ elsif ! self.class.cached?
162
+ mofile.update!
163
+ end
164
+ return mofile
165
+ end
166
+
167
+ path = @locale_path.current_path(lang)
168
+
169
+ if path
170
+ charset = @output_charset || lang.charset || Locale.charset || "UTF-8"
171
+ @mofiles[lang_key] = MOFile.open(path, charset)
172
+ else
173
+ @mofiles[lang_key] = :empty
174
+ end
175
+ end
176
+ end
177
+ end
@@ -0,0 +1,24 @@
1
+ =begin
2
+ gettext/textdomain_group - GetText::TextDomainGroup class
3
+
4
+ Copyright (C) 2009 Masao Mutoh
5
+
6
+ You may redistribute it and/or modify it under the same
7
+ license terms as Ruby or LGPL.
8
+
9
+ =end
10
+
11
+ module GetText
12
+
13
+ class TextDomainGroup
14
+ attr_reader :textdomains
15
+
16
+ def initialize
17
+ @textdomains = []
18
+ end
19
+
20
+ def add(textdomain)
21
+ @textdomains.unshift(textdomain) unless @textdomains.include? textdomain
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,211 @@
1
+ =begin
2
+ gettext/textdomain_manager - GetText::TextDomainManager class
3
+
4
+ Copyright (C) 2009 Masao Mutoh
5
+
6
+ You may redistribute it and/or modify it under the same
7
+ license terms as Ruby or LGPL.
8
+
9
+ =end
10
+
11
+ require 'gettext/runtime/class_info'
12
+ require 'gettext/runtime/textdomain'
13
+ require 'gettext/runtime/textdomain_group'
14
+
15
+ module GetText
16
+
17
+ module TextDomainManager
18
+
19
+ @@textdomain_pool = {}
20
+ @@textdomain_group_pool = {}
21
+
22
+ @@output_charset = nil
23
+ @@gettext_classes = []
24
+
25
+ @@singular_message_cache = {}
26
+ @@plural_message_cache = {}
27
+ @@cached = ! $DEBUG
28
+
29
+ extend self
30
+
31
+ # Find textdomain by name
32
+ def textdomain_pool(domainname)
33
+ @@textdomain_pool[domainname]
34
+ end
35
+
36
+ # Set the value whether cache messages or not.
37
+ # true to cache messages, otherwise false.
38
+ #
39
+ # Default is true. If $DEBUG is false, messages are not checked even if
40
+ # this value is true.
41
+ def cached=(val)
42
+ @@cached = val
43
+ TextDomain.cached = val
44
+ end
45
+
46
+ # Return the cached value.
47
+ def cached?
48
+ TextDomain.cached?
49
+ end
50
+
51
+ # Gets the output charset.
52
+ def output_charset
53
+ @@output_charset
54
+ end
55
+
56
+ # Sets the output charset.The program can have a output charset.
57
+ def output_charset=(charset)
58
+ @@output_charset = charset
59
+ @@textdomain_pool.each do |key, textdomain|
60
+ textdomain.output_charset = charset
61
+ end
62
+ end
63
+
64
+ # bind textdomain to the class.
65
+ def bind_to(klass, domainname, options = {})
66
+ warn "Bind the domain '#{domainname}' to '#{klass}'. " if $DEBUG
67
+
68
+ charset = options[:output_charset] || self.output_charset
69
+ textdomain = create_or_find_textdomain(domainname,options[:path],charset)
70
+ target_klass = ClassInfo.normalize_class(klass)
71
+ create_or_find_textdomain_group(target_klass).add(textdomain)
72
+ @@gettext_classes << target_klass unless @@gettext_classes.include? target_klass
73
+
74
+ textdomain
75
+ end
76
+
77
+ def each_textdomains(klass) #:nodoc:
78
+ lang = Locale.candidates[0]
79
+ ClassInfo.related_classes(klass, @@gettext_classes).each do |target|
80
+ msg = nil
81
+ if group = @@textdomain_group_pool[target]
82
+ group.textdomains.each do |textdomain|
83
+ yield textdomain, lang
84
+ end
85
+ end
86
+ end
87
+ end
88
+
89
+ # Translates msgid, but if there are no localized text,
90
+ # it returns a last part of msgid separeted "div" or whole of the msgid with no "div".
91
+ #
92
+ # * msgid: the message id.
93
+ # * div: separator or nil.
94
+ # * Returns: the localized text by msgid. If there are no localized text,
95
+ # it returns a last part of msgid separeted "div".
96
+ def translate_singluar_message(klass, msgid, div = nil)
97
+ klass = ClassInfo.normalize_class(klass)
98
+ key = [Locale.current, klass, msgid, div].hash
99
+ msg = @@singular_message_cache[key]
100
+ return msg if msg and @@cached
101
+ # Find messages from related classes.
102
+ each_textdomains(klass) do |textdomain, lang|
103
+ msg = textdomain.translate_singluar_message(lang, msgid)
104
+ break if msg
105
+ end
106
+
107
+ # If not found, return msgid.
108
+ msg ||= msgid
109
+ if div and msg == msgid
110
+ if index = msg.rindex(div)
111
+ msg = msg[(index + 1)..-1]
112
+ end
113
+ end
114
+ @@singular_message_cache[key] = msg
115
+ end
116
+
117
+ # This function is similar to the get_singluar_message function
118
+ # as it finds the message catalogs in the same way.
119
+ # But it takes two extra arguments for plural form.
120
+ # The msgid parameter must contain the singular form of the string to be converted.
121
+ # It is also used as the key for the search in the catalog.
122
+ # The msgid_plural parameter is the plural form.
123
+ # The parameter n is used to determine the plural form.
124
+ # If no message catalog is found msgid1 is returned if n == 1, otherwise msgid2.
125
+ # And if msgid includes "div", it returns a last part of msgid separeted "div".
126
+ #
127
+ # * msgid: the singular form with "div". (e.g. "Special|An apple", "An apple")
128
+ # * msgid_plural: the plural form. (e.g. "%{num} Apples")
129
+ # * n: a number used to determine the plural form.
130
+ # * div: the separator. Default is "|".
131
+ # * Returns: the localized text which key is msgid_plural if n is plural(follow plural-rule) or msgid.
132
+ # "plural-rule" is defined in po-file.
133
+ #
134
+ # or
135
+ #
136
+ # * [msgid, msgid_plural] : msgid and msgid_plural an Array
137
+ # * n: a number used to determine the plural form.
138
+ # * div: the separator. Default is "|".
139
+ def translate_plural_message(klass, arg1, arg2, arg3 = "|", arg4 = "|")
140
+ klass = ClassInfo.normalize_class(klass)
141
+ # parse arguments
142
+ if arg1.kind_of?(Array)
143
+ msgid = arg1[0]
144
+ msgid_plural = arg1[1]
145
+ n = arg2
146
+ if arg3 and arg3.kind_of? Numeric
147
+ raise ArgumentError, _("3rd parmeter is wrong: value = %{number}") % {:number => arg3}
148
+ end
149
+ div = arg3
150
+ else
151
+ msgid = arg1
152
+ msgid_plural = arg2
153
+ n = arg3
154
+ div = arg4
155
+ end
156
+
157
+ key = [Locale.current, klass, msgid, msgid_plural, div].hash
158
+ msgs = @@plural_message_cache[key]
159
+ unless (msgs and @@cached)
160
+ # Find messages from related classes.
161
+ msgs = nil
162
+ each_textdomains(klass) do |textdomain, lang|
163
+ msgs = textdomain.translate_plural_message(lang, msgid, msgid_plural)
164
+ break if msgs
165
+ end
166
+
167
+ msgs = [[msgid, msgid_plural], TextDomain::DEFAULT_PLURAL_CALC] unless msgs
168
+
169
+ msgstrs = msgs[0]
170
+ if div and msgstrs[0] == msgid and index = msgstrs[0].rindex(div)
171
+ msgstrs[0] = msgstrs[0][(index + 1)..-1]
172
+ end
173
+ @@plural_message_cache[key] = msgs
174
+ end
175
+
176
+ # Return the singular or plural message.
177
+ msgstrs = msgs[0]
178
+ plural = msgs[1].call(n)
179
+ return msgstrs[plural] if plural.kind_of?(Numeric)
180
+ return plural ? msgstrs[1] : msgstrs[0]
181
+ end
182
+
183
+ # for testing.
184
+ def clear_all_textdomains
185
+ @@textdomain_pool = {}
186
+ @@textdomain_group_pool = {}
187
+ @@gettext_classes = []
188
+ clear_caches
189
+ end
190
+
191
+ # for testing.
192
+ def clear_caches
193
+ @@singular_message_cache = {}
194
+ @@plural_message_cache = {}
195
+ end
196
+
197
+ def create_or_find_textdomain_group(klass) #:nodoc:
198
+ group = @@textdomain_group_pool[klass]
199
+ return group if group
200
+
201
+ @@textdomain_group_pool[klass] = TextDomainGroup.new
202
+ end
203
+
204
+ def create_or_find_textdomain(name, path, charset)#:nodoc:
205
+ textdomain = @@textdomain_pool[name]
206
+ return textdomain if textdomain
207
+
208
+ @@textdomain_pool[name] = TextDomain.new(name, path, charset)
209
+ end
210
+ end
211
+ end
data/lib/gettext/tools.rb CHANGED
@@ -1,29 +1,29 @@
1
1
  =begin
2
2
  tools.rb - Utility functions
3
-
3
+
4
4
  Copyright (C) 2005-2008 Masao Mutoh
5
-
5
+
6
6
  You may redistribute it and/or modify it under the same
7
7
  license terms as Ruby or LGPL.
8
8
  =end
9
-
9
+
10
10
  require 'rbconfig'
11
11
  if /mingw|mswin|mswin32/ =~ RUBY_PLATFORM
12
12
  ENV['PATH'] = %w(bin lib).collect{|dir|
13
13
  "#{Config::CONFIG["prefix"]}\\lib\\GTK\\#{dir};"
14
14
  }.join('') + ENV['PATH']
15
15
  end
16
-
16
+
17
17
  require 'gettext/tools/rgettext'
18
18
  require 'gettext/tools/rmsgfmt'
19
19
  require 'gettext/runtime/mofile'
20
20
  require 'fileutils'
21
-
21
+
22
22
  module GetText
23
23
  bindtextdomain "rgettext"
24
-
24
+
25
25
  BOM_UTF8 = [0xef, 0xbb, 0xbf].pack("c3")
26
-
26
+
27
27
  # Currently, GNU msgmerge doesn't accept BOM.
28
28
  # This mesthod remove the UTF-8 BOM from the po-file.
29
29
  def remove_bom(path) #:nodoc:
@@ -33,7 +33,7 @@ module GetText
33
33
  File.open(path, "w") {|f| f.write(data)}
34
34
  end
35
35
  end
36
-
36
+
37
37
  # Merges two Uniforum style .po files together.
38
38
  #
39
39
  # *Note* This function requires "msgmerge" tool included in GNU GetText. So you need to install GNU GetText.
@@ -58,7 +58,7 @@ module GetText
58
58
  verbose = options.delete(:verbose)
59
59
  puts "msgmerge called" if verbose
60
60
  $stderr.print defpo + " "
61
-
61
+
62
62
  content = merge_po_files(defpo,refpo,options.delete(:msgmerge),verbose)
63
63
 
64
64
  if content.empty?
@@ -76,7 +76,7 @@ module GetText
76
76
 
77
77
  self
78
78
  end
79
-
79
+
80
80
  # Creates mo-files using #{po_root}/#{lang}/*.po an put them to
81
81
  # #{targetdir}/#{targetdir_rule}/.
82
82
  #
@@ -88,7 +88,7 @@ module GetText
88
88
  # * mo_path_rule: the target directory for each mo-files.
89
89
  def create_mofiles(options = {})
90
90
  options = {:po_root => "./po"}.merge(options)
91
-
91
+
92
92
  Dir.glob(File.join(options[:po_root], "*/*.po")) do |po_file|
93
93
  mo_file = mo_file_from_po_file(po_file,options)
94
94
  $stderr.print %Q[#{po_file} -> #{mo_file} ... ] if options[:verbose]
@@ -97,8 +97,8 @@ module GetText
97
97
  $stderr.puts "Done." if options[:verbose]
98
98
  end
99
99
  end
100
-
101
-
100
+
101
+
102
102
  # At first, this creates the #{po_root}/#{domainname}.pot file using GetText.rgettext.
103
103
  # In the second step, this updates(merges) the #{po_root}/#{domainname}.pot and all of the
104
104
  # #{po_root}/#{lang}/#{domainname}.po files under "po_root" using "msgmerge".
@@ -120,60 +120,67 @@ module GetText
120
120
  # Example: GetText.update_pofiles("myapp", Dir.glob("lib/*.rb"), "myapp 1.0.0", :verbose => true)
121
121
  def update_pofiles(textdomain, files, app_version, options = {})
122
122
  puts options.inspect if options[:verbose]
123
-
124
- #write found messages to tmp.pot
123
+
124
+ #write found messages to tmp.pot and private_tmp.pot
125
125
  temp_pot = "tmp.pot"
126
- rgettext(files, temp_pot)
127
-
128
- #merge tmp.pot and existing pot
126
+ private_temp_pot = "private_tmp.pot"
127
+ rgettext(files, temp_pot, private_temp_pot)
128
+
129
+ #merge tmp.pot and private_tmp.pot with existing pot
129
130
  po_root = options.delete(:po_root) || "po"
130
131
  FileUtils.mkdir_p(po_root)
131
132
  msgmerge("#{po_root}/#{textdomain}.pot", temp_pot, app_version, options.dup)
132
-
133
+ msgmerge("#{po_root}/private_#{textdomain}.pot", private_temp_pot, app_version, options.dup)
134
+
133
135
  #update local po-files
134
136
  only_one_language = options.delete(:lang)
135
137
  if only_one_language
136
138
  msgmerge("#{po_root}/#{only_one_language}/#{textdomain}.po", temp_pot, app_version, options.dup)
139
+ msgmerge("#{po_root}/#{only_one_language}/private_#{textdomain}.po", private_temp_pot, app_version, options.dup)
137
140
  else
138
141
  Dir.glob("#{po_root}/*/#{textdomain}.po") do |po_file|
139
142
  msgmerge(po_file, temp_pot, app_version, options.dup)
140
143
  end
144
+ Dir.glob("#{po_root}/*/private_#{textdomain}.po") do |po_file|
145
+ msgmerge(po_file, private_temp_pot, app_version, options.dup)
146
+ end
141
147
  end
142
-
148
+
143
149
  File.delete(temp_pot)
150
+ File.delete(private_temp_pot)
144
151
  end
145
-
152
+
146
153
  private
147
-
154
+
148
155
  # Merge 2 po files, using msgmerge
149
156
  def merge_po_files(po_a,po_b,msgmerge_options=[],verbose=false)
150
157
  return File.read(po_b) unless FileTest.exist? po_a
151
-
158
+
152
159
  cmd = ENV["MSGMERGE_PATH"] || "msgmerge"
153
160
  ensure_command_exists(cmd)
154
-
161
+
155
162
  remove_bom(po_a)
156
-
163
+
157
164
  cmd_params = array_to_cli_options(msgmerge_options)
158
165
  to_run = "#{cmd} #{cmd_params} #{po_a} #{po_b}"
159
166
  puts "\nrunning #{to_run}" if verbose
160
167
  `#{to_run}`
161
168
  end
162
-
169
+
163
170
  # convert an array of String/Symbol to cli options
164
171
  def array_to_cli_options(array)
165
172
  [*array].map do |o|
166
173
  o.kind_of?(Symbol) ? "--#{o}".gsub('_','-') : o.to_s
167
174
  end.join(' ')
168
175
  end
169
-
176
+
170
177
  def ensure_command_exists(cmd)
171
178
  `#{cmd} --help`
172
179
  unless $? && $?.success?
173
180
  raise _("`%{cmd}' can not be found. \nInstall GNU Gettext then set PATH or MSGMERGE_PATH correctly.") % {:cmd => cmd}
174
181
  end
175
182
  end
176
-
183
+
177
184
  # where lies the mo file for a given po_file
178
185
  # generare directory unless it exists
179
186
  def mo_file_from_po_file(po_file,options)
@@ -183,13 +190,13 @@ module GetText
183
190
  }.merge(options)
184
191
 
185
192
  lang, textdomain = %r[/([^/]+?)/(.*)\.po].match(po_file[options[:po_root].size..-1]).to_a[1,2]
186
-
193
+
187
194
  mo_dir_rule = File.join(options[:mo_root], options[:mo_path_rule])
188
195
  mo_dir = mo_dir_rule % {:lang => lang}
189
196
  File.join(mo_dir, "#{textdomain}.mo")
190
197
  end
191
198
  end
192
-
199
+
193
200
  if __FILE__ == $0
194
201
  GetText.update_pofiles("foo", ARGV, "foo 1.1.0")
195
- end
202
+ end