gettext 3.2.9 → 3.4.9

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 (237) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +276 -198
  3. data/Rakefile +7 -4
  4. data/doc/text/news.md +451 -0
  5. data/gettext.gemspec +10 -7
  6. data/lib/gettext/locale_path.rb +17 -9
  7. data/lib/gettext/mo.rb +12 -19
  8. data/lib/gettext/po.rb +4 -4
  9. data/lib/gettext/po_entry.rb +47 -27
  10. data/lib/gettext/po_parser.rb +65 -59
  11. data/lib/gettext/text_domain.rb +1 -1
  12. data/lib/gettext/text_domain_manager.rb +6 -5
  13. data/lib/gettext/tools/msgcat.rb +9 -2
  14. data/lib/gettext/tools/msginit.rb +226 -54
  15. data/lib/gettext/tools/msgmerge.rb +24 -6
  16. data/lib/gettext/tools/parser/erb.rb +9 -1
  17. data/lib/gettext/tools/parser/erubi.rb +88 -0
  18. data/lib/gettext/tools/parser/glade.rb +38 -40
  19. data/lib/gettext/tools/parser/gtk_builder_ui_definitions.rb +129 -0
  20. data/lib/gettext/tools/parser/ruby.rb +288 -221
  21. data/lib/gettext/tools/task.rb +4 -5
  22. data/lib/gettext/tools/xgettext.rb +21 -10
  23. data/lib/gettext/version.rb +3 -3
  24. data/locale/bg/LC_MESSAGES/gettext.mo +0 -0
  25. data/locale/bs/LC_MESSAGES/gettext.mo +0 -0
  26. data/locale/ca/LC_MESSAGES/gettext.mo +0 -0
  27. data/locale/cs/LC_MESSAGES/gettext.mo +0 -0
  28. data/locale/de/LC_MESSAGES/gettext.mo +0 -0
  29. data/locale/el/LC_MESSAGES/gettext.mo +0 -0
  30. data/locale/eo/LC_MESSAGES/gettext.mo +0 -0
  31. data/locale/es/LC_MESSAGES/gettext.mo +0 -0
  32. data/locale/et/LC_MESSAGES/gettext.mo +0 -0
  33. data/locale/fr/LC_MESSAGES/gettext.mo +0 -0
  34. data/locale/hr/LC_MESSAGES/gettext.mo +0 -0
  35. data/locale/hu/LC_MESSAGES/gettext.mo +0 -0
  36. data/locale/it/LC_MESSAGES/gettext.mo +0 -0
  37. data/locale/ja/LC_MESSAGES/gettext.mo +0 -0
  38. data/locale/ko/LC_MESSAGES/gettext.mo +0 -0
  39. data/locale/lv/LC_MESSAGES/gettext.mo +0 -0
  40. data/locale/nb/LC_MESSAGES/gettext.mo +0 -0
  41. data/locale/nl/LC_MESSAGES/gettext.mo +0 -0
  42. data/locale/pt_BR/LC_MESSAGES/gettext.mo +0 -0
  43. data/locale/ru/LC_MESSAGES/gettext.mo +0 -0
  44. data/locale/sr/LC_MESSAGES/gettext.mo +0 -0
  45. data/locale/uk/LC_MESSAGES/gettext.mo +0 -0
  46. data/locale/vi/LC_MESSAGES/gettext.mo +0 -0
  47. data/locale/zh/LC_MESSAGES/gettext.mo +0 -0
  48. data/locale/zh_TW/LC_MESSAGES/gettext.mo +0 -0
  49. data/po/bg/gettext.edit.po +81 -572
  50. data/po/bg/gettext.po +7 -409
  51. data/po/bs/gettext.edit.po +81 -572
  52. data/po/bs/gettext.po +7 -409
  53. data/po/ca/gettext.edit.po +81 -572
  54. data/po/ca/gettext.po +7 -409
  55. data/po/cs/gettext.edit.po +81 -572
  56. data/po/cs/gettext.po +7 -409
  57. data/po/de/gettext.edit.po +81 -572
  58. data/po/de/gettext.po +7 -409
  59. data/po/el/gettext.edit.po +81 -572
  60. data/po/el/gettext.po +7 -409
  61. data/po/eo/gettext.edit.po +81 -572
  62. data/po/eo/gettext.po +7 -409
  63. data/po/es/gettext.edit.po +81 -572
  64. data/po/es/gettext.po +7 -409
  65. data/po/et/gettext.edit.po +81 -572
  66. data/po/et/gettext.po +7 -409
  67. data/po/fr/gettext.edit.po +81 -572
  68. data/po/fr/gettext.po +7 -409
  69. data/po/gettext.pot +93 -645
  70. data/po/hr/gettext.edit.po +81 -572
  71. data/po/hr/gettext.po +7 -409
  72. data/po/hu/gettext.edit.po +81 -572
  73. data/po/hu/gettext.po +7 -409
  74. data/po/it/gettext.edit.po +81 -572
  75. data/po/it/gettext.po +7 -409
  76. data/po/ja/gettext.edit.po +83 -574
  77. data/po/ja/gettext.po +9 -411
  78. data/po/ko/gettext.edit.po +81 -572
  79. data/po/ko/gettext.po +7 -409
  80. data/po/lv/gettext.edit.po +81 -572
  81. data/po/lv/gettext.po +7 -409
  82. data/po/nb/gettext.edit.po +81 -572
  83. data/po/nb/gettext.po +7 -409
  84. data/po/nl/gettext.edit.po +81 -572
  85. data/po/nl/gettext.po +7 -409
  86. data/po/pt_BR/gettext.edit.po +81 -572
  87. data/po/pt_BR/gettext.po +7 -409
  88. data/po/ru/gettext.edit.po +81 -572
  89. data/po/ru/gettext.po +7 -409
  90. data/po/sr/gettext.edit.po +81 -572
  91. data/po/sr/gettext.po +7 -409
  92. data/po/sv/gettext.edit.po +81 -572
  93. data/po/sv/gettext.po +7 -409
  94. data/po/uk/gettext.edit.po +81 -572
  95. data/po/uk/gettext.po +7 -409
  96. data/po/vi/gettext.edit.po +81 -572
  97. data/po/vi/gettext.po +7 -409
  98. data/po/zh/gettext.edit.po +81 -572
  99. data/po/zh/gettext.po +7 -409
  100. data/po/zh_TW/gettext.edit.po +81 -572
  101. data/po/zh_TW/gettext.po +7 -409
  102. data/samples/cgi/po/helloerb1.pot +3 -3
  103. data/samples/cgi/po/helloerb2.pot +3 -3
  104. data/samples/cgi/po/hellolib.pot +3 -3
  105. data/samples/cgi/po/main.pot +3 -3
  106. data/samples/po/bg/hello_gtk_builder.edit.po +15 -0
  107. data/samples/po/bg/hello_gtk_builder.po +12 -0
  108. data/samples/po/bs/hello_gtk_builder.edit.po +15 -0
  109. data/samples/po/bs/hello_gtk_builder.po +12 -0
  110. data/samples/po/ca/hello_gtk_builder.edit.po +15 -0
  111. data/samples/po/ca/hello_gtk_builder.po +12 -0
  112. data/samples/po/cs/hello_gtk_builder.edit.po +15 -0
  113. data/samples/po/cs/hello_gtk_builder.po +12 -0
  114. data/samples/po/de/hello_gtk_builder.edit.po +15 -0
  115. data/samples/po/de/hello_gtk_builder.po +12 -0
  116. data/samples/po/el/hello_gtk_builder.edit.po +15 -0
  117. data/samples/po/el/hello_gtk_builder.po +12 -0
  118. data/samples/po/eo/hello_gtk_builder.edit.po +15 -0
  119. data/samples/po/eo/hello_gtk_builder.po +12 -0
  120. data/samples/po/es/hello_gtk_builder.edit.po +15 -0
  121. data/samples/po/es/hello_gtk_builder.po +12 -0
  122. data/samples/po/fr/hello_gtk_builder.edit.po +15 -0
  123. data/samples/po/fr/hello_gtk_builder.po +12 -0
  124. data/samples/po/hello.pot +3 -3
  125. data/samples/po/hello2.pot +4 -4
  126. data/samples/po/hello_glade2.pot +8 -5
  127. data/samples/po/hello_gtk2.pot +4 -4
  128. data/samples/po/hello_gtk_builder.pot +18 -4
  129. data/samples/po/hello_noop.pot +4 -4
  130. data/samples/po/hello_plural.pot +4 -4
  131. data/samples/po/hello_tk.pot +4 -4
  132. data/samples/po/hr/hello_gtk_builder.edit.po +15 -0
  133. data/samples/po/hr/hello_gtk_builder.po +12 -0
  134. data/samples/po/hu/hello_gtk_builder.edit.po +15 -0
  135. data/samples/po/hu/hello_gtk_builder.po +12 -0
  136. data/samples/po/it/hello_gtk_builder.edit.po +15 -0
  137. data/samples/po/it/hello_gtk_builder.po +12 -0
  138. data/samples/po/ja/hello_gtk_builder.edit.po +15 -0
  139. data/samples/po/ja/hello_gtk_builder.po +12 -0
  140. data/samples/po/ko/hello_gtk_builder.edit.po +15 -0
  141. data/samples/po/ko/hello_gtk_builder.po +12 -0
  142. data/samples/po/lv/hello_gtk_builder.edit.po +15 -0
  143. data/samples/po/lv/hello_gtk_builder.po +12 -0
  144. data/samples/po/nb/hello_gtk_builder.edit.po +15 -0
  145. data/samples/po/nb/hello_gtk_builder.po +12 -0
  146. data/samples/po/nl/hello_gtk_builder.edit.po +15 -0
  147. data/samples/po/nl/hello_gtk_builder.po +12 -0
  148. data/samples/po/pt_BR/hello_gtk_builder.edit.po +15 -0
  149. data/samples/po/pt_BR/hello_gtk_builder.po +12 -0
  150. data/samples/po/ru/hello_gtk_builder.edit.po +15 -0
  151. data/samples/po/ru/hello_gtk_builder.po +12 -0
  152. data/samples/po/sr/hello_gtk_builder.edit.po +15 -0
  153. data/samples/po/sr/hello_gtk_builder.po +12 -0
  154. data/samples/po/sv/hello_gtk_builder.edit.po +15 -0
  155. data/samples/po/sv/hello_gtk_builder.po +12 -0
  156. data/samples/po/uk/hello_gtk_builder.edit.po +15 -0
  157. data/samples/po/uk/hello_gtk_builder.po +12 -0
  158. data/samples/po/vi/hello_gtk_builder.edit.po +15 -0
  159. data/samples/po/vi/hello_gtk_builder.po +12 -0
  160. data/samples/po/zh/hello_gtk_builder.edit.po +15 -0
  161. data/samples/po/zh/hello_gtk_builder.po +12 -0
  162. data/samples/po/zh_TW/hello_gtk_builder.edit.po +15 -0
  163. data/samples/po/zh_TW/hello_gtk_builder.po +12 -0
  164. data/src/po_parser.ry +48 -42
  165. data/test/fixtures/_/backtick.rb +30 -0
  166. data/test/fixtures/_/block_parameter.rb +2 -2
  167. data/test/fixtures/_/double_quote_in_double_quote.rb +2 -2
  168. data/test/fixtures/_/double_quote_in_single_quote.rb +2 -2
  169. data/test/fixtures/_/literal_concatenation_with_continuation_line.rb +2 -2
  170. data/test/fixtures/_/middle_new_line.rb +2 -2
  171. data/test/fixtures/_/multiple_lines_literal.rb +2 -2
  172. data/test/fixtures/_/multiple_messages_in_same_line.rb +2 -2
  173. data/test/fixtures/_/multiple_same_messages.rb +2 -2
  174. data/test/fixtures/_/one_line.rb +2 -2
  175. data/test/fixtures/_/one_new_line.rb +2 -2
  176. data/test/fixtures/_/percent_strings.rb +55 -0
  177. data/test/fixtures/_/pipe.rb +32 -0
  178. data/test/{gettext-test-utils.rb → fixtures/_/quoted_symbol.rb} +13 -23
  179. data/test/fixtures/_.rb +10 -1
  180. data/test/fixtures/erb/case.rhtml +16 -0
  181. data/test/fixtures/erb/minus.rhtml +12 -0
  182. data/test/fixtures/erb/non_ascii.rhtml +1 -0
  183. data/test/fixtures/glade/3.glade +63 -0
  184. data/test/fixtures/gtk_builder_ui_definitions.ui +68 -0
  185. data/test/fixtures/multi_text_domain.rb +12 -12
  186. data/test/fixtures/np_.rb +1 -1
  187. data/test/fixtures/ns_/custom.rb +2 -2
  188. data/test/fixtures/ns_.rb +1 -1
  189. data/test/fixtures/p_.rb +1 -1
  190. data/test/fixtures/ruby/percent_lower_i.rb +1 -0
  191. data/test/fixtures/ruby/percent_lower_w.rb +1 -0
  192. data/test/fixtures/ruby/percent_upper_i.rb +1 -0
  193. data/test/fixtures/ruby/percent_upper_w.rb +1 -0
  194. data/test/fixtures/s_/custom.rb +2 -2
  195. data/test/fixtures/s_.rb +1 -1
  196. data/test/fixtures/simple.rb +5 -1
  197. data/test/fixtures/upper_nn_.rb +77 -0
  198. data/test/helper.rb +99 -0
  199. data/test/locale/fr/LC_MESSAGES/plural_error.mo +0 -0
  200. data/test/locale/fr/LC_MESSAGES/test1.mo +0 -0
  201. data/test/locale/fr_BE/LC_MESSAGES/test1.mo +0 -0
  202. data/test/locale/fr_BE_Foo/LC_MESSAGES/test1.mo +0 -0
  203. data/test/locale/ja/LC_MESSAGES/_.mo +0 -0
  204. data/test/po/_.pot +28 -4
  205. data/test/po/backslash.pot +6 -4
  206. data/test/po/fr/plural_error.po +7 -0
  207. data/test/po/fr/test1.po +7 -0
  208. data/test/po/fr_BE/test1.po +24 -0
  209. data/test/po/fr_BE_Foo/test1.po +20 -0
  210. data/test/po/hello.pot +3 -3
  211. data/test/po/ja/_.edit.po +27 -3
  212. data/test/po/ja/_.po +20 -2
  213. data/test/po/ja/hello.edit.po +0 -1
  214. data/test/po/non_ascii.pot +4 -4
  215. data/test/po/np_.pot +8 -5
  216. data/test/po/ns_.pot +6 -4
  217. data/test/po/p_.pot +3 -3
  218. data/test/po/s_.pot +6 -4
  219. data/test/po/untranslated.pot +4 -4
  220. data/test/run-test.rb +2 -3
  221. data/test/test_class_info.rb +8 -9
  222. data/test/test_gettext.rb +30 -1
  223. data/test/test_locale_path.rb +12 -4
  224. data/test/test_parser.rb +113 -25
  225. data/test/test_po_entry.rb +21 -17
  226. data/test/test_po_parser.rb +49 -4
  227. data/test/test_string.rb +9 -5
  228. data/test/tools/parser/test_glade.rb +91 -0
  229. data/test/tools/parser/test_gtk_builder_ui_definitions.rb +63 -0
  230. data/test/tools/parser/test_ruby.rb +76 -39
  231. data/test/tools/test_msgcat.rb +21 -1
  232. data/test/tools/test_msginit.rb +82 -3
  233. data/test/tools/test_msgmerge.rb +81 -6
  234. data/test/tools/test_xgettext.rb +106 -5
  235. metadata +82 -34
  236. data/lib/gettext/tools/parser/haml.rb +0 -61
  237. /data/test/fixtures/{gladeparser.glade → glade/2.glade} +0 -0
@@ -17,3 +17,15 @@ msgstr ""
17
17
  "Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4"
18
18
  " && (n%100<10 || n%100>=20) ? 1 : 2;\n"
19
19
  "\n"
20
+
21
+ msgid "window1"
22
+ msgstr ""
23
+
24
+ msgid ""
25
+ "first line\n"
26
+ "second line\n"
27
+ "third line"
28
+ msgstr ""
29
+
30
+ msgid "<Hello world>"
31
+ msgstr ""
@@ -17,3 +17,18 @@ msgstr ""
17
17
  "Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4"
18
18
  " && (n%100<10 || n%100>=20) ? 1 : 2;\n"
19
19
  "\n"
20
+
21
+ #: ../hello_gtk_builder.ui:7
22
+ msgid "window1"
23
+ msgstr ""
24
+
25
+ #: ../hello_gtk_builder.ui:16
26
+ msgid ""
27
+ "first line\n"
28
+ "second line\n"
29
+ "third line"
30
+ msgstr ""
31
+
32
+ #: ../hello_gtk_builder.ui:28
33
+ msgid "<Hello world>"
34
+ msgstr ""
@@ -17,3 +17,15 @@ msgstr ""
17
17
  "Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4"
18
18
  " && (n%100<10 || n%100>=20) ? 1 : 2;\n"
19
19
  "\n"
20
+
21
+ msgid "window1"
22
+ msgstr ""
23
+
24
+ msgid ""
25
+ "first line\n"
26
+ "second line\n"
27
+ "third line"
28
+ msgstr ""
29
+
30
+ msgid "<Hello world>"
31
+ msgstr ""
@@ -16,3 +16,18 @@ msgstr ""
16
16
  "Content-Transfer-Encoding: 8bit\n"
17
17
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
18
18
  "\n"
19
+
20
+ #: ../hello_gtk_builder.ui:7
21
+ msgid "window1"
22
+ msgstr ""
23
+
24
+ #: ../hello_gtk_builder.ui:16
25
+ msgid ""
26
+ "first line\n"
27
+ "second line\n"
28
+ "third line"
29
+ msgstr ""
30
+
31
+ #: ../hello_gtk_builder.ui:28
32
+ msgid "<Hello world>"
33
+ msgstr ""
@@ -16,3 +16,15 @@ msgstr ""
16
16
  "Content-Transfer-Encoding: 8bit\n"
17
17
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
18
18
  "\n"
19
+
20
+ msgid "window1"
21
+ msgstr ""
22
+
23
+ msgid ""
24
+ "first line\n"
25
+ "second line\n"
26
+ "third line"
27
+ msgstr ""
28
+
29
+ msgid "<Hello world>"
30
+ msgstr ""
@@ -17,3 +17,18 @@ msgstr ""
17
17
  "Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4"
18
18
  " && (n%100<10 || n%100>=20) ? 1 : 2;\n"
19
19
  "\n"
20
+
21
+ #: ../hello_gtk_builder.ui:7
22
+ msgid "window1"
23
+ msgstr ""
24
+
25
+ #: ../hello_gtk_builder.ui:16
26
+ msgid ""
27
+ "first line\n"
28
+ "second line\n"
29
+ "third line"
30
+ msgstr ""
31
+
32
+ #: ../hello_gtk_builder.ui:28
33
+ msgid "<Hello world>"
34
+ msgstr ""
@@ -17,3 +17,15 @@ msgstr ""
17
17
  "Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4"
18
18
  " && (n%100<10 || n%100>=20) ? 1 : 2;\n"
19
19
  "\n"
20
+
21
+ msgid "window1"
22
+ msgstr ""
23
+
24
+ msgid ""
25
+ "first line\n"
26
+ "second line\n"
27
+ "third line"
28
+ msgstr ""
29
+
30
+ msgid "<Hello world>"
31
+ msgstr ""
@@ -16,3 +16,18 @@ msgstr ""
16
16
  "Content-Transfer-Encoding: 8bit\n"
17
17
  "Plural-Forms: nplurals=1; plural=0;\n"
18
18
  "\n"
19
+
20
+ #: ../hello_gtk_builder.ui:7
21
+ msgid "window1"
22
+ msgstr ""
23
+
24
+ #: ../hello_gtk_builder.ui:16
25
+ msgid ""
26
+ "first line\n"
27
+ "second line\n"
28
+ "third line"
29
+ msgstr ""
30
+
31
+ #: ../hello_gtk_builder.ui:28
32
+ msgid "<Hello world>"
33
+ msgstr ""
@@ -16,3 +16,15 @@ msgstr ""
16
16
  "Content-Transfer-Encoding: 8bit\n"
17
17
  "Plural-Forms: nplurals=1; plural=0;\n"
18
18
  "\n"
19
+
20
+ msgid "window1"
21
+ msgstr ""
22
+
23
+ msgid ""
24
+ "first line\n"
25
+ "second line\n"
26
+ "third line"
27
+ msgstr ""
28
+
29
+ msgid "<Hello world>"
30
+ msgstr ""
@@ -16,3 +16,18 @@ msgstr ""
16
16
  "Content-Transfer-Encoding: 8bit\n"
17
17
  "Plural-Forms: nplurals=1; plural=0;\n"
18
18
  "\n"
19
+
20
+ #: ../hello_gtk_builder.ui:7
21
+ msgid "window1"
22
+ msgstr ""
23
+
24
+ #: ../hello_gtk_builder.ui:16
25
+ msgid ""
26
+ "first line\n"
27
+ "second line\n"
28
+ "third line"
29
+ msgstr ""
30
+
31
+ #: ../hello_gtk_builder.ui:28
32
+ msgid "<Hello world>"
33
+ msgstr ""
@@ -16,3 +16,15 @@ msgstr ""
16
16
  "Content-Transfer-Encoding: 8bit\n"
17
17
  "Plural-Forms: nplurals=1; plural=0;\n"
18
18
  "\n"
19
+
20
+ msgid "window1"
21
+ msgstr ""
22
+
23
+ msgid ""
24
+ "first line\n"
25
+ "second line\n"
26
+ "third line"
27
+ msgstr ""
28
+
29
+ msgid "<Hello world>"
30
+ msgstr ""
@@ -16,3 +16,18 @@ msgstr ""
16
16
  "Content-Transfer-Encoding: 8bit\n"
17
17
  "Plural-Forms: nplurals=1; plural=0;\n"
18
18
  "\n"
19
+
20
+ #: ../hello_gtk_builder.ui:7
21
+ msgid "window1"
22
+ msgstr ""
23
+
24
+ #: ../hello_gtk_builder.ui:16
25
+ msgid ""
26
+ "first line\n"
27
+ "second line\n"
28
+ "third line"
29
+ msgstr ""
30
+
31
+ #: ../hello_gtk_builder.ui:28
32
+ msgid "<Hello world>"
33
+ msgstr ""
@@ -16,3 +16,15 @@ msgstr ""
16
16
  "Content-Transfer-Encoding: 8bit\n"
17
17
  "Plural-Forms: nplurals=1; plural=0;\n"
18
18
  "\n"
19
+
20
+ msgid "window1"
21
+ msgstr ""
22
+
23
+ msgid ""
24
+ "first line\n"
25
+ "second line\n"
26
+ "third line"
27
+ msgstr ""
28
+
29
+ msgid "<Hello world>"
30
+ msgstr ""
data/src/po_parser.ry CHANGED
@@ -2,9 +2,9 @@
2
2
  #
3
3
  # po_parser.ry - ruby version of msgfmt
4
4
  #
5
- # Copyright (C) 2002-2008 Masao Mutoh <mutomasa at gmail.com>
6
- # Copyright (C) 2012-2017 Kouhei Sutou <kou@clear-code.com>
7
- # Copyright (C) 2012-2013 Haruka Yoshihara <yoshihara@clear-code.com>
5
+ # Copyright (C) 2002-2008 Masao Mutoh <mutomasa at gmail.com>
6
+ # Copyright (C) 2012-2023 Sutou Kouhei <kou@clear-code.com>
7
+ # Copyright (C) 2012-2013 Haruka Yoshihara <yoshihara@clear-code.com>
8
8
  #
9
9
  # You may redistribute it and/or modify it under the same
10
10
  # license terms as Ruby or LGPL.
@@ -24,7 +24,7 @@ class GetText::POParser
24
24
  msgctxt
25
25
  : MSGCTXT string_list
26
26
  {
27
- @msgctxt = unescape(val[1])
27
+ @msgctxt = val[1]
28
28
  }
29
29
  ;
30
30
 
@@ -36,9 +36,8 @@ class GetText::POParser
36
36
  single_message
37
37
  : MSGID string_list MSGSTR string_list
38
38
  {
39
- msgid_raw = val[1]
40
- msgid = unescape(msgid_raw)
41
- msgstr = unescape(val[3])
39
+ msgid = val[1]
40
+ msgstr = val[3]
42
41
  use_message_p = true
43
42
  if @fuzzy and not msgid.empty?
44
43
  use_message_p = (not ignore_fuzzy?)
@@ -48,11 +47,15 @@ class GetText::POParser
48
47
  else
49
48
  $stderr.print _("Warning: fuzzy message was used.\n")
50
49
  end
51
- $stderr.print " #{@po_file}: msgid '#{msgid_raw}'\n"
50
+ $stderr.print " #{@po_file}: msgid '#{msgid}'\n"
52
51
  end
53
52
  end
54
53
  @fuzzy = false
55
- on_message(msgid, msgstr) if use_message_p
54
+ if use_message_p
55
+ on_message(msgid, msgstr)
56
+ else
57
+ clear
58
+ end
56
59
  result = ""
57
60
  }
58
61
 
@@ -144,31 +147,26 @@ require "gettext/po"
144
147
  @report_warning
145
148
  end
146
149
 
147
- def unescape(orig)
148
- ret = orig.gsub(/\\n/, "\n")
149
- ret.gsub!(/\\t/, "\t")
150
- ret.gsub!(/\\r/, "\r")
151
- ret.gsub!(/\\"/, "\"")
152
- ret
150
+ def unescape(string)
151
+ string.gsub(/\\(.)/) do
152
+ escaped_character = $1
153
+ case escaped_character
154
+ when "t"
155
+ "\t"
156
+ when "r"
157
+ "\r"
158
+ when "n"
159
+ "\n"
160
+ else
161
+ escaped_character
162
+ end
163
+ end
153
164
  end
154
165
  private :unescape
155
166
 
156
- def unescape_string(string)
157
- string.gsub(/\\\\/, "\\")
158
- end
159
- private :unescape_string
160
-
161
167
  def parse(str, data)
162
- @translator_comments = []
163
- @extracted_comments = []
164
- @references = []
165
- @flags = []
166
- @previous = []
167
- @comments = []
168
+ clear
168
169
  @data = data
169
- @fuzzy = false
170
- @msgctxt = nil
171
- @msgid_plural = nil
172
170
 
173
171
  str = str.strip
174
172
  @q = []
@@ -202,7 +200,7 @@ require "gettext/po"
202
200
  @q.push [:COMMENT, $&]
203
201
  str = $'
204
202
  when /\A\"(.*)\"/
205
- @q.push [:STRING, unescape_string($1)]
203
+ @q.push [:STRING, unescape($1)]
206
204
  str = $'
207
205
  else
208
206
  #c = str[0,1]
@@ -254,15 +252,7 @@ require "gettext/po"
254
252
  @data.set_comment(msgid, format_comment(@comments))
255
253
  end
256
254
 
257
- @translator_comments = []
258
- @extracted_comments = []
259
- @references = []
260
- @flags = []
261
- @previous = []
262
- @references = []
263
- @comments.clear
264
- @msgctxt = nil
265
- @msgid_plural = nil
255
+ clear
266
256
  end
267
257
 
268
258
  def format_comment(comments)
@@ -274,7 +264,11 @@ require "gettext/po"
274
264
  end
275
265
 
276
266
  def on_comment(comment)
277
- @fuzzy = true if (/fuzzy/ =~ comment)
267
+ if comment.start_with?(POFormat::FLAG_MARK)
268
+ content = comment[POFormat::FLAG_MARK.size..-1]
269
+ flags = parse_flags_line(content)
270
+ @fuzzy = flags.include?("fuzzy")
271
+ end
278
272
  if @data.instance_of?(PO)
279
273
  if comment == "#"
280
274
  @translator_comments << ""
@@ -289,7 +283,7 @@ require "gettext/po"
289
283
  when POFormat::REFERENCE_COMMENT_MARK
290
284
  @references.concat(parse_references_line(content))
291
285
  when POFormat::FLAG_MARK
292
- @flags.concat(parse_flags_line(content))
286
+ @flags.concat(flags)
293
287
  when POFormat::PREVIOUS_COMMENT_MARK
294
288
  @previous << content
295
289
  else
@@ -358,7 +352,19 @@ require "gettext/po"
358
352
  end
359
353
 
360
354
  def parse_flags_line(line)
361
- line.split(/\s+/)
355
+ line.split(",").collect(&:strip)
356
+ end
357
+
358
+ def clear
359
+ @translator_comments = []
360
+ @extracted_comments = []
361
+ @references = []
362
+ @flags = []
363
+ @previous = []
364
+ @references = []
365
+ @comments = []
366
+ @msgctxt = nil
367
+ @msgid_plural = nil
362
368
  end
363
369
  ---- footer
364
370
 
@@ -0,0 +1,30 @@
1
+ # Copyright (C) 2020 Kitaiti Makoto <KitaitiMakoto@gmail.com>
2
+ #
3
+ # License: Ruby's or LGPL
4
+ #
5
+ # This library is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ module Fixtures
19
+ module Method_
20
+ class Backtick
21
+ include GetText
22
+
23
+ bindtextdomain("_", :path => Helper::Path.locale_path)
24
+
25
+ def backtick
26
+ _(`echo hello world`)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2017 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2017-2020 Sutou Kouhei <kou@clear-code.com>
2
2
  #
3
3
  # License: Ruby's or LGPL
4
4
  #
@@ -20,7 +20,7 @@ module Fixtures
20
20
  class BlockParameter
21
21
  include GetText
22
22
 
23
- bindtextdomain("_", :path => GetTextTestUtils.locale_path)
23
+ bindtextdomain("_", :path => Helper::Path.locale_path)
24
24
 
25
25
  def message
26
26
  message_generator = lambda do |_|
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2013 Kouhei Sutou <kou@clear-code.com>
3
+ # Copyright (C) 2013-2020 Sutou Kouhei <kou@clear-code.com>
4
4
  #
5
5
  # License: Ruby's or LGPL
6
6
  #
@@ -22,7 +22,7 @@ module Fixtures
22
22
  class DoubleQuoteInDoubleQuote
23
23
  include GetText
24
24
 
25
- bindtextdomain("_", :path => GetTextTestUtils.locale_path)
25
+ bindtextdomain("_", :path => Helper::Path.locale_path)
26
26
 
27
27
  def message
28
28
  _("double \"quote\" in double quote")
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2013 Kouhei Sutou <kou@clear-code.com>
3
+ # Copyright (C) 2013-2020 Sutou Kouhei <kou@clear-code.com>
4
4
  #
5
5
  # License: Ruby's or LGPL
6
6
  #
@@ -22,7 +22,7 @@ module Fixtures
22
22
  class DoubleQuoteInSingleQuote
23
23
  include GetText
24
24
 
25
- bindtextdomain("_", :path => GetTextTestUtils.locale_path)
25
+ bindtextdomain("_", :path => Helper::Path.locale_path)
26
26
 
27
27
  def message
28
28
  _('double "quote" in single quote')
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2013 Kouhei Sutou <kou@clear-code.com>
3
+ # Copyright (C) 2013-2020 Sutou Kouhei <kou@clear-code.com>
4
4
  #
5
5
  # License: Ruby's or LGPL
6
6
  #
@@ -22,7 +22,7 @@ module Fixtures
22
22
  class LiteralConcatenationWithContinuationLine
23
23
  include GetText
24
24
 
25
- bindtextdomain("_", :path => GetTextTestUtils.locale_path)
25
+ bindtextdomain("_", :path => Helper::Path.locale_path)
26
26
 
27
27
  def message
28
28
  _("literal " \
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2013 Kouhei Sutou <kou@clear-code.com>
3
+ # Copyright (C) 2013-2020 Sutou Kouhei <kou@clear-code.com>
4
4
  #
5
5
  # License: Ruby's or LGPL
6
6
  #
@@ -22,7 +22,7 @@ module Fixtures
22
22
  class MiddleNewLine
23
23
  include GetText
24
24
 
25
- bindtextdomain("_", :path => GetTextTestUtils.locale_path)
25
+ bindtextdomain("_", :path => Helper::Path.locale_path)
26
26
 
27
27
  def message
28
28
  _("middle\nnew line")
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2013 Kouhei Sutou <kou@clear-code.com>
3
+ # Copyright (C) 2013-2020 Sutou Kouhei <kou@clear-code.com>
4
4
  #
5
5
  # License: Ruby's or LGPL
6
6
  #
@@ -22,7 +22,7 @@ module Fixtures
22
22
  class MultipleLinesLiteral
23
23
  include GetText
24
24
 
25
- bindtextdomain("_", :path => GetTextTestUtils.locale_path)
25
+ bindtextdomain("_", :path => Helper::Path.locale_path)
26
26
 
27
27
  def message
28
28
  _("multiple
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2013 Kouhei Sutou <kou@clear-code.com>
3
+ # Copyright (C) 2013-2020 Sutou Kouhei <kou@clear-code.com>
4
4
  #
5
5
  # License: Ruby's or LGPL
6
6
  #
@@ -22,7 +22,7 @@ module Fixtures
22
22
  class MultipleMessagesInSameLine
23
23
  include GetText
24
24
 
25
- bindtextdomain("_", :path => GetTextTestUtils.locale_path)
25
+ bindtextdomain("_", :path => Helper::Path.locale_path)
26
26
 
27
27
  def message
28
28
  _("multiple") + " messages " + _("in same line")
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2013 Kouhei Sutou <kou@clear-code.com>
3
+ # Copyright (C) 2013-2020 Sutou Kouhei <kou@clear-code.com>
4
4
  #
5
5
  # License: Ruby's or LGPL
6
6
  #
@@ -22,7 +22,7 @@ module Fixtures
22
22
  class MultipleSameMessages
23
23
  include GetText
24
24
 
25
- bindtextdomain("_", :path => GetTextTestUtils.locale_path)
25
+ bindtextdomain("_", :path => Helper::Path.locale_path)
26
26
 
27
27
  def message
28
28
  _("multiple same messages")
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
3
+ # Copyright (C) 2012-2020 Sutou Kouhei <kou@clear-code.com>
4
4
  #
5
5
  # License: Ruby's or LGPL
6
6
  #
@@ -22,7 +22,7 @@ module Fixtures
22
22
  class OneLine
23
23
  include GetText
24
24
 
25
- bindtextdomain("_", :path => GetTextTestUtils.locale_path)
25
+ bindtextdomain("_", :path => Helper::Path.locale_path)
26
26
 
27
27
  def message
28
28
  _("one line")
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2013 Kouhei Sutou <kou@clear-code.com>
3
+ # Copyright (C) 2013-2020 Sutou Kouhei <kou@clear-code.com>
4
4
  #
5
5
  # License: Ruby's or LGPL
6
6
  #
@@ -22,7 +22,7 @@ module Fixtures
22
22
  class OneNewLine
23
23
  include GetText
24
24
 
25
- bindtextdomain("_", :path => GetTextTestUtils.locale_path)
25
+ bindtextdomain("_", :path => Helper::Path.locale_path)
26
26
 
27
27
  def message
28
28
  _("one new line\n")
@@ -0,0 +1,55 @@
1
+ # Copyright (C) 2020 Kitaiti Makoto <KitaitiMakoto@gmail.com>
2
+ # Copyright (C) 2020 Sutou Kouhei <kou@clear-code.com>
3
+ #
4
+ # License: Ruby's or LGPL
5
+ #
6
+ # This library is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU Lesser General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # This library is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU Lesser General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public License
17
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ module Fixtures
20
+ module Method_
21
+ class PercentStrings
22
+ include GetText
23
+
24
+ bindtextdomain("_", :path => Helper::Path.locale_path)
25
+
26
+ def symbol_array
27
+ _(%i(hello world))
28
+ end
29
+
30
+ def in_symbol_array
31
+ %I(before#{_("in_symbol_array")}after)
32
+ end
33
+
34
+ def symbol
35
+ _(%s(hello world))
36
+ end
37
+
38
+ def string
39
+ _(%(hello world))
40
+ end
41
+
42
+ def string_array
43
+ _(%w(hello world))
44
+ end
45
+
46
+ def in_string_array
47
+ %W(before#{_("in_string_array")}after)
48
+ end
49
+
50
+ def execute
51
+ _(%x(echo hello world))
52
+ end
53
+ end
54
+ end
55
+ end