gettext 2.2.1 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,510 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
|
4
|
+
# Copyright (C) 2005-2009 Masao Mutoh
|
5
|
+
# Copyright (C) 2005,2006 speakillof
|
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 "gettext"
|
24
|
+
require "gettext/tools/poparser"
|
25
|
+
require "gettext/tools/pomessage"
|
26
|
+
|
27
|
+
# TODO: MsgMerge should use PoMessage to generate PO content.
|
28
|
+
|
29
|
+
module GetText
|
30
|
+
module Tools
|
31
|
+
class MsgMerge
|
32
|
+
class PoData #:nodoc:
|
33
|
+
|
34
|
+
attr_reader :msgids
|
35
|
+
|
36
|
+
def initialize
|
37
|
+
@msgid2msgstr = {}
|
38
|
+
@msgid2comment = {}
|
39
|
+
@msgids = []
|
40
|
+
end
|
41
|
+
|
42
|
+
def set_comment(msgid_or_sym, comment)
|
43
|
+
@msgid2comment[msgid_or_sym] = comment
|
44
|
+
end
|
45
|
+
|
46
|
+
def msgstr(msgid)
|
47
|
+
@msgid2msgstr[msgid]
|
48
|
+
end
|
49
|
+
|
50
|
+
def comment(msgid)
|
51
|
+
@msgid2comment[msgid]
|
52
|
+
end
|
53
|
+
|
54
|
+
def [](msgid)
|
55
|
+
@msgid2msgstr[msgid]
|
56
|
+
end
|
57
|
+
|
58
|
+
def []=(msgid, msgstr)
|
59
|
+
# Retain the order
|
60
|
+
if @msgid2msgstr[msgid].nil?
|
61
|
+
@msgids << msgid
|
62
|
+
end
|
63
|
+
|
64
|
+
@msgid2msgstr[msgid] = msgstr
|
65
|
+
end
|
66
|
+
|
67
|
+
def each_msgid
|
68
|
+
msgids = @msgids.delete_if do |msgid|
|
69
|
+
msgid.kind_of?(Symbol) or msgid.empty?
|
70
|
+
end
|
71
|
+
|
72
|
+
msgids.each do |msgid|
|
73
|
+
yield(msgid)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def msgid?(msgid)
|
78
|
+
return false if msgid.kind_of?(Symbol)
|
79
|
+
return true if msgid.empty?
|
80
|
+
@msgid2msgstr.has_key?(msgid)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Is it necessary to implement this method?
|
84
|
+
def search_msgid_fuzzy(msgid, used_msgids)
|
85
|
+
nil
|
86
|
+
end
|
87
|
+
|
88
|
+
def nplurals
|
89
|
+
return 0 if @msgid2msgstr[""].nil?
|
90
|
+
|
91
|
+
if /\s*nplurals\s*=\s*(\d+)/ =~ @msgid2msgstr[""]
|
92
|
+
return $1.to_i
|
93
|
+
else
|
94
|
+
return 0
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def generate_po
|
99
|
+
str = ""
|
100
|
+
str << generate_po_header
|
101
|
+
|
102
|
+
po_entries = []
|
103
|
+
self.each_msgid do |id|
|
104
|
+
po_entries << self.generate_po_entry(id)
|
105
|
+
end
|
106
|
+
|
107
|
+
unless @msgid2comment[:last].nil?
|
108
|
+
po_entries << "#{@msgid2comment[:last]}\n"
|
109
|
+
end
|
110
|
+
|
111
|
+
str << po_entries.join("\n")
|
112
|
+
str
|
113
|
+
end
|
114
|
+
|
115
|
+
def generate_po_header
|
116
|
+
str = ""
|
117
|
+
|
118
|
+
str << @msgid2comment[""].strip << "\n"
|
119
|
+
str << 'msgid ""' << "\n"
|
120
|
+
str << 'msgstr ""' << "\n"
|
121
|
+
msgstr = @msgid2msgstr[""].gsub(/"/, '\"').gsub(/\r/, "")
|
122
|
+
msgstr = msgstr.gsub(/^(.*)$/, '"\1\n"')
|
123
|
+
str << msgstr
|
124
|
+
str << "\n"
|
125
|
+
|
126
|
+
str
|
127
|
+
end
|
128
|
+
|
129
|
+
def generate_po_entry(msgid)
|
130
|
+
str = ""
|
131
|
+
str << @msgid2comment[msgid]
|
132
|
+
if str[-1] != "\n"[0]
|
133
|
+
str << "\n"
|
134
|
+
end
|
135
|
+
|
136
|
+
id = msgid.gsub(/\r/, "")
|
137
|
+
msgstr = @msgid2msgstr[msgid].gsub(/\r/, "")
|
138
|
+
|
139
|
+
if id.include?("\004")
|
140
|
+
ids = id.split(/\004/)
|
141
|
+
context = ids[0]
|
142
|
+
id = ids[1]
|
143
|
+
str << "msgctxt " << __conv(context) << "\n"
|
144
|
+
end
|
145
|
+
|
146
|
+
if id.include?("\000")
|
147
|
+
ids = id.split(/\000/)
|
148
|
+
str << "msgid " << __conv(ids[0]) << "\n"
|
149
|
+
ids[1..-1].each do |single_id|
|
150
|
+
str << "msgid_plural " << __conv(single_id) << "\n"
|
151
|
+
end
|
152
|
+
|
153
|
+
msgstr.split("\000", -1).each_with_index do |m, n|
|
154
|
+
str << "msgstr[#{n}] " << __conv(m) << "\n"
|
155
|
+
end
|
156
|
+
else
|
157
|
+
str << "msgid " << __conv(id) << "\n"
|
158
|
+
str << "msgstr " << __conv(msgstr) << "\n"
|
159
|
+
end
|
160
|
+
|
161
|
+
str
|
162
|
+
end
|
163
|
+
|
164
|
+
def __conv(str)
|
165
|
+
s = ""
|
166
|
+
|
167
|
+
if str.count("\n") > 1
|
168
|
+
s << '""' << "\n"
|
169
|
+
str.each_line do |line|
|
170
|
+
s << '"' << escape(line) << '"' << "\n"
|
171
|
+
end
|
172
|
+
else
|
173
|
+
s << '"' << escape(str) << '"'
|
174
|
+
end
|
175
|
+
|
176
|
+
s.rstrip
|
177
|
+
end
|
178
|
+
|
179
|
+
def escape(string)
|
180
|
+
PoMessage.escape(string)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
class Merger #:nodoc:
|
185
|
+
# From GNU gettext source.
|
186
|
+
#
|
187
|
+
# Merge the reference with the definition: take the #. and
|
188
|
+
# #: comments from the reference, take the # comments from
|
189
|
+
# the definition, take the msgstr from the definition. Add
|
190
|
+
# this merged entry to the output message list.
|
191
|
+
|
192
|
+
DOT_COMMENT_RE = /\A#\./
|
193
|
+
SEMICOLON_COMMENT_RE = /\A#\:/
|
194
|
+
FUZZY_RE = /\A#\,/
|
195
|
+
NOT_SPECIAL_COMMENT_RE = /\A#([^:.,]|\z)/
|
196
|
+
|
197
|
+
CRLF_RE = /\r?\n/
|
198
|
+
POT_DATE_EXTRACT_RE = /POT-Creation-Date:\s*(.*)?\s*$/
|
199
|
+
POT_DATE_RE = /POT-Creation-Date:.*?$/
|
200
|
+
|
201
|
+
def merge(definition, reference)
|
202
|
+
# deep copy
|
203
|
+
result = Marshal.load( Marshal.dump(reference) )
|
204
|
+
|
205
|
+
used = []
|
206
|
+
merge_header(result, definition)
|
207
|
+
|
208
|
+
result.each_msgid do |msgid|
|
209
|
+
if definition.msgid?(msgid)
|
210
|
+
used << msgid
|
211
|
+
merge_message(msgid, result, msgid, definition)
|
212
|
+
elsif other_msgid = definition.search_msgid_fuzzy(msgid, used)
|
213
|
+
used << other_msgid
|
214
|
+
merge_fuzzy_message(msgid, result, other_msgid, definition)
|
215
|
+
elsif msgid.index("\000") and (reference.msgstr(msgid).gsub("\000", "").empty?)
|
216
|
+
# plural
|
217
|
+
result[msgid] = ([""] * definition.nplurals).join("\000")
|
218
|
+
else
|
219
|
+
change_reference_comment(msgid, result)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
###################################################################
|
224
|
+
# msgids which are not used in reference are handled as obsolete. #
|
225
|
+
###################################################################
|
226
|
+
last_comment = result.comment(:last) || ""
|
227
|
+
definition.each_msgid do |msgid|
|
228
|
+
unless used.include?(msgid)
|
229
|
+
last_comment << "\n"
|
230
|
+
last_comment << definition.generate_po_entry(msgid).strip.gsub(/^/, "#. ")
|
231
|
+
last_comment << "\n"
|
232
|
+
end
|
233
|
+
end
|
234
|
+
result.set_comment(:last, last_comment) unless last_comment.empty?
|
235
|
+
|
236
|
+
result
|
237
|
+
end
|
238
|
+
|
239
|
+
def merge_message(msgid, target, def_msgid, definition)
|
240
|
+
merge_comment(msgid, target, def_msgid, definition)
|
241
|
+
|
242
|
+
############################################
|
243
|
+
# check mismatch of msgid and msgid_plural #
|
244
|
+
############################################
|
245
|
+
def_msgstr = definition[def_msgid]
|
246
|
+
if msgid.index("\000")
|
247
|
+
if def_msgstr.index("\000")
|
248
|
+
# OK
|
249
|
+
target[msgid] = def_msgstr
|
250
|
+
else
|
251
|
+
# NG
|
252
|
+
strings = []
|
253
|
+
definition.nplurals.times do
|
254
|
+
strings << def_msgstr
|
255
|
+
end
|
256
|
+
target[msgid] = strings.join("\000")
|
257
|
+
end
|
258
|
+
else
|
259
|
+
if def_msgstr.index("\000")
|
260
|
+
# NG
|
261
|
+
target[msgid] = def_msgstr.split("\000")[0]
|
262
|
+
else
|
263
|
+
# OK
|
264
|
+
target[msgid] = def_msgstr
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
# for the future
|
270
|
+
def merge_fuzzy_message(msgid, target, def_msgid, definition)
|
271
|
+
merge_message(msgid, target, def_msgid, definition)
|
272
|
+
end
|
273
|
+
|
274
|
+
def merge_comment(msgid, target, def_msgid, definition)
|
275
|
+
ref_comment = target.comment(msgid)
|
276
|
+
def_comment = definition.comment(def_msgid)
|
277
|
+
|
278
|
+
normal_comment = []
|
279
|
+
dot_comment = []
|
280
|
+
semi_comment = []
|
281
|
+
is_fuzzy = false
|
282
|
+
|
283
|
+
def_comment.split(CRLF_RE).each do |l|
|
284
|
+
if NOT_SPECIAL_COMMENT_RE =~ l
|
285
|
+
normal_comment << l
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
ref_comment.split(CRLF_RE).each do |l|
|
290
|
+
if DOT_COMMENT_RE =~ l
|
291
|
+
dot_comment << l
|
292
|
+
elsif SEMICOLON_COMMENT_RE =~ l
|
293
|
+
semi_comment << l
|
294
|
+
elsif FUZZY_RE =~ l
|
295
|
+
is_fuzzy = true if msgid != ""
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
str = format_comment(normal_comment, dot_comment, semi_comment, is_fuzzy)
|
300
|
+
target.set_comment(msgid, str)
|
301
|
+
end
|
302
|
+
|
303
|
+
def change_reference_comment(msgid, podata)
|
304
|
+
normal_comment = []
|
305
|
+
dot_comment = []
|
306
|
+
semi_comment = []
|
307
|
+
is_fuzzy = false
|
308
|
+
|
309
|
+
podata.comment(msgid).split(CRLF_RE).each do |l|
|
310
|
+
if DOT_COMMENT_RE =~ l
|
311
|
+
dot_comment << l
|
312
|
+
elsif SEMICOLON_COMMENT_RE =~ l
|
313
|
+
semi_comment << l
|
314
|
+
elsif FUZZY_RE =~ l
|
315
|
+
is_fuzzy = true
|
316
|
+
else
|
317
|
+
normal_comment << l
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
str = format_comment(normal_comment, dot_comment, semi_comment, is_fuzzy)
|
322
|
+
podata.set_comment(msgid, str)
|
323
|
+
end
|
324
|
+
|
325
|
+
def format_comment(normal_comment, dot_comment, semi_comment, is_fuzzy)
|
326
|
+
str = ""
|
327
|
+
|
328
|
+
str << normal_comment.join("\n").gsub(/^#(\s*)/) do |sss|
|
329
|
+
if $1 == ""
|
330
|
+
"# "
|
331
|
+
else
|
332
|
+
sss
|
333
|
+
end
|
334
|
+
end
|
335
|
+
if normal_comment.size > 0
|
336
|
+
str << "\n"
|
337
|
+
end
|
338
|
+
|
339
|
+
str << dot_comment.join("\n").gsub(/^#.(\s*)/) do |sss|
|
340
|
+
if $1 == ""
|
341
|
+
"#. "
|
342
|
+
else
|
343
|
+
sss
|
344
|
+
end
|
345
|
+
end
|
346
|
+
if dot_comment.size > 0
|
347
|
+
str << "\n"
|
348
|
+
end
|
349
|
+
|
350
|
+
str << semi_comment.join("\n").gsub(/^#:\s*/, "#: ")
|
351
|
+
if semi_comment.size > 0
|
352
|
+
str << "\n"
|
353
|
+
end
|
354
|
+
|
355
|
+
if is_fuzzy
|
356
|
+
str << "#, fuzzy\n"
|
357
|
+
end
|
358
|
+
|
359
|
+
str
|
360
|
+
end
|
361
|
+
|
362
|
+
def merge_header(target, definition)
|
363
|
+
merge_comment("", target, "", definition)
|
364
|
+
|
365
|
+
msg = target.msgstr("")
|
366
|
+
def_msg = definition.msgstr("")
|
367
|
+
if POT_DATE_EXTRACT_RE =~ msg
|
368
|
+
time = $1
|
369
|
+
def_msg = def_msg.sub(POT_DATE_RE, "POT-Creation-Date: #{time}")
|
370
|
+
end
|
371
|
+
|
372
|
+
target[""] = def_msg
|
373
|
+
end
|
374
|
+
end
|
375
|
+
|
376
|
+
class Config #:nodoc:
|
377
|
+
|
378
|
+
attr_accessor :defpo, :refpot, :output, :fuzzy, :update
|
379
|
+
|
380
|
+
# update mode options
|
381
|
+
attr_accessor :backup, :suffix
|
382
|
+
|
383
|
+
# The result is written back to def.po.
|
384
|
+
# --backup=CONTROL make a backup of def.po
|
385
|
+
# --suffix=SUFFIX override the usual backup suffix
|
386
|
+
# The version control method may be selected
|
387
|
+
# via the --backup option or through
|
388
|
+
# the VERSION_CONTROL environment variable. Here are the values:
|
389
|
+
# none, off never make backups (even if --backup is given)
|
390
|
+
# numbered, t make numbered backups
|
391
|
+
# existing, nil numbered if numbered backups exist, simple otherwise
|
392
|
+
# simple, never always make simple backups
|
393
|
+
# The backup suffix is `~', unless set with --suffix or
|
394
|
+
# the SIMPLE_BACKUP_SUFFIX environment variable.
|
395
|
+
|
396
|
+
def initialize
|
397
|
+
@output = nil
|
398
|
+
@fuzzy = nil
|
399
|
+
@update = nil
|
400
|
+
@backup = ENV["VERSION_CONTROL"]
|
401
|
+
@suffix = ENV["SIMPLE_BACKUP_SUFFIX"] || "~"
|
402
|
+
@input_dirs = ["."]
|
403
|
+
end
|
404
|
+
end
|
405
|
+
|
406
|
+
class << self
|
407
|
+
# Merge a po-file inluding translated messages and a new pot-file.
|
408
|
+
# @param [Array<String>] arguments arguments for rmsgfmt.
|
409
|
+
# @return [void]
|
410
|
+
def run(*arguments)
|
411
|
+
new.run(*arguments)
|
412
|
+
end
|
413
|
+
end
|
414
|
+
|
415
|
+
include GetText
|
416
|
+
|
417
|
+
bindtextdomain("rgettext")
|
418
|
+
|
419
|
+
# constant values
|
420
|
+
VERSION = GetText::VERSION
|
421
|
+
|
422
|
+
def check_command_line_options(*options) #:nodoc:
|
423
|
+
options, output = parse_arguments(*options)
|
424
|
+
|
425
|
+
if output.nil?
|
426
|
+
output = nil
|
427
|
+
else
|
428
|
+
if not FileTest.exist?(output)
|
429
|
+
$stderr.puts(_("File '%s' has already existed.") % out)
|
430
|
+
exit(false)
|
431
|
+
end
|
432
|
+
end
|
433
|
+
|
434
|
+
config = Config.new
|
435
|
+
config.output = output
|
436
|
+
config.defpo = options[0]
|
437
|
+
config.refpot = options[1]
|
438
|
+
|
439
|
+
if config.defpo.nil?
|
440
|
+
raise ArgumentError, _("definition po is not given.")
|
441
|
+
elsif config.refpot.nil?
|
442
|
+
raise ArgumentError, _("reference pot is not given.")
|
443
|
+
end
|
444
|
+
|
445
|
+
config
|
446
|
+
end
|
447
|
+
|
448
|
+
def parse_arguments(*options) #:nodoc:
|
449
|
+
parser = OptionParser.new
|
450
|
+
parser.banner = _("Usage: %s def.po ref.pot [-o output.pot]") % $0
|
451
|
+
#parser.summary_width = 80
|
452
|
+
parser.separator("")
|
453
|
+
description = _("Merges two Uniforum style .po files together. " +
|
454
|
+
"The def.po file is an existing PO file with " +
|
455
|
+
"translations. The ref.pot file is the last " +
|
456
|
+
"created PO file with up-to-date source " +
|
457
|
+
"references. ref.pot is generally created by " +
|
458
|
+
"rgettext.")
|
459
|
+
parser.separator(description)
|
460
|
+
parser.separator("")
|
461
|
+
parser.separator(_("Specific options:"))
|
462
|
+
|
463
|
+
output = nil
|
464
|
+
|
465
|
+
parser.on("-o", "--output=FILE",
|
466
|
+
_("write output to specified file")) do |out|
|
467
|
+
output = out
|
468
|
+
end
|
469
|
+
|
470
|
+
#parser.on("-F", "--fuzzy-matching")
|
471
|
+
|
472
|
+
parser.on("-h", "--help", _("Dispray this help and exit")) do
|
473
|
+
puts(parser.help)
|
474
|
+
exit(true)
|
475
|
+
end
|
476
|
+
|
477
|
+
parser.on_tail("--version", _("display version information and exit")) do
|
478
|
+
puts(VERSION)
|
479
|
+
exit(true)
|
480
|
+
end
|
481
|
+
|
482
|
+
parser.parse!(options)
|
483
|
+
|
484
|
+
[options, output]
|
485
|
+
end
|
486
|
+
|
487
|
+
def run(*options) #:nodoc:
|
488
|
+
config = check_command_line_options(*options)
|
489
|
+
|
490
|
+
parser = PoParser.new
|
491
|
+
parser.ignore_fuzzy = false
|
492
|
+
defpo = parser.parse_file(config.defpo, PoData.new)
|
493
|
+
refpot = parser.parse_file(config.refpot, PoData.new)
|
494
|
+
|
495
|
+
merger = Merger.new
|
496
|
+
result = merger.merge(defpo, refpot)
|
497
|
+
p result if $DEBUG
|
498
|
+
print result.generate_po if $DEBUG
|
499
|
+
|
500
|
+
if config.output.is_a?(String)
|
501
|
+
File.open(File.expand_path(config.output), "w+") do |file|
|
502
|
+
file.write(result.generate_po)
|
503
|
+
end
|
504
|
+
else
|
505
|
+
puts(result.generate_po)
|
506
|
+
end
|
507
|
+
end
|
508
|
+
end
|
509
|
+
end
|
510
|
+
end
|