gettext 2.2.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/COPYING +2 -1
- data/README.rdoc +9 -9
- data/Rakefile +94 -149
- data/bin/rmsgfmt +23 -20
- data/bin/rmsginit +29 -0
- data/bin/rmsgmerge +22 -20
- data/bin/rxgettext +24 -0
- data/doc/text/news.md +60 -0
- data/gettext.gemspec +7 -4
- data/lib/gettext.rb +3 -3
- data/lib/gettext/core_ext/string.rb +2 -1
- data/lib/gettext/runtime/locale_path.rb +6 -4
- data/lib/gettext/runtime/textdomain.rb +14 -8
- data/lib/gettext/runtime/textdomain_manager.rb +3 -3
- data/lib/gettext/task.rb +203 -0
- data/lib/gettext/tools.rb +33 -24
- data/lib/gettext/tools/msgfmt.rb +104 -0
- data/lib/gettext/tools/msginit.rb +363 -0
- data/lib/gettext/tools/msgmerge.rb +510 -0
- data/lib/gettext/tools/parser/ruby.rb +12 -17
- data/lib/gettext/tools/pomessage.rb +37 -4
- data/lib/gettext/tools/poparser.rb +27 -24
- data/lib/gettext/tools/xgettext.rb +327 -0
- data/lib/gettext/version.rb +2 -2
- data/po/bg/rgettext.po +2 -2
- data/po/bs/rgettext.po +2 -2
- data/po/ca/rgettext.po +2 -2
- data/po/cs/rgettext.po +2 -2
- data/po/de/gettext.po +668 -0
- data/po/de/gettext.po.bak +589 -0
- data/po/de/rgettext.po +2 -2
- data/po/el/gettext.po +571 -0
- data/po/el/rgettext.po +2 -2
- data/po/eo/rgettext.po +2 -2
- data/po/es/rgettext.po +2 -2
- data/po/et/rgettext.po +2 -2
- data/po/fr/gettext.po +589 -0
- data/po/fr/rgettext.po +2 -2
- data/po/gettext.pot +638 -0
- data/po/gettext.pot~ +638 -0
- data/po/hr/rgettext.po +2 -2
- data/po/hu/rgettext.po +2 -2
- data/po/it/gettext.po +589 -0
- data/po/it/rgettext.po +2 -2
- data/po/ja/gettext.po +591 -0
- data/po/ja/rgettext.po +112 -69
- data/po/ko/rgettext.po +2 -2
- data/po/lv/rgettext.po +2 -2
- data/po/nb/rgettext.po +2 -2
- data/po/nl/rgettext.po +2 -2
- data/po/pt_BR/rgettext.po +2 -2
- data/po/ru/rgettext.po +2 -2
- data/po/sr/rgettext.po +2 -2
- data/po/sv/rgettext.po +2 -2
- data/po/uk/gettext.po +571 -0
- data/po/uk/rgettext.po +2 -2
- data/po/vi/rgettext.po +2 -2
- data/po/zh/rgettext.po +2 -2
- data/po/zh_TW/rgettext.po +2 -2
- data/samples/README +2 -4
- data/samples/cgi/README +1 -1
- data/samples/cgi/cookie.cgi +1 -1
- data/samples/cgi/gettext.css +1 -1
- data/samples/cgi/helloerb.rhtml +1 -1
- data/samples/cgi/hellolib.rb +1 -1
- data/samples/cgi/http.rb +2 -2
- data/samples/cgi/index.cgi +1 -1
- data/samples/cgi/locale/bg/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/bg/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/bg/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/bs/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/bs/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/bs/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/ca/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/ca/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/ca/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/cs/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/cs/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/cs/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/de/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/de/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/de/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/el/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/el/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/el/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/eo/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/eo/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/eo/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/es/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/es/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/es/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/fr/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/fr/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/fr/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/hr/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/hr/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/hr/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/hu/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/hu/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/hu/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/it/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/it/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/it/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/ja/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/ja/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/ja/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/ko/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/ko/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/ko/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/lv/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/lv/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/lv/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/nb/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/nb/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/nb/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/nl/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/nl/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/nl/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/pt_BR/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/pt_BR/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/pt_BR/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/ru/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/ru/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/ru/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/sr/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/sr/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/sr/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/uk/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/uk/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/uk/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/vi/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/vi/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/vi/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/zh/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/zh/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/zh/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/zh_TW/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/zh_TW/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/zh_TW/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/other.rhtml +1 -1
- data/samples/cgi/po/bg/helloerb1.po +4 -4
- data/samples/cgi/po/bg/helloerb2.po +4 -4
- data/samples/cgi/po/bg/hellolib.po +2 -2
- data/samples/cgi/po/bg/main.po +4 -4
- data/samples/cgi/po/bs/helloerb1.po +3 -3
- data/samples/cgi/po/bs/helloerb2.po +3 -3
- data/samples/cgi/po/bs/hellolib.po +2 -2
- data/samples/cgi/po/bs/main.po +3 -3
- data/samples/cgi/po/ca/helloerb1.po +4 -4
- data/samples/cgi/po/ca/helloerb2.po +4 -4
- data/samples/cgi/po/ca/hellolib.po +2 -2
- data/samples/cgi/po/ca/main.po +4 -4
- data/samples/cgi/po/cs/helloerb1.po +4 -4
- data/samples/cgi/po/cs/helloerb2.po +4 -4
- data/samples/cgi/po/cs/hellolib.po +2 -2
- data/samples/cgi/po/cs/main.po +4 -4
- data/samples/cgi/po/de/helloerb1.po +3 -3
- data/samples/cgi/po/de/helloerb2.po +3 -3
- data/samples/cgi/po/de/hellolib.po +2 -2
- data/samples/cgi/po/de/main.po +3 -3
- data/samples/cgi/po/el/helloerb1.po +3 -3
- data/samples/cgi/po/el/helloerb2.po +3 -3
- data/samples/cgi/po/el/hellolib.po +2 -2
- data/samples/cgi/po/el/main.po +3 -3
- data/samples/cgi/po/eo/helloerb1.po +3 -3
- data/samples/cgi/po/eo/helloerb2.po +3 -3
- data/samples/cgi/po/eo/hellolib.po +2 -2
- data/samples/cgi/po/eo/main.po +3 -3
- data/samples/cgi/po/es/helloerb1.po +4 -4
- data/samples/cgi/po/es/helloerb2.po +4 -4
- data/samples/cgi/po/es/hellolib.po +2 -2
- data/samples/cgi/po/es/main.po +4 -4
- data/samples/cgi/po/fr/helloerb1.po +4 -4
- data/samples/cgi/po/fr/helloerb2.po +4 -4
- data/samples/cgi/po/fr/hellolib.po +2 -2
- data/samples/cgi/po/fr/main.po +4 -4
- data/samples/cgi/po/hr/helloerb1.po +3 -3
- data/samples/cgi/po/hr/helloerb2.po +3 -3
- data/samples/cgi/po/hr/hellolib.po +2 -2
- data/samples/cgi/po/hr/main.po +3 -3
- data/samples/cgi/po/hu/helloerb1.po +4 -4
- data/samples/cgi/po/hu/helloerb2.po +4 -4
- data/samples/cgi/po/hu/hellolib.po +2 -2
- data/samples/cgi/po/hu/main.po +4 -4
- data/samples/cgi/po/it/helloerb1.po +3 -3
- data/samples/cgi/po/it/helloerb2.po +3 -3
- data/samples/cgi/po/it/hellolib.po +2 -2
- data/samples/cgi/po/it/main.po +3 -3
- data/samples/cgi/po/ja/helloerb1.po +4 -4
- data/samples/cgi/po/ja/helloerb2.po +4 -4
- data/samples/cgi/po/ja/hellolib.po +2 -2
- data/samples/cgi/po/ja/main.po +3 -3
- data/samples/cgi/po/ko/helloerb1.po +3 -3
- data/samples/cgi/po/ko/helloerb2.po +3 -3
- data/samples/cgi/po/ko/hellolib.po +2 -2
- data/samples/cgi/po/ko/main.po +3 -3
- data/samples/cgi/po/lv/helloerb1.po +4 -4
- data/samples/cgi/po/lv/helloerb2.po +4 -4
- data/samples/cgi/po/lv/hellolib.po +2 -2
- data/samples/cgi/po/lv/main.po +4 -4
- data/samples/cgi/po/nb/helloerb1.po +3 -3
- data/samples/cgi/po/nb/helloerb2.po +3 -3
- data/samples/cgi/po/nb/hellolib.po +2 -2
- data/samples/cgi/po/nb/main.po +3 -3
- data/samples/cgi/po/nl/helloerb1.po +4 -4
- data/samples/cgi/po/nl/helloerb2.po +4 -4
- data/samples/cgi/po/nl/hellolib.po +2 -2
- data/samples/cgi/po/nl/main.po +4 -4
- data/samples/cgi/po/pt_BR/helloerb1.po +4 -4
- data/samples/cgi/po/pt_BR/helloerb2.po +4 -4
- data/samples/cgi/po/pt_BR/hellolib.po +2 -2
- data/samples/cgi/po/pt_BR/main.po +4 -4
- data/samples/cgi/po/ru/helloerb1.po +4 -4
- data/samples/cgi/po/ru/helloerb2.po +4 -4
- data/samples/cgi/po/ru/hellolib.po +2 -2
- data/samples/cgi/po/ru/main.po +4 -4
- data/samples/cgi/po/sr/helloerb1.po +4 -4
- data/samples/cgi/po/sr/helloerb2.po +4 -4
- data/samples/cgi/po/sr/hellolib.po +2 -2
- data/samples/cgi/po/sr/main.po +4 -4
- data/samples/cgi/po/uk/helloerb1.po +4 -4
- data/samples/cgi/po/uk/helloerb2.po +4 -4
- data/samples/cgi/po/uk/hellolib.po +2 -2
- data/samples/cgi/po/uk/main.po +4 -4
- data/samples/cgi/po/vi/helloerb1.po +3 -3
- data/samples/cgi/po/vi/helloerb2.po +3 -3
- data/samples/cgi/po/vi/hellolib.po +2 -2
- data/samples/cgi/po/vi/main.po +3 -3
- data/samples/cgi/po/zh/helloerb1.po +4 -4
- data/samples/cgi/po/zh/helloerb2.po +4 -4
- data/samples/cgi/po/zh/hellolib.po +2 -2
- data/samples/cgi/po/zh/main.po +4 -4
- data/samples/cgi/po/zh_TW/helloerb1.po +4 -4
- data/samples/cgi/po/zh_TW/helloerb2.po +4 -4
- data/samples/cgi/po/zh_TW/hellolib.po +2 -2
- data/samples/cgi/po/zh_TW/main.po +4 -4
- data/samples/hello.rb +1 -1
- data/samples/hello2.rb +1 -1
- data/samples/hello_glade2.rb +1 -1
- data/samples/hello_gtk2.rb +2 -2
- data/samples/hello_noop.rb +1 -1
- data/samples/hello_plural.rb +1 -1
- data/samples/hello_tk.rb +1 -1
- data/samples/locale/bg/LC_MESSAGES/hello_gtk2.mo +0 -0
- data/samples/locale/bs/LC_MESSAGES/hello_gtk2.mo +0 -0
- data/samples/locale/ca/LC_MESSAGES/hello_gtk2.mo +0 -0
- data/samples/locale/cs/LC_MESSAGES/hello_gtk2.mo +0 -0
- data/samples/locale/de/LC_MESSAGES/hello_gtk2.mo +0 -0
- data/samples/locale/el/LC_MESSAGES/hello_gtk2.mo +0 -0
- data/samples/locale/eo/LC_MESSAGES/hello_gtk2.mo +0 -0
- data/samples/locale/es/LC_MESSAGES/hello_gtk2.mo +0 -0
- data/samples/locale/fr/LC_MESSAGES/hello_gtk2.mo +0 -0
- data/samples/locale/hr/LC_MESSAGES/hello_gtk2.mo +0 -0
- data/samples/locale/hu/LC_MESSAGES/hello_gtk2.mo +0 -0
- data/samples/locale/it/LC_MESSAGES/hello_gtk2.mo +0 -0
- data/samples/locale/ja/LC_MESSAGES/hello_gtk2.mo +0 -0
- data/samples/locale/ko/LC_MESSAGES/hello_gtk2.mo +0 -0
- data/samples/locale/lv/LC_MESSAGES/hello_gtk2.mo +0 -0
- data/samples/locale/nb/LC_MESSAGES/hello_gtk2.mo +0 -0
- data/samples/locale/nl/LC_MESSAGES/hello_gtk2.mo +0 -0
- data/samples/locale/pt_BR/LC_MESSAGES/hello_gtk2.mo +0 -0
- data/samples/locale/ru/LC_MESSAGES/hello_gtk2.mo +0 -0
- data/samples/locale/sr/LC_MESSAGES/hello_gtk2.mo +0 -0
- data/samples/locale/sv/LC_MESSAGES/hello_gtk2.mo +0 -0
- data/samples/locale/uk/LC_MESSAGES/hello_gtk2.mo +0 -0
- data/samples/locale/vi/LC_MESSAGES/hello_gtk2.mo +0 -0
- data/samples/locale/zh/LC_MESSAGES/hello_gtk2.mo +0 -0
- data/samples/locale/zh_TW/LC_MESSAGES/hello_gtk2.mo +0 -0
- data/samples/po/bg/hello.po +2 -2
- data/samples/po/bg/hello2.po +1 -1
- data/samples/po/bg/hello_glade2.po +1 -1
- data/samples/po/bg/{hello_gtk.po → hello_gtk2.po} +1 -1
- data/samples/po/bg/hello_noop.po +1 -1
- data/samples/po/bg/hello_plural.po +1 -1
- data/samples/po/bg/hello_tk.po +1 -1
- data/samples/po/bs/hello.po +2 -2
- data/samples/po/bs/hello2.po +1 -1
- data/samples/po/bs/hello_glade2.po +1 -1
- data/samples/po/bs/{hello_gtk.po → hello_gtk2.po} +1 -1
- data/samples/po/bs/hello_noop.po +1 -1
- data/samples/po/bs/hello_plural.po +1 -1
- data/samples/po/bs/hello_tk.po +1 -1
- data/samples/po/ca/hello.po +2 -2
- data/samples/po/ca/hello2.po +1 -1
- data/samples/po/ca/hello_glade2.po +1 -1
- data/samples/po/ca/{hello_gtk.po → hello_gtk2.po} +1 -1
- data/samples/po/ca/hello_noop.po +1 -1
- data/samples/po/ca/hello_plural.po +1 -1
- data/samples/po/ca/hello_tk.po +1 -1
- data/samples/po/cs/hello.po +1 -1
- data/samples/po/cs/hello_glade2.po +1 -1
- data/samples/po/cs/{hello_gtk.po → hello_gtk2.po} +0 -0
- data/samples/po/cs/hello_plural.po +1 -1
- data/samples/po/de/hello.po +1 -1
- data/samples/po/de/{hello_gtk.po → hello_gtk2.po} +0 -0
- data/samples/po/de/hello_plural.po +1 -1
- data/samples/po/el/hello.po +2 -2
- data/samples/po/el/hello2.po +1 -1
- data/samples/po/el/hello_glade2.po +1 -1
- data/samples/po/el/{hello_gtk.po → hello_gtk2.po} +1 -1
- data/samples/po/el/hello_noop.po +1 -1
- data/samples/po/el/hello_plural.po +1 -1
- data/samples/po/el/hello_tk.po +1 -1
- data/samples/po/eo/hello.po +2 -2
- data/samples/po/eo/hello2.po +1 -1
- data/samples/po/eo/hello_glade2.po +1 -1
- data/samples/po/eo/{hello_gtk.po → hello_gtk2.po} +1 -1
- data/samples/po/eo/hello_noop.po +1 -1
- data/samples/po/eo/hello_plural.po +1 -1
- data/samples/po/eo/hello_tk.po +1 -1
- data/samples/po/es/{hello_gtk.po → hello_gtk2.po} +0 -0
- data/samples/po/fr/{hello_gtk.po → hello_gtk2.po} +0 -0
- data/samples/po/hello.pot +13 -13
- data/samples/po/hello2.pot +17 -17
- data/samples/po/hello_glade2.pot +12 -13
- data/{test/pot/backslash.pot → samples/po/hello_gtk2.pot} +8 -6
- data/samples/po/hello_noop.pot +13 -13
- data/samples/po/hello_plural.pot +14 -15
- data/samples/po/hello_tk.pot +9 -10
- data/samples/po/hr/hello.po +2 -2
- data/samples/po/hr/hello2.po +1 -1
- data/samples/po/hr/hello_glade2.po +1 -1
- data/samples/po/hr/{hello_gtk.po → hello_gtk2.po} +1 -1
- data/samples/po/hr/hello_noop.po +1 -1
- data/samples/po/hr/hello_plural.po +1 -1
- data/samples/po/hr/hello_tk.po +1 -1
- data/samples/po/hu/hello.po +2 -2
- data/samples/po/hu/hello2.po +1 -1
- data/samples/po/hu/hello_glade2.po +1 -1
- data/samples/po/hu/{hello_gtk.po → hello_gtk2.po} +1 -1
- data/samples/po/hu/hello_noop.po +1 -1
- data/samples/po/hu/hello_plural.po +1 -1
- data/samples/po/hu/hello_tk.po +1 -1
- data/samples/po/it/hello.po +1 -1
- data/samples/po/it/{hello_gtk.po → hello_gtk2.po} +0 -0
- data/samples/po/ja/{hello_gtk.po → hello_gtk2.po} +0 -0
- data/samples/po/ko/{hello_gtk.po → hello_gtk2.po} +0 -0
- data/samples/po/ko/hello_plural.po +1 -1
- data/samples/po/lv/hello.po +2 -2
- data/samples/po/lv/hello2.po +1 -1
- data/samples/po/lv/hello_glade2.po +1 -1
- data/samples/po/lv/{hello_gtk.po → hello_gtk2.po} +1 -1
- data/samples/po/lv/hello_noop.po +1 -1
- data/samples/po/lv/hello_plural.po +1 -1
- data/samples/po/lv/hello_tk.po +1 -1
- data/samples/po/nb/hello.po +2 -2
- data/samples/po/nb/hello2.po +1 -1
- data/samples/po/nb/hello_glade2.po +1 -1
- data/samples/po/nb/{hello_gtk.po → hello_gtk2.po} +1 -1
- data/samples/po/nb/hello_noop.po +1 -1
- data/samples/po/nb/hello_plural.po +1 -1
- data/samples/po/nb/hello_tk.po +1 -1
- data/samples/po/nl/hello.po +2 -2
- data/samples/po/nl/hello2.po +1 -1
- data/samples/po/nl/hello_glade2.po +1 -1
- data/samples/po/nl/{hello_gtk.po → hello_gtk2.po} +1 -1
- data/samples/po/nl/hello_noop.po +1 -1
- data/samples/po/nl/hello_plural.po +1 -1
- data/samples/po/nl/hello_tk.po +1 -1
- data/samples/po/pt_BR/{hello_gtk.po → hello_gtk2.po} +0 -0
- data/samples/po/ru/hello.po +2 -2
- data/samples/po/ru/hello2.po +1 -1
- data/samples/po/ru/hello_glade2.po +1 -1
- data/samples/po/ru/{hello_gtk.po → hello_gtk2.po} +1 -1
- data/samples/po/ru/hello_noop.po +1 -1
- data/samples/po/ru/hello_plural.po +1 -1
- data/samples/po/ru/hello_tk.po +1 -1
- data/samples/po/sr/hello.po +2 -2
- data/samples/po/sr/hello2.po +1 -1
- data/samples/po/sr/hello_glade2.po +1 -1
- data/samples/po/sr/{hello_gtk.po → hello_gtk2.po} +1 -1
- data/samples/po/sr/hello_noop.po +1 -1
- data/samples/po/sr/hello_plural.po +1 -1
- data/samples/po/sr/hello_tk.po +1 -1
- data/samples/po/sv/{hello_gtk.po → hello_gtk2.po} +0 -0
- data/samples/po/uk/hello.po +2 -2
- data/samples/po/uk/hello2.po +1 -1
- data/samples/po/uk/hello_glade2.po +1 -1
- data/samples/po/uk/{hello_gtk.po → hello_gtk2.po} +1 -1
- data/samples/po/uk/hello_noop.po +1 -1
- data/samples/po/uk/hello_plural.po +1 -1
- data/samples/po/uk/hello_tk.po +1 -1
- data/samples/po/vi/hello.po +2 -2
- data/samples/po/vi/hello2.po +1 -1
- data/samples/po/vi/hello_glade2.po +1 -1
- data/samples/po/vi/{hello_gtk.po → hello_gtk2.po} +1 -1
- data/samples/po/vi/hello_noop.po +1 -1
- data/samples/po/vi/hello_plural.po +1 -1
- data/samples/po/vi/hello_tk.po +1 -1
- data/samples/po/zh/hello.po +2 -2
- data/samples/po/zh/hello2.po +1 -1
- data/samples/po/zh/hello_glade2.po +1 -1
- data/samples/po/zh/{hello_gtk.po → hello_gtk2.po} +1 -1
- data/samples/po/zh/hello_noop.po +1 -1
- data/samples/po/zh/hello_plural.po +1 -1
- data/samples/po/zh/hello_tk.po +1 -1
- data/samples/po/zh_TW/hello.po +2 -2
- data/samples/po/zh_TW/hello2.po +1 -1
- data/samples/po/zh_TW/hello_glade2.po +1 -1
- data/samples/po/zh_TW/{hello_gtk.po → hello_gtk2.po} +1 -1
- data/samples/po/zh_TW/hello_noop.po +1 -1
- data/samples/po/zh_TW/hello_plural.po +1 -1
- data/samples/po/zh_TW/hello_tk.po +1 -1
- data/src/poparser.ry +18 -14
- data/test/{testlib → fixtures}/N_.rb +0 -0
- data/test/{testlib/gettext.rb → fixtures/_.rb} +27 -1
- data/test/fixtures/_/one_line.rb +32 -0
- data/test/fixtures/backslash.rb +29 -0
- data/test/{testlib → fixtures}/erb.rhtml +0 -0
- data/test/{testlib → fixtures}/erb.rxml +0 -0
- data/test/{testlib → fixtures}/gladeparser.glade +0 -0
- data/test/{testlib → fixtures}/multi_textdomain.rb +0 -0
- data/test/{testlib/ngettext.rb → fixtures/n_.rb} +20 -1
- data/test/{testlib → fixtures}/non_ascii.rb +0 -0
- data/test/fixtures/np_.rb +51 -0
- data/test/{testlib/nsgettext.rb → fixtures/ns_.rb} +20 -2
- data/test/fixtures/ns_/custom.rb +32 -0
- data/test/fixtures/p_.rb +57 -0
- data/test/fixtures/s_.rb +66 -0
- data/test/fixtures/s_/custom.rb +32 -0
- data/test/{testlib → fixtures}/simple.rb +0 -0
- data/test/gettext-test-utils.rb +44 -0
- data/test/locale/ja/LC_MESSAGES/_.mo +0 -0
- data/test/locale/ja/LC_MESSAGES/backslash.mo +0 -0
- data/test/locale/ja/LC_MESSAGES/np_.mo +0 -0
- data/test/locale/ja/LC_MESSAGES/ns_.mo +0 -0
- data/test/locale/ja/LC_MESSAGES/p_.mo +0 -0
- data/test/locale/ja/LC_MESSAGES/s_.mo +0 -0
- data/test/parser/test_ruby.rb +121 -0
- data/test/po/_.pot +109 -0
- data/test/{pot/sgettext.pot → po/backslash.pot} +10 -4
- data/test/po/ja/_.po +114 -0
- data/test/po/ja/backslash.po +3 -3
- data/test/po/ja/non_ascii.po +1 -1
- data/test/po/ja/{npgettext.po → np_.po} +6 -6
- data/test/po/ja/{nsgettext.po → ns_.po} +16 -10
- data/test/po/ja/{pgettext.po → p_.po} +5 -5
- data/test/po/ja/{sgettext.po → s_.po} +0 -0
- data/test/{pot → po}/non_ascii.pot +7 -5
- data/test/{pot/npgettext.pot → po/np_.pot} +10 -9
- data/test/{pot/nsgettext.pot → po/ns_.pot} +20 -12
- data/test/{pot/pgettext.pot → po/p_.pot} +12 -10
- data/test/po/s_.pot +55 -0
- data/test/run-test.rb +5 -0
- data/test/test_class_info.rb +0 -1
- data/test/test_gettext.rb +49 -12
- data/test/test_locale_path.rb +1 -4
- data/test/test_mofile.rb +0 -1
- data/test/test_parser.rb +119 -88
- data/test/test_po_generation.rb +32 -9
- data/test/{test_pomessage.rb → test_po_message.rb} +18 -1
- data/test/test_po_parser.rb +117 -0
- data/test/test_string.rb +0 -2
- data/test/test_textdomain_bind.rb +0 -2
- data/test/test_textdomain_multi.rb +1 -2
- data/test/test_textdomain_toplevel.rb +0 -1
- data/test/test_thread.rb +0 -1
- data/test/tools/test_msginit.rb +351 -0
- data/test/tools/test_msgmerge.rb +202 -0
- data/test/tools/test_tools.rb +0 -2
- data/test/tools/test_xgettext.rb +154 -0
- metadata +822 -753
- data/bin/rgettext +0 -23
- data/data/locale/bg/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/bs/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/ca/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/cs/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/de/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/el/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/eo/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/es/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/et/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/fr/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/hr/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/hu/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/it/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/ja/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/ko/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/lv/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/nb/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/nl/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/pt_BR/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/ru/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/sr/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/sv/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/uk/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/vi/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/zh/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/zh_TW/LC_MESSAGES/rgettext.mo +0 -0
- data/lib/gettext/tools/rgettext.rb +0 -251
- data/lib/gettext/tools/rmsgfmt.rb +0 -86
- data/lib/gettext/tools/rmsgmerge.rb +0 -500
- data/samples/makemo.rb +0 -6
- data/samples/po/hello_gtk.pot +0 -23
- data/samples/po/test.rb +0 -13
- data/test/testlib/backslash.rb +0 -12
- data/test/testlib/helper.rb +0 -13
- data/test/testlib/npgettext.rb +0 -33
- data/test/testlib/pgettext.rb +0 -38
- data/test/testlib/sgettext.rb +0 -48
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/ruby
|
|
2
1
|
=begin
|
|
3
2
|
parser/ruby.rb - parser for ruby script
|
|
4
3
|
|
|
@@ -21,7 +20,7 @@ module GetText
|
|
|
21
20
|
def parse
|
|
22
21
|
until ( (tk = token).kind_of?(RubyToken::TkEND_OF_SCRIPT) && !@continue or tk.nil? )
|
|
23
22
|
s = get_readed
|
|
24
|
-
if RubyToken::TkSTRING === tk
|
|
23
|
+
if RubyToken::TkSTRING === tk or RubyToken::TkDSTRING === tk
|
|
25
24
|
def tk.value
|
|
26
25
|
@value
|
|
27
26
|
end
|
|
@@ -44,7 +43,7 @@ module GetText
|
|
|
44
43
|
end
|
|
45
44
|
|
|
46
45
|
if $DEBUG
|
|
47
|
-
if tk.is_a? TkSTRING
|
|
46
|
+
if tk.is_a? TkSTRING or tk.is_a? TkDSTRING
|
|
48
47
|
$stderr.puts("#{tk}: #{tk.value}")
|
|
49
48
|
elsif tk.is_a? TkIDENTIFIER
|
|
50
49
|
$stderr.puts("#{tk}: #{tk.name}")
|
|
@@ -136,8 +135,11 @@ module GetText
|
|
|
136
135
|
line_no = nil
|
|
137
136
|
last_comment = ''
|
|
138
137
|
reset_comment = false
|
|
138
|
+
ignore_next_comma = false
|
|
139
139
|
rl.parse do |tk|
|
|
140
140
|
begin
|
|
141
|
+
ignore_current_comma = ignore_next_comma
|
|
142
|
+
ignore_next_comma = false
|
|
141
143
|
case tk
|
|
142
144
|
when RubyToken::TkIDENTIFIER, RubyToken::TkCONSTANT
|
|
143
145
|
store_pomessage(pomessages, pomessage, path, line_no, last_comment)
|
|
@@ -153,15 +155,20 @@ module GetText
|
|
|
153
155
|
pomessage = nil
|
|
154
156
|
end
|
|
155
157
|
line_no = tk.line_no.to_s
|
|
156
|
-
when RubyToken::TkSTRING
|
|
158
|
+
when RubyToken::TkSTRING, RubyToken::TkDSTRING
|
|
157
159
|
pomessage.set_current_attribute tk.value if pomessage
|
|
158
160
|
when RubyToken::TkPLUS, RubyToken::TkNL
|
|
159
161
|
#do nothing
|
|
162
|
+
when RubyToken::TkINTEGER
|
|
163
|
+
ignore_next_comma = true
|
|
160
164
|
when RubyToken::TkCOMMA
|
|
161
|
-
|
|
165
|
+
unless ignore_current_comma
|
|
166
|
+
pomessage.advance_to_next_attribute if pomessage
|
|
167
|
+
end
|
|
162
168
|
else
|
|
163
169
|
if store_pomessage(pomessages, pomessage, path, line_no, last_comment)
|
|
164
170
|
pomessage = nil
|
|
171
|
+
last_comment = ""
|
|
165
172
|
end
|
|
166
173
|
end
|
|
167
174
|
rescue
|
|
@@ -212,15 +219,3 @@ module GetText
|
|
|
212
219
|
end
|
|
213
220
|
end
|
|
214
221
|
end
|
|
215
|
-
|
|
216
|
-
if __FILE__ == $0
|
|
217
|
-
require 'pp'
|
|
218
|
-
ARGV.each do |path|
|
|
219
|
-
pp GetText::RubyParser.parse(path)
|
|
220
|
-
end
|
|
221
|
-
|
|
222
|
-
#rl = GetText::RubyLexX.new; rl.set_input(ARGF)
|
|
223
|
-
#rl.parse do |tk|
|
|
224
|
-
#p tk
|
|
225
|
-
#end
|
|
226
|
-
end
|
|
@@ -1,4 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
|
|
4
|
+
# Copyright (C) 2010 masone (Christian Felder) <ema@rh-productions.ch>
|
|
5
|
+
# Copyright (C) 2009 Masao Mutoh
|
|
6
|
+
#
|
|
7
|
+
# License: Ruby's or LGPL
|
|
8
|
+
#
|
|
9
|
+
# This library is free software: you can redistribute it and/or modify
|
|
10
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
# (at your option) any later version.
|
|
13
|
+
#
|
|
14
|
+
# This library is distributed in the hope that it will be useful,
|
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
# GNU Lesser General Public License for more details.
|
|
18
|
+
#
|
|
19
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
20
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
2
21
|
|
|
3
22
|
module GetText
|
|
4
23
|
class ParseError < StandardError
|
|
@@ -8,12 +27,25 @@ module GetText
|
|
|
8
27
|
# is to be translated.
|
|
9
28
|
class PoMessage
|
|
10
29
|
PARAMS = {
|
|
11
|
-
:normal => [:msgid],
|
|
12
|
-
:plural => [:msgid, :msgid_plural],
|
|
30
|
+
:normal => [:msgid, :separator],
|
|
31
|
+
:plural => [:msgid, :msgid_plural, :separator],
|
|
13
32
|
:msgctxt => [:msgctxt, :msgid],
|
|
14
33
|
:msgctxt_plural => [:msgctxt, :msgid, :msgid_plural]
|
|
15
34
|
}
|
|
16
35
|
|
|
36
|
+
class << self
|
|
37
|
+
def escape(string)
|
|
38
|
+
string.gsub(/([\\"\n])/) do
|
|
39
|
+
special_character = $1
|
|
40
|
+
if special_character == "\n"
|
|
41
|
+
"\\n"
|
|
42
|
+
else
|
|
43
|
+
"\\#{special_character}"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
17
49
|
@@max_line_length = 70
|
|
18
50
|
|
|
19
51
|
# Sets the max line length.
|
|
@@ -31,6 +63,7 @@ module GetText
|
|
|
31
63
|
attr_accessor :msgid
|
|
32
64
|
# Options
|
|
33
65
|
attr_accessor :msgid_plural
|
|
66
|
+
attr_accessor :separator
|
|
34
67
|
attr_accessor :msgctxt
|
|
35
68
|
attr_accessor :sources # ["file1:line1", "file2:line2", ...]
|
|
36
69
|
attr_accessor :comment
|
|
@@ -56,7 +89,7 @@ module GetText
|
|
|
56
89
|
# and other purposes.
|
|
57
90
|
def escaped(param_name)
|
|
58
91
|
orig = self.send param_name
|
|
59
|
-
|
|
92
|
+
self.class.escape(orig.gsub(/\r/, ""))
|
|
60
93
|
end
|
|
61
94
|
|
|
62
95
|
# Checks if the other translation target is mergeable with
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
#
|
|
12
12
|
# DO NOT MODIFY!!!!
|
|
13
|
-
# This file is automatically generated by Racc 1.4.
|
|
13
|
+
# This file is automatically generated by Racc 1.4.9
|
|
14
14
|
# from Racc grammer file "".
|
|
15
15
|
#
|
|
16
16
|
|
|
@@ -18,7 +18,7 @@ require 'racc/parser.rb'
|
|
|
18
18
|
module GetText
|
|
19
19
|
class PoParser < Racc::Parser
|
|
20
20
|
|
|
21
|
-
module_eval(<<'...end poparser.ry/module_eval...', 'poparser.ry',
|
|
21
|
+
module_eval(<<'...end poparser.ry/module_eval...', 'poparser.ry', 119)
|
|
22
22
|
if GetText.respond_to?(:bindtextdomain)
|
|
23
23
|
include GetText
|
|
24
24
|
GetText.bindtextdomain("rgettext")
|
|
@@ -123,10 +123,9 @@ module_eval(<<'...end poparser.ry/module_eval...', 'poparser.ry', 114)
|
|
|
123
123
|
end
|
|
124
124
|
|
|
125
125
|
def on_message(msgid, msgstr)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
end
|
|
126
|
+
@data[msgid] = msgstr
|
|
127
|
+
@data.set_comment(msgid, @comments.join("\n"))
|
|
128
|
+
|
|
130
129
|
@comments.clear
|
|
131
130
|
@msgctxt = ""
|
|
132
131
|
end
|
|
@@ -279,7 +278,7 @@ Racc_debug_parser = true
|
|
|
279
278
|
|
|
280
279
|
# reduce 4 omitted
|
|
281
280
|
|
|
282
|
-
module_eval(<<'.,.,', 'poparser.ry',
|
|
281
|
+
module_eval(<<'.,.,', 'poparser.ry', 26)
|
|
283
282
|
def _reduce_5(val, _values, result)
|
|
284
283
|
@msgctxt = unescape(val[1]) + "\004"
|
|
285
284
|
|
|
@@ -291,30 +290,34 @@ module_eval(<<'.,.,', 'poparser.ry', 25)
|
|
|
291
290
|
|
|
292
291
|
# reduce 7 omitted
|
|
293
292
|
|
|
294
|
-
module_eval(<<'.,.,', 'poparser.ry',
|
|
293
|
+
module_eval(<<'.,.,', 'poparser.ry', 38)
|
|
295
294
|
def _reduce_8(val, _values, result)
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
295
|
+
msgid_raw = val[1]
|
|
296
|
+
msgid = unescape(msgid_raw)
|
|
297
|
+
msgstr = unescape(val[3])
|
|
298
|
+
use_message_p = true
|
|
299
|
+
if @fuzzy and not msgid.empty?
|
|
300
|
+
use_message_p = (not ignore_fuzzy?)
|
|
301
|
+
if report_warning?
|
|
302
|
+
if ignore_fuzzy?
|
|
299
303
|
$stderr.print _("Warning: fuzzy message was ignored.\n")
|
|
300
|
-
|
|
304
|
+
else
|
|
305
|
+
$stderr.print _("Warning: fuzzy message was used.\n")
|
|
301
306
|
end
|
|
302
|
-
|
|
303
|
-
on_message('', unescape(val[3]))
|
|
307
|
+
$stderr.print " #{@po_file}: msgid '#{msgid_raw}'\n"
|
|
304
308
|
end
|
|
305
|
-
@fuzzy = false
|
|
306
|
-
else
|
|
307
|
-
on_message(@msgctxt + unescape(val[1]), unescape(val[3]))
|
|
308
309
|
end
|
|
310
|
+
@fuzzy = false
|
|
311
|
+
on_message(@msgctxt + msgid, msgstr) if use_message_p
|
|
309
312
|
result = ""
|
|
310
313
|
|
|
311
314
|
result
|
|
312
315
|
end
|
|
313
316
|
.,.,
|
|
314
317
|
|
|
315
|
-
module_eval(<<'.,.,', 'poparser.ry',
|
|
318
|
+
module_eval(<<'.,.,', 'poparser.ry', 61)
|
|
316
319
|
def _reduce_9(val, _values, result)
|
|
317
|
-
if @fuzzy and
|
|
320
|
+
if @fuzzy and ignore_fuzzy?
|
|
318
321
|
if val[1] != ""
|
|
319
322
|
if report_warning?
|
|
320
323
|
$stderr.print _("Warning: fuzzy message was ignored.\n")
|
|
@@ -333,7 +336,7 @@ module_eval(<<'.,.,', 'poparser.ry', 56)
|
|
|
333
336
|
end
|
|
334
337
|
.,.,
|
|
335
338
|
|
|
336
|
-
module_eval(<<'.,.,', 'poparser.ry',
|
|
339
|
+
module_eval(<<'.,.,', 'poparser.ry', 81)
|
|
337
340
|
def _reduce_10(val, _values, result)
|
|
338
341
|
if val[0].size > 0
|
|
339
342
|
result = val[0] + "\000" + val[1]
|
|
@@ -347,7 +350,7 @@ module_eval(<<'.,.,', 'poparser.ry', 76)
|
|
|
347
350
|
|
|
348
351
|
# reduce 11 omitted
|
|
349
352
|
|
|
350
|
-
module_eval(<<'.,.,', 'poparser.ry',
|
|
353
|
+
module_eval(<<'.,.,', 'poparser.ry', 93)
|
|
351
354
|
def _reduce_12(val, _values, result)
|
|
352
355
|
result = val[2]
|
|
353
356
|
|
|
@@ -355,7 +358,7 @@ module_eval(<<'.,.,', 'poparser.ry', 88)
|
|
|
355
358
|
end
|
|
356
359
|
.,.,
|
|
357
360
|
|
|
358
|
-
module_eval(<<'.,.,', 'poparser.ry',
|
|
361
|
+
module_eval(<<'.,.,', 'poparser.ry', 100)
|
|
359
362
|
def _reduce_13(val, _values, result)
|
|
360
363
|
on_comment(val[0])
|
|
361
364
|
|
|
@@ -363,7 +366,7 @@ module_eval(<<'.,.,', 'poparser.ry', 95)
|
|
|
363
366
|
end
|
|
364
367
|
.,.,
|
|
365
368
|
|
|
366
|
-
module_eval(<<'.,.,', 'poparser.ry',
|
|
369
|
+
module_eval(<<'.,.,', 'poparser.ry', 108)
|
|
367
370
|
def _reduce_14(val, _values, result)
|
|
368
371
|
result = val.delete_if{|item| item == ""}.join
|
|
369
372
|
|
|
@@ -371,7 +374,7 @@ module_eval(<<'.,.,', 'poparser.ry', 103)
|
|
|
371
374
|
end
|
|
372
375
|
.,.,
|
|
373
376
|
|
|
374
|
-
module_eval(<<'.,.,', 'poparser.ry',
|
|
377
|
+
module_eval(<<'.,.,', 'poparser.ry', 112)
|
|
375
378
|
def _reduce_15(val, _values, result)
|
|
376
379
|
result = val[0]
|
|
377
380
|
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2012 Haruka Yoshihara <yoshihara@clear-code.com>
|
|
4
|
+
# Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
|
|
5
|
+
# Copyright (C) 2003-2010 Masao Mutoh
|
|
6
|
+
# Copyright (C) 2001,2002 Yasushi Shoji, Masao Mutoh
|
|
7
|
+
#
|
|
8
|
+
# License: Ruby's or LGPL
|
|
9
|
+
#
|
|
10
|
+
# This library is free software: you can redistribute it and/or modify
|
|
11
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
|
12
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
13
|
+
# (at your option) any later version.
|
|
14
|
+
#
|
|
15
|
+
# This library is distributed in the hope that it will be useful,
|
|
16
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
18
|
+
# GNU Lesser General Public License for more details.
|
|
19
|
+
#
|
|
20
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
21
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
22
|
+
|
|
23
|
+
require "pathname"
|
|
24
|
+
require "optparse"
|
|
25
|
+
require "gettext"
|
|
26
|
+
|
|
27
|
+
module GetText
|
|
28
|
+
module Tools
|
|
29
|
+
class XGetText #:nodoc:
|
|
30
|
+
class << self
|
|
31
|
+
def run(*arguments)
|
|
32
|
+
new.run(*arguments)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
include GetText
|
|
37
|
+
|
|
38
|
+
bindtextdomain("rgettext")
|
|
39
|
+
|
|
40
|
+
def initialize #:nodoc:
|
|
41
|
+
@ex_parsers = []
|
|
42
|
+
parsers = [
|
|
43
|
+
["glade.rb", "GladeParser"],
|
|
44
|
+
["erb.rb", "ErbParser"],
|
|
45
|
+
# ["ripper.rb", "RipperParser"],
|
|
46
|
+
["ruby.rb", "RubyParser"] # Default parser.
|
|
47
|
+
]
|
|
48
|
+
parsers.each do |f, klass|
|
|
49
|
+
begin
|
|
50
|
+
require "gettext/tools/parser/#{f}"
|
|
51
|
+
@ex_parsers << GetText.const_get(klass)
|
|
52
|
+
rescue
|
|
53
|
+
$stderr.puts(_("'%{klass}' is ignored.") % {:klass => klass})
|
|
54
|
+
$stderr.puts($!) if $DEBUG
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
@input_files = nil
|
|
59
|
+
@output = nil
|
|
60
|
+
|
|
61
|
+
@package_name = nil
|
|
62
|
+
@package_version = nil
|
|
63
|
+
@msgid_bugs_address = nil
|
|
64
|
+
@copyright_holder = nil
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# How to add your option parser
|
|
68
|
+
# The option parser module requires to have target?(file) and
|
|
69
|
+
# parser(file, ary) method.
|
|
70
|
+
#
|
|
71
|
+
# require "gettext/tools/xgettext"
|
|
72
|
+
# module FooParser
|
|
73
|
+
# module_function
|
|
74
|
+
# def target?(file)
|
|
75
|
+
# File.extname(file) == ".foo" # *.foo file only.
|
|
76
|
+
# end
|
|
77
|
+
# def parse(file)
|
|
78
|
+
# :
|
|
79
|
+
# ary = []
|
|
80
|
+
# # Simple message
|
|
81
|
+
# po = PoMessage.new(:normal)
|
|
82
|
+
# po.msgid = "hello"
|
|
83
|
+
# po.sources = ["foo.rb:200", "bar.rb:300"]
|
|
84
|
+
# po.add_comment("Comment for the message")
|
|
85
|
+
# ary << po
|
|
86
|
+
# # Plural message
|
|
87
|
+
# po = PoMessage.new(:plural)
|
|
88
|
+
# po.msgid = "An apple"
|
|
89
|
+
# po.msgid_plural = "Apples"
|
|
90
|
+
# po.sources = ["foo.rb:200", "bar.rb:300"]
|
|
91
|
+
# ary << po
|
|
92
|
+
# # Simple message with the message context
|
|
93
|
+
# po = PoMessage.new(:msgctxt)
|
|
94
|
+
# po.msgctxt = "context"
|
|
95
|
+
# po.msgid = "hello"
|
|
96
|
+
# po.sources = ["foo.rb:200", "bar.rb:300"]
|
|
97
|
+
# ary << po
|
|
98
|
+
# # Plural message with the message context.
|
|
99
|
+
# po = PoMessage.new(:msgctxt_plural)
|
|
100
|
+
# po.msgctxt = "context"
|
|
101
|
+
# po.msgid = "An apple"
|
|
102
|
+
# po.msgid_plural = "Apples"
|
|
103
|
+
# po.sources = ["foo.rb:200", "bar.rb:300"]
|
|
104
|
+
# ary << po
|
|
105
|
+
# return ary
|
|
106
|
+
# end
|
|
107
|
+
# end
|
|
108
|
+
#
|
|
109
|
+
# GetText::XGetText.add_parser(FooParser)
|
|
110
|
+
def add_parser(klass)
|
|
111
|
+
@ex_parsers.insert(0, klass)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def generate_pot_header # :nodoc:
|
|
115
|
+
time = now.strftime("%Y-%m-%d %H:%M%z")
|
|
116
|
+
|
|
117
|
+
<<EOH
|
|
118
|
+
# SOME DESCRIPTIVE TITLE.
|
|
119
|
+
# Copyright (C) YEAR #{@copyright_holder}
|
|
120
|
+
# This file is distributed under the same license as the #{@package_name} package.
|
|
121
|
+
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
|
122
|
+
#
|
|
123
|
+
#, fuzzy
|
|
124
|
+
msgid ""
|
|
125
|
+
msgstr ""
|
|
126
|
+
"Project-Id-Version: #{@package_name} #{@package_version}\\n"
|
|
127
|
+
"Report-Msgid-Bugs-To: #{@msgid_bugs_address}\\n"
|
|
128
|
+
"POT-Creation-Date: #{time}\\n"
|
|
129
|
+
"PO-Revision-Date: #{time}\\n"
|
|
130
|
+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"
|
|
131
|
+
"Language-Team: LANGUAGE <LL@li.org>\\n"
|
|
132
|
+
"Language: \\n"
|
|
133
|
+
"MIME-Version: 1.0\\n"
|
|
134
|
+
"Content-Type: text/plain; charset=UTF-8\\n"
|
|
135
|
+
"Content-Transfer-Encoding: 8bit\\n"
|
|
136
|
+
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n"
|
|
137
|
+
EOH
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def generate_pot(paths) # :nodoc:
|
|
141
|
+
pomessages = parse(paths)
|
|
142
|
+
str = ""
|
|
143
|
+
pomessages.each do |target|
|
|
144
|
+
str << target.to_po_str
|
|
145
|
+
end
|
|
146
|
+
str
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def parse(paths) # :nodoc:
|
|
150
|
+
pomessages = []
|
|
151
|
+
paths = [paths] if paths.kind_of?(String)
|
|
152
|
+
paths.each do |path|
|
|
153
|
+
begin
|
|
154
|
+
@ex_parsers.each do |klass|
|
|
155
|
+
next unless klass.target?(path)
|
|
156
|
+
|
|
157
|
+
if klass.method(:parse).arity == 1
|
|
158
|
+
targets = klass.parse(path)
|
|
159
|
+
else
|
|
160
|
+
# For backward compatibility
|
|
161
|
+
targets = klass.parse(path, [])
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
targets.each do |pomessage|
|
|
165
|
+
if pomessage.kind_of?(Array)
|
|
166
|
+
pomessage = PoMessage.new_from_ary(pomessage)
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
if pomessage.msgid.empty?
|
|
170
|
+
warn _("Warning: The empty \"\" msgid is reserved by " +
|
|
171
|
+
"gettext. So gettext(\"\") doesn't returns " +
|
|
172
|
+
"empty string but the header entry in po file.")
|
|
173
|
+
# TODO: add pommesage.source to the pot header as below:
|
|
174
|
+
# # SOME DESCRIPTIVE TITLE.
|
|
175
|
+
# # Copyright (C) YEAR THE COPYRIGHT HOLDER
|
|
176
|
+
# # This file is distributed under the same license as the PACKAGE package.
|
|
177
|
+
# # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
|
178
|
+
# #
|
|
179
|
+
# #: test/test_gettext.rb:65
|
|
180
|
+
# #, fuzzy
|
|
181
|
+
# "#: test/test_gettext.rb:65" line is added.
|
|
182
|
+
next
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
if @output.is_a?(String)
|
|
186
|
+
base_path = Pathname.new(@output).dirname.expand_path
|
|
187
|
+
pomessage.sources = pomessage.sources.collect do |source|
|
|
188
|
+
path, line, = source.split(/:(\d+)\z/, 2)
|
|
189
|
+
absolute_path = Pathname.new(path).expand_path
|
|
190
|
+
begin
|
|
191
|
+
path = absolute_path.relative_path_from(base_path).to_s
|
|
192
|
+
rescue ArgumentError
|
|
193
|
+
raise # Should we ignore it?
|
|
194
|
+
end
|
|
195
|
+
"#{path}:#{line}"
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
# Save the previous target
|
|
200
|
+
if pomessages.empty?
|
|
201
|
+
existing = nil
|
|
202
|
+
else
|
|
203
|
+
message = pomessages.find {|t| t == pomessage}
|
|
204
|
+
existing = pomessages.index(message)
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
if existing
|
|
208
|
+
pomessage = pomessages[existing].merge(pomessage)
|
|
209
|
+
pomessages[existing] = pomessage
|
|
210
|
+
else
|
|
211
|
+
pomessages << pomessage
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
break
|
|
215
|
+
end
|
|
216
|
+
rescue
|
|
217
|
+
puts(_("Error parsing %{path}") % {:path => path})
|
|
218
|
+
raise
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
pomessages
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
# constant values
|
|
225
|
+
VERSION = GetText::VERSION
|
|
226
|
+
|
|
227
|
+
def check_command_line_options(*options) # :nodoc:
|
|
228
|
+
input_files, output = parse_arguments(*options)
|
|
229
|
+
|
|
230
|
+
if input_files.empty?
|
|
231
|
+
raise ArgumentError, _("no input files")
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
output ||= STDOUT
|
|
235
|
+
|
|
236
|
+
@input_files = input_files
|
|
237
|
+
@output = output
|
|
238
|
+
|
|
239
|
+
@package_name ||= "PACKAGE"
|
|
240
|
+
@package_version ||= "VERSION"
|
|
241
|
+
@msgid_bugs_address ||= ""
|
|
242
|
+
@copyright_holder ||= "THE PACKAGE'S COPYRIGHT HOLDER"
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
def parse_arguments(*options) #:nodoc:
|
|
246
|
+
output = nil
|
|
247
|
+
|
|
248
|
+
parser = OptionParser.new
|
|
249
|
+
banner = _("Usage: %s input.rb [-r parser.rb] [-o output.pot]") % $0
|
|
250
|
+
parser.banner = banner
|
|
251
|
+
parser.separator("")
|
|
252
|
+
description = _("Extract translatable strings from given input files.")
|
|
253
|
+
parser.separator(description)
|
|
254
|
+
parser.separator("")
|
|
255
|
+
parser.separator(_("Specific options:"))
|
|
256
|
+
|
|
257
|
+
parser.on("-o", "--output=FILE",
|
|
258
|
+
_("write output to specified file")) do |out|
|
|
259
|
+
output = out
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
parser.on("--package-name=PACKAGE",
|
|
263
|
+
_("set package name in output")) do |out|
|
|
264
|
+
@package_name = out
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
parser.on("--package-version=VERSION",
|
|
268
|
+
_("set package version in output")) do |out|
|
|
269
|
+
@package_version = out
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
parser.on("--msgid-bugs-address=EMAIL",
|
|
273
|
+
_("set report address for msgid bugs")) do |out|
|
|
274
|
+
@msgid_bugs_address = out
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
parser.on("--copyright-holder=STRING",
|
|
278
|
+
_("set copyright holder in output")) do |out|
|
|
279
|
+
@copyright_holder = out
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
parser.on("-r", "--require=library",
|
|
283
|
+
_("require the library before executing xgettext")) do |out|
|
|
284
|
+
require out
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
parser.on("-d", "--debug", _("run in debugging mode")) do
|
|
288
|
+
$DEBUG = true
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
parser.on("-h", "--help", _("display this help and exit")) do
|
|
292
|
+
puts(parser.help)
|
|
293
|
+
exit(true)
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
parser.on_tail("--version", _("display version information and exit")) do
|
|
297
|
+
puts(VERSION)
|
|
298
|
+
exit(true)
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
parser.parse!(options)
|
|
302
|
+
|
|
303
|
+
[options, output]
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
def run(*options) # :nodoc:
|
|
307
|
+
check_command_line_options(*options)
|
|
308
|
+
|
|
309
|
+
if @output.is_a?(String)
|
|
310
|
+
File.open(File.expand_path(@output), "w+") do |file|
|
|
311
|
+
file.puts(generate_pot_header)
|
|
312
|
+
file.puts(generate_pot(@input_files))
|
|
313
|
+
end
|
|
314
|
+
else
|
|
315
|
+
@output.puts(generate_pot_header)
|
|
316
|
+
@output.puts(generate_pot(@input_files))
|
|
317
|
+
end
|
|
318
|
+
self
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
private
|
|
322
|
+
def now
|
|
323
|
+
Time.now
|
|
324
|
+
end
|
|
325
|
+
end
|
|
326
|
+
end
|
|
327
|
+
end
|