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
data/lib/gettext/tools.rb
CHANGED
|
@@ -1,23 +1,34 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
|
|
4
|
+
# Copyright (C) 2005-2008 Masao Mutoh
|
|
5
|
+
#
|
|
6
|
+
# License: Ruby's or LGPL
|
|
7
|
+
#
|
|
8
|
+
# This library is free software: you can redistribute it and/or modify
|
|
9
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
|
10
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
# (at your option) any later version.
|
|
12
|
+
#
|
|
13
|
+
# This library is distributed in the hope that it will be useful,
|
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
# GNU Lesser General Public License for more details.
|
|
17
|
+
#
|
|
18
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
19
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
11
20
|
|
|
12
21
|
require 'rbconfig'
|
|
13
22
|
if /mingw|mswin|mswin32/ =~ RUBY_PLATFORM
|
|
14
23
|
ENV['PATH'] = %w(bin lib).collect{|dir|
|
|
15
|
-
"#{
|
|
24
|
+
"#{::RbConfig::CONFIG["prefix"]}\\lib\\GTK\\#{dir};"
|
|
16
25
|
}.join('') + ENV['PATH']
|
|
17
26
|
end
|
|
18
27
|
|
|
19
|
-
require 'gettext/tools/
|
|
20
|
-
require 'gettext/tools/
|
|
28
|
+
require 'gettext/tools/xgettext'
|
|
29
|
+
require 'gettext/tools/msgfmt'
|
|
30
|
+
require 'gettext/tools/msginit'
|
|
31
|
+
require 'gettext/tools/msgmerge'
|
|
21
32
|
require 'gettext/runtime/mofile'
|
|
22
33
|
require 'fileutils'
|
|
23
34
|
|
|
@@ -45,7 +56,7 @@ module GetText
|
|
|
45
56
|
# but extracted comments and file positions will be discarded.
|
|
46
57
|
#
|
|
47
58
|
# The ref.pot file is the last created PO file with up-to-date source references but
|
|
48
|
-
# old translations, or a PO Template file (generally created by
|
|
59
|
+
# old translations, or a PO Template file (generally created by rxgettext);
|
|
49
60
|
# any translations or comments in the file will be discarded, however dot
|
|
50
61
|
# comments and file positions will be preserved. Where an exact match
|
|
51
62
|
# cannot be found, fuzzy matching is used to produce better results.
|
|
@@ -95,21 +106,23 @@ module GetText
|
|
|
95
106
|
mo_file = mo_file_from_po_file(po_file,options)
|
|
96
107
|
$stderr.print %Q[#{po_file} -> #{mo_file} ... ] if options[:verbose]
|
|
97
108
|
FileUtils.mkdir_p(File.dirname(mo_file))
|
|
98
|
-
|
|
109
|
+
Tools::MsgFmt.run(po_file, "-o", mo_file)
|
|
99
110
|
$stderr.puts "Done." if options[:verbose]
|
|
100
111
|
end
|
|
101
112
|
end
|
|
102
113
|
|
|
103
114
|
|
|
104
|
-
# At first, this creates the #{po_root}/#{domainname}.pot file using
|
|
105
|
-
# In the second step, this updates(merges)
|
|
106
|
-
# #{po_root}/#{
|
|
115
|
+
# At first, this creates the #{po_root}/#{domainname}.pot file using
|
|
116
|
+
# GetText::XGetText.run. In the second step, this updates(merges)
|
|
117
|
+
# the #{po_root}/#{domainname}.pot and all of the
|
|
118
|
+
# #{po_root}/#{lang}/#{domainname}.po files under "po_root" using
|
|
119
|
+
# "msgmerge".
|
|
107
120
|
#
|
|
108
121
|
# *Note* "msgmerge" tool is included in GNU GetText. So you need to install GNU GetText.
|
|
109
122
|
#
|
|
110
123
|
# See <HOWTO maintain po/mo files(http://www.yotabanana.com/hiki/ruby-gettext-howto-manage.html)> for more detals.
|
|
111
124
|
# * domainname: the textdomain name.
|
|
112
|
-
# * targetfiles: An Array of target files, that should be parsed for messages (See GetText.
|
|
125
|
+
# * targetfiles: An Array of target files, that should be parsed for messages (See GetText::XGetText.run for more details).
|
|
113
126
|
# * app_version: the application information which appears "Project-Id-Version: #{app_version}" in the pot/po-files.
|
|
114
127
|
# * options: a hash with following possible settings
|
|
115
128
|
# :lang - update files only for one language - the language specified by this option
|
|
@@ -125,7 +138,7 @@ module GetText
|
|
|
125
138
|
|
|
126
139
|
#write found messages to tmp.pot
|
|
127
140
|
temp_pot = "tmp.pot"
|
|
128
|
-
|
|
141
|
+
Tools::XGetText.run("-o", temp_pot, *files)
|
|
129
142
|
|
|
130
143
|
#merge tmp.pot and existing pot
|
|
131
144
|
po_root = options.delete(:po_root) || "po"
|
|
@@ -191,7 +204,3 @@ module GetText
|
|
|
191
204
|
File.join(mo_dir, "#{textdomain}.mo")
|
|
192
205
|
end
|
|
193
206
|
end
|
|
194
|
-
|
|
195
|
-
if __FILE__ == $0
|
|
196
|
-
GetText.update_pofiles("foo", ARGV, "foo 1.1.0")
|
|
197
|
-
end
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
|
|
4
|
+
# Copyright (C) 2012 Haruka Yoshihara <yoshihara@clear-code.com>
|
|
5
|
+
# Copyright (C) 2003-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/>.
|
|
21
|
+
|
|
22
|
+
require "optparse"
|
|
23
|
+
require "fileutils"
|
|
24
|
+
require "gettext"
|
|
25
|
+
require "gettext/tools/poparser"
|
|
26
|
+
|
|
27
|
+
module GetText
|
|
28
|
+
module Tools
|
|
29
|
+
class MsgFmt #:nodoc:
|
|
30
|
+
# Create a mo-file from a target file(po-file).
|
|
31
|
+
# You must specify a path of a target file in arguments.
|
|
32
|
+
# If a path of a mo-file is not specified in arguments, a mo-file is
|
|
33
|
+
# created as "messages.mo" in the current directory.
|
|
34
|
+
# @param [Array<String>] arguments arguments for rmsgfmt.
|
|
35
|
+
# @return [void]
|
|
36
|
+
class << self
|
|
37
|
+
def run(*arguments)
|
|
38
|
+
new.run(*arguments)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
include GetText
|
|
43
|
+
|
|
44
|
+
bindtextdomain("rgettext")
|
|
45
|
+
|
|
46
|
+
def initialize
|
|
47
|
+
@input_file = nil
|
|
48
|
+
@output_file = nil
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def run(*options) # :nodoc:
|
|
52
|
+
initialize_arguments(*options)
|
|
53
|
+
|
|
54
|
+
parser = PoParser.new
|
|
55
|
+
data = MoFile.new
|
|
56
|
+
|
|
57
|
+
parser.parse_file(@input_file, data)
|
|
58
|
+
data.save_to_file(@output_file)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def initialize_arguments(*options) # :nodoc:
|
|
62
|
+
input_file, output_file = parse_commandline_options(*options)
|
|
63
|
+
|
|
64
|
+
if input_file.nil?
|
|
65
|
+
raise(ArgumentError, _("no input files specified."))
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
if output_file.nil?
|
|
69
|
+
output_file = "messages.mo"
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
@input_file = input_file
|
|
73
|
+
@output_file = output_file
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def parse_commandline_options(*options)
|
|
77
|
+
output_file = nil
|
|
78
|
+
|
|
79
|
+
parser = OptionParser.new
|
|
80
|
+
parser.banner = _("Usage: %s input.po [-o output.mo]" % $0)
|
|
81
|
+
parser.separator("")
|
|
82
|
+
description = _("Generate binary message catalog from textual " +
|
|
83
|
+
"translation description.")
|
|
84
|
+
parser.separator(description)
|
|
85
|
+
parser.separator("")
|
|
86
|
+
parser.separator(_("Specific options:"))
|
|
87
|
+
|
|
88
|
+
parser.on("-o", "--output=FILE",
|
|
89
|
+
_("write output to specified file")) do |out|
|
|
90
|
+
output_file = out
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
parser.on_tail("--version", _("display version information and exit")) do
|
|
94
|
+
puts(VERSION)
|
|
95
|
+
exit(true)
|
|
96
|
+
end
|
|
97
|
+
parser.parse!(options)
|
|
98
|
+
|
|
99
|
+
input_file = options[0]
|
|
100
|
+
[input_file, output_file]
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
@@ -0,0 +1,363 @@
|
|
|
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
|
+
#
|
|
6
|
+
# License: Ruby's or LGPL
|
|
7
|
+
#
|
|
8
|
+
# This library is free software: you can redistribute it and/or modify
|
|
9
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
|
10
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
# (at your option) any later version.
|
|
12
|
+
#
|
|
13
|
+
# This library is distributed in the hope that it will be useful,
|
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
# GNU Lesser General Public License for more details.
|
|
17
|
+
#
|
|
18
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
19
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
|
|
21
|
+
require "gettext"
|
|
22
|
+
require "gettext/tools/poparser"
|
|
23
|
+
require "gettext/tools/msgmerge"
|
|
24
|
+
require "locale/info"
|
|
25
|
+
require "optparse"
|
|
26
|
+
|
|
27
|
+
module GetText
|
|
28
|
+
module Tools
|
|
29
|
+
class MsgInit
|
|
30
|
+
class Error < StandardError
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
class ArgumentError < Error
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
class ValidationError < Error
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
class << self
|
|
40
|
+
# Create a new .po file from initializing .pot file with user's
|
|
41
|
+
# environment and input.
|
|
42
|
+
# @param [Array<String>] arguments arguments for rmsginit.
|
|
43
|
+
# @return [void]
|
|
44
|
+
def run(*arguments)
|
|
45
|
+
new.run(*arguments)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
include GetText
|
|
50
|
+
|
|
51
|
+
bindtextdomain("rgettext")
|
|
52
|
+
|
|
53
|
+
def initialize #:nodoc:
|
|
54
|
+
@input_file = nil
|
|
55
|
+
@output_file = nil
|
|
56
|
+
@locale = nil
|
|
57
|
+
@language = nil
|
|
58
|
+
@entry = nil
|
|
59
|
+
@comment = nil
|
|
60
|
+
@translator = nil
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Create .po file from .pot file, user's inputs and metadata.
|
|
64
|
+
# @param [Array] arguments the list of arguments for rmsginit
|
|
65
|
+
def run(*arguments)
|
|
66
|
+
parse_arguments(*arguments)
|
|
67
|
+
validate
|
|
68
|
+
|
|
69
|
+
parser = PoParser.new
|
|
70
|
+
parser.ignore_fuzzy = false
|
|
71
|
+
pot = parser.parse_file(@input_file,
|
|
72
|
+
GetText::Tools::MsgMerge::PoData.new)
|
|
73
|
+
po = replace_pot_header(pot)
|
|
74
|
+
|
|
75
|
+
File.open(@output_file, "w") do |f|
|
|
76
|
+
f.puts(po.generate_po)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
private
|
|
81
|
+
VERSION = GetText::VERSION
|
|
82
|
+
|
|
83
|
+
def parse_arguments(*arguments) #:nodoc:
|
|
84
|
+
parser = OptionParser.new
|
|
85
|
+
description = _("Create a new .po file from initializing .pot " +
|
|
86
|
+
"file with user's environment and input.")
|
|
87
|
+
parser.separator(description)
|
|
88
|
+
parser.separator("")
|
|
89
|
+
parser.separator(_("Specific options:"))
|
|
90
|
+
|
|
91
|
+
input_description = _("Use INPUT as a .pot file. If INPUT is not " +
|
|
92
|
+
"specified, INPUT is a .pot file existing " +
|
|
93
|
+
"the current directory.")
|
|
94
|
+
parser.on("-i", "--input=FILE", input_description) do |input|
|
|
95
|
+
@input_file = input
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
output_description = _("Use OUTPUT as a created .po file. If OUTPUT " +
|
|
99
|
+
"is not specified, OUTPUT depend on LOCALE " +
|
|
100
|
+
"or the current locale on your environment.")
|
|
101
|
+
parser.on("-o", "--output=OUTPUT", output_description) do |output|
|
|
102
|
+
@output_file = output
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
locale_description = _("Use LOCALE as target locale. If LOCALE is " +
|
|
106
|
+
"not specified, LOCALE is the current " +
|
|
107
|
+
"locale on your environment.")
|
|
108
|
+
parser.on("-l", "--locale=LOCALE", locale_description) do |loc|
|
|
109
|
+
@locale = loc
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
parser.on("-h", "--help", _("Dispray this help and exit")) do
|
|
113
|
+
puts(parser.help)
|
|
114
|
+
exit(true)
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
version_description = _("Display version and exit")
|
|
118
|
+
parser.on_tail("-v", "--version", version_description) do
|
|
119
|
+
puts(VERSION)
|
|
120
|
+
exit(true)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
begin
|
|
124
|
+
parser.parse!(arguments)
|
|
125
|
+
rescue OptionParser::ParseError
|
|
126
|
+
raise(ArgumentError, $!.message)
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def validate
|
|
131
|
+
if @input_file.nil?
|
|
132
|
+
@input_file = Dir.glob("./*.pot").first
|
|
133
|
+
if @input_file.nil?
|
|
134
|
+
raise(ValidationError,
|
|
135
|
+
_(".pot file does not exist in the current directory."))
|
|
136
|
+
end
|
|
137
|
+
else
|
|
138
|
+
unless File.exist?(@input_file)
|
|
139
|
+
raise(ValidationError,
|
|
140
|
+
_("file #{@input_file} does not exist."))
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
if @locale.nil?
|
|
145
|
+
language_tag = Locale.current
|
|
146
|
+
else
|
|
147
|
+
language_tag = Locale::Tag.parse(@locale)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
unless valid_locale?(language_tag)
|
|
151
|
+
raise(ValidationError,
|
|
152
|
+
_("Locale '#{language_tag}' is invalid. " +
|
|
153
|
+
"Please check if your specified locale is usable."))
|
|
154
|
+
end
|
|
155
|
+
@locale = language_tag.to_simple.to_s
|
|
156
|
+
@language = language_tag.language
|
|
157
|
+
|
|
158
|
+
@output_file ||= "#{@locale}.po"
|
|
159
|
+
if File.exist?(@output_file)
|
|
160
|
+
raise(ValidationError,
|
|
161
|
+
_("file #{@output_file} has already existed."))
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def valid_locale?(language_tag)
|
|
166
|
+
return false if language_tag.instance_of?(Locale::Tag::Irregular)
|
|
167
|
+
|
|
168
|
+
Locale::Info.language_code?(language_tag.language)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def replace_pot_header(pot) #:nodoc:
|
|
172
|
+
@entry = pot[""]
|
|
173
|
+
@comment = pot.comment("")
|
|
174
|
+
@translator = translator_info
|
|
175
|
+
|
|
176
|
+
replace_entry
|
|
177
|
+
replace_comment
|
|
178
|
+
|
|
179
|
+
pot[""] = @entry.chomp
|
|
180
|
+
pot.set_comment("", @comment)
|
|
181
|
+
pot
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def translator_info
|
|
185
|
+
full_name = translator_full_name
|
|
186
|
+
mail = translator_mail
|
|
187
|
+
if not full_name.nil? and not mail.nil?
|
|
188
|
+
"#{full_name} <#{mail}>"
|
|
189
|
+
else
|
|
190
|
+
nil
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def translator_full_name
|
|
195
|
+
read_translator_full_name
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
def read_translator_full_name #:nodoc:
|
|
199
|
+
prompt(_("Please enter your full name"), guess_full_name)
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def guess_full_name
|
|
203
|
+
ENV["USERNAME"]
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def translator_mail
|
|
207
|
+
read_translator_mail
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
def read_translator_mail #:nodoc:
|
|
211
|
+
prompt(_("Please enter your email address"), guess_mail)
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
def guess_mail
|
|
215
|
+
ENV["EMAIL"]
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
def prompt(message, default)
|
|
219
|
+
print(message)
|
|
220
|
+
print(" [#{default}]") if default
|
|
221
|
+
print(": ")
|
|
222
|
+
|
|
223
|
+
user_input = $stdin.gets.chomp
|
|
224
|
+
if user_input.empty?
|
|
225
|
+
default
|
|
226
|
+
else
|
|
227
|
+
user_input
|
|
228
|
+
end
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
def replace_entry
|
|
232
|
+
replace_last_translator
|
|
233
|
+
replace_pot_revision_date
|
|
234
|
+
replace_language
|
|
235
|
+
replace_plural_forms
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
def replace_comment
|
|
239
|
+
replace_description
|
|
240
|
+
replace_first_author
|
|
241
|
+
replace_copyright_year
|
|
242
|
+
@comment = @comment.gsub(/#, fuzzy/, "")
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
EMAIL = "EMAIL@ADDRESS"
|
|
246
|
+
FIRST_AUTHOR_KEY = /^(\s*#\s*) FIRST AUTHOR <#{EMAIL}>, (\d+\.)$/
|
|
247
|
+
|
|
248
|
+
def replace_last_translator #:nodoc:
|
|
249
|
+
unless @translator.nil?
|
|
250
|
+
@entry = @entry.gsub(LAST_TRANSLATOR_KEY, "\\1 #{@translator}")
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
POT_REVISION_DATE_KEY = /^(PO-Revision-Date:).+/
|
|
255
|
+
|
|
256
|
+
def replace_pot_revision_date #:nodoc:
|
|
257
|
+
date = Time.now
|
|
258
|
+
revision_date = date.strftime("%Y-%m-%d %H:%M%z")
|
|
259
|
+
|
|
260
|
+
@entry = @entry.gsub(POT_REVISION_DATE_KEY,
|
|
261
|
+
"\\1 #{revision_date}")
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
LANGUAGE_KEY = /^(Language:).+/
|
|
265
|
+
LANGUAGE_TEAM_KEY = /^(Language-Team:).+/
|
|
266
|
+
|
|
267
|
+
def replace_language #:nodoc:
|
|
268
|
+
language_name = Locale::Info.get_language(@language).name
|
|
269
|
+
@entry = @entry.gsub(LANGUAGE_KEY, "\\1 #{@locale}")
|
|
270
|
+
@entry = @entry.gsub(LANGUAGE_TEAM_KEY, "\\1 #{language_name}")
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
PLURAL_FORMS =
|
|
274
|
+
/^(Plural-Forms:) nplurals=INTEGER; plural=EXPRESSION;$/
|
|
275
|
+
|
|
276
|
+
def replace_plural_forms #:nodoc:
|
|
277
|
+
@entry = @entry.gsub(PLURAL_FORMS, "\\1 #{plural_forms(@language)}")
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
def plural_forms(language) #:nodoc:
|
|
281
|
+
case language
|
|
282
|
+
when "ja", "vi", "ko"
|
|
283
|
+
nplural = "1"
|
|
284
|
+
plural_expression = "0"
|
|
285
|
+
when "en", "de", "nl", "sv", "da", "no", "fo", "es", "pt",
|
|
286
|
+
"it", "bg", "el", "fi", "et", "he", "eo", "hu", "tr"
|
|
287
|
+
nplural = "2"
|
|
288
|
+
plural_expression = "n != 1"
|
|
289
|
+
when "pt_BR", "fr"
|
|
290
|
+
nplural = "2"
|
|
291
|
+
plural_expression = "n>1"
|
|
292
|
+
when "lv"
|
|
293
|
+
nplural = "3"
|
|
294
|
+
plural_expression = "n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2"
|
|
295
|
+
when "ga"
|
|
296
|
+
nplural = "3"
|
|
297
|
+
plural_expression = "n==1 ? 0 : n==2 ? 1 : 2"
|
|
298
|
+
when "ro"
|
|
299
|
+
nplural = "3"
|
|
300
|
+
plural_expression = "n==1 ? 0 : " +
|
|
301
|
+
"(n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2"
|
|
302
|
+
when "lt"
|
|
303
|
+
nplural = "3"
|
|
304
|
+
plural_expression = "n%10==1 && n%100!=11 ? 0 : " +
|
|
305
|
+
"n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2"
|
|
306
|
+
when "ru", "uk", "sr", "hr"
|
|
307
|
+
nplural = "3"
|
|
308
|
+
plural_expression = "n%10==1 && n%100!=11 ? 0 : n%10>=2 && " +
|
|
309
|
+
"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2"
|
|
310
|
+
when "cs", "sk"
|
|
311
|
+
nplural = "3"
|
|
312
|
+
plural_expression = "(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2"
|
|
313
|
+
when "pl"
|
|
314
|
+
nplural = "3"
|
|
315
|
+
plural_expression = "n==1 ? 0 : n%10>=2 && " +
|
|
316
|
+
"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2"
|
|
317
|
+
when "sl"
|
|
318
|
+
nplural = "4"
|
|
319
|
+
plural_expression = "n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 " +
|
|
320
|
+
"|| n%100==4 ? 2 : 3"
|
|
321
|
+
else
|
|
322
|
+
nplural = nil
|
|
323
|
+
plural_expression = nil
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
"nplurals=#{nplural}; plural=#{plural_expression};"
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
DESCRIPTION_TITLE = /^(\s*#\s*) SOME DESCRIPTIVE TITLE\.$/
|
|
330
|
+
|
|
331
|
+
def replace_description #:nodoc:
|
|
332
|
+
language_name = Locale::Info.get_language(@language).name
|
|
333
|
+
package_name = ""
|
|
334
|
+
@entry.gsub(/Project-Id-Version: (.+?) .+/) do
|
|
335
|
+
package_name = $1
|
|
336
|
+
end
|
|
337
|
+
description = "#{language_name} translations " +
|
|
338
|
+
"for #{package_name} package."
|
|
339
|
+
@comment = @comment.gsub(DESCRIPTION_TITLE, "\\1 #{description}")
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
YEAR_KEY = /^(\s*#\s* FIRST AUTHOR <#{EMAIL}>,) YEAR\.$/
|
|
343
|
+
LAST_TRANSLATOR_KEY = /^(Last-Translator:) FULL NAME <#{EMAIL}>$/
|
|
344
|
+
|
|
345
|
+
def replace_first_author #:nodoc:
|
|
346
|
+
year = Time.now.year
|
|
347
|
+
|
|
348
|
+
@comment = @comment.gsub(YEAR_KEY, "\\1 #{year}.")
|
|
349
|
+
unless @translator.nil?
|
|
350
|
+
@comment = @comment.gsub(FIRST_AUTHOR_KEY,
|
|
351
|
+
"\\1 #{@translator}, \\2")
|
|
352
|
+
end
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
COPYRIGHT_KEY = /(\s*#\s* Copyright \(C\)) YEAR (THE PACKAGE'S COPYRIGHT HOLDER)$/
|
|
356
|
+
def replace_copyright_year #:nodoc:
|
|
357
|
+
date = Time.now
|
|
358
|
+
|
|
359
|
+
@comment = @comment.gsub(COPYRIGHT_KEY, "\\1 #{date.year} \\2")
|
|
360
|
+
end
|
|
361
|
+
end
|
|
362
|
+
end
|
|
363
|
+
end
|