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
data/bin/rxgettext
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
#
|
4
|
+
# Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
|
5
|
+
# Copyright (C) 2005-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 "gettext/tools/xgettext"
|
23
|
+
|
24
|
+
GetText::Tools::XGetText.run(*ARGV)
|
data/doc/text/news.md
CHANGED
@@ -1,4 +1,64 @@
|
|
1
1
|
# News
|
2
|
+
## <a id="2-3-0">2.3.0</a>: 2012-08-28
|
3
|
+
|
4
|
+
Various improvements, changes and fixes release.
|
5
|
+
|
6
|
+
### Improvements
|
7
|
+
|
8
|
+
* Improved TextDomain#translate\_singluar\_message performance.
|
9
|
+
[Base idea is provided by @angelf]
|
10
|
+
* Added msginit command.
|
11
|
+
* [xgettext] Added command line options for package name, version,
|
12
|
+
copyright holder and msgid bugs address.[Github#8]
|
13
|
+
[Reported by Francesco Poli (wintermute) and 375gnu, and patch by 375gnu]
|
14
|
+
* [xgettext] Supported s\_ and ns\_ with parameter.
|
15
|
+
* [poparser] Reported warnings when fuzzy message is used.
|
16
|
+
[Reported by Michael Grosser]
|
17
|
+
* Used %{...} to check the availability of String#% with hash and
|
18
|
+
raise Error if this syntax isn't supported.
|
19
|
+
* Searched mo files under LC_MESSAGES/ directory.
|
20
|
+
* Updated documents for tools.
|
21
|
+
|
22
|
+
### Changes
|
23
|
+
|
24
|
+
* Renamed the package name from "Ruby-GetText-Package" to "gettext".
|
25
|
+
* Renamed RGetText to XGetText, RMsgMerge to MsgMerge, RMsgFmt to MsgFmt.
|
26
|
+
* Renamed rgettext to rxgettext, rmsgmerge to msgmerge, rmsgfmt to msgfmt.
|
27
|
+
* Defined tools(XGetText, MsgMerge, MsgFmt) as Class under GetText::Tools
|
28
|
+
module.
|
29
|
+
* Removed shortcuts for tools in GetText module.
|
30
|
+
Please use GetText::Tools:XXX.run instead of GetText.xxx.
|
31
|
+
* Changed API of tools.
|
32
|
+
e.g.) Before: GetText.rsmgfmt(targetfile, output\_path)
|
33
|
+
Now: GetText::Tools::MsgFmt.run(targetfile, "-o", output\_path)
|
34
|
+
* [xgettext] Used relative path for source path.
|
35
|
+
This path appears in generated pot file.
|
36
|
+
* [xgettext] Returned the pot header instead of "" as the translation of
|
37
|
+
"" msgid.
|
38
|
+
* [poparser] Treated not translated msgid when parsing po file.
|
39
|
+
A translation of no translated msgid is msgid itself even now.
|
40
|
+
* [xgettext] Removed descriptions of ruby in information by "-v" option.
|
41
|
+
|
42
|
+
### Fixes
|
43
|
+
|
44
|
+
* Included msgctxt when generating .po file. [Patch by 3dd13]
|
45
|
+
* Fixed a typo in msgmerge. [Patch by Yves-Eric Martin]
|
46
|
+
* [msgmerge] Followed PoParser API change.
|
47
|
+
* [ruby-parser] Reseted the last comment when po message is stored.[Github#6]
|
48
|
+
[Reported by 375gnu and Francesco Poli (wintermute), and Patch by 375gnu]
|
49
|
+
* [ruby-parser] Processed RubyToken::TkDSTRING too.[Github#6]
|
50
|
+
[Reported by 375gnu and Francesco Poli (wintermute), and Patch by 375gnu]
|
51
|
+
* [msgmerge] Fixed not to add fuzzy to header message.
|
52
|
+
* [msgmerge] Escaped backslash and "\n".
|
53
|
+
|
54
|
+
### Thanks
|
55
|
+
|
56
|
+
* @angelf
|
57
|
+
* Francesco Poli (wintermute)
|
58
|
+
* 375gnu
|
59
|
+
* Michael Grosser
|
60
|
+
* 3dd13
|
61
|
+
* Yves-Eric Martin
|
2
62
|
|
3
63
|
## <a id="2-2-0">2.2.0</a>: 2012-03-11
|
4
64
|
|
data/gettext.gemspec
CHANGED
@@ -7,11 +7,11 @@ require "gettext/version"
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "gettext"
|
9
9
|
s.version = GetText::VERSION
|
10
|
-
s.summary = '
|
10
|
+
s.summary = 'Gettext is a pure Ruby libary and tools to localize messages.'
|
11
11
|
s.description = <<-EOD
|
12
|
-
|
13
|
-
The catalog file(po-file) is same format with GNU
|
14
|
-
So you can use GNU
|
12
|
+
Gettext is a GNU gettext-like program for Ruby.
|
13
|
+
The catalog file(po-file) is same format with GNU gettext.
|
14
|
+
So you can use GNU gettext tools for maintaining.
|
15
15
|
EOD
|
16
16
|
s.authors = ["Kouhei Sutou", "Masao Mutoh"]
|
17
17
|
s.email = ["kou@clear-code.com", "mutomasa at gmail.com"]
|
@@ -28,8 +28,11 @@ So you can use GNU GetText tools for maintaining.
|
|
28
28
|
end
|
29
29
|
|
30
30
|
s.add_runtime_dependency("locale")
|
31
|
+
s.add_development_dependency("rake")
|
31
32
|
s.add_development_dependency("racc")
|
32
33
|
s.add_development_dependency("yard")
|
34
|
+
s.add_development_dependency("redcarpet")
|
33
35
|
s.add_development_dependency("test-unit")
|
34
36
|
s.add_development_dependency("test-unit-notify")
|
37
|
+
s.add_development_dependency("test-unit-rr")
|
35
38
|
end
|
data/lib/gettext.rb
CHANGED
@@ -127,7 +127,7 @@ module GetText
|
|
127
127
|
# * msgid: the message id.
|
128
128
|
# * Returns: localized text by msgid. If there are not binded mo-file, it will return msgid.
|
129
129
|
def gettext(msgid)
|
130
|
-
TextDomainManager.
|
130
|
+
TextDomainManager.translate_singular_message(self, msgid)
|
131
131
|
end
|
132
132
|
|
133
133
|
# call-seq:
|
@@ -144,7 +144,7 @@ module GetText
|
|
144
144
|
# <tt>Movie|Location -> Location</tt>
|
145
145
|
# See: http://www.gnu.org/software/gettext/manual/html_mono/gettext.html#SEC151
|
146
146
|
def sgettext(msgid, seperator = "|")
|
147
|
-
TextDomainManager.
|
147
|
+
TextDomainManager.translate_singular_message(self, msgid, seperator)
|
148
148
|
end
|
149
149
|
|
150
150
|
# call-seq:
|
@@ -161,7 +161,7 @@ module GetText
|
|
161
161
|
# it returns msgid.
|
162
162
|
# See: http://www.gnu.org/software/autoconf/manual/gettext/Contexts.html
|
163
163
|
def pgettext(msgctxt, msgid)
|
164
|
-
TextDomainManager.
|
164
|
+
TextDomainManager.translate_singular_message(self, "#{msgctxt}\004#{msgid}", "\004")
|
165
165
|
end
|
166
166
|
|
167
167
|
# call-seq:
|
@@ -56,9 +56,11 @@ module GetText
|
|
56
56
|
load_path.map!{|v| v.match(/(.*?)(\/lib)*?$/); $1}
|
57
57
|
load_path.each {|path|
|
58
58
|
default_path_rules += [
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
"#{path}/data/locale/%{lang}/LC_MESSAGES/%{name}.mo",
|
60
|
+
"#{path}/data/locale/%{lang}/%{name}.mo",
|
61
|
+
"#{path}/locale/%{lang}/LC_MESSAGES/%{name}.mo",
|
62
|
+
"#{path}/locale/%{lang}/%{name}.mo",
|
63
|
+
]
|
62
64
|
}
|
63
65
|
# paths existed only.
|
64
66
|
default_path_rules = default_path_rules.select{|path|
|
@@ -85,7 +87,7 @@ module GetText
|
|
85
87
|
@locale_paths = {}
|
86
88
|
path_rules.each do |rule|
|
87
89
|
this_path_rules = rule % {:lang => "([^\/]+)", :name => name}
|
88
|
-
Dir.glob(rule %{:lang => "*", :name => name}).each do |path|
|
90
|
+
Dir.glob(rule % {:lang => "*", :name => name}).each do |path|
|
89
91
|
if /#{this_path_rules}/ =~ path
|
90
92
|
@locale_paths[$1] = path.untaint unless @locale_paths[$1]
|
91
93
|
end
|
@@ -67,8 +67,8 @@ module GetText
|
|
67
67
|
# * lang: Locale::Tag::Simple's subclass.
|
68
68
|
# * msgid: the original message.
|
69
69
|
# * Returns: the translated string or nil.
|
70
|
-
def
|
71
|
-
return "" if msgid
|
70
|
+
def translate_singular_message(lang, msgid)
|
71
|
+
return "" if msgid.nil?
|
72
72
|
|
73
73
|
lang_key = lang.to_s
|
74
74
|
|
@@ -85,14 +85,19 @@ module GetText
|
|
85
85
|
end
|
86
86
|
|
87
87
|
msgstr = mofile[msgid]
|
88
|
-
if
|
89
|
-
msgstr
|
88
|
+
if not msgstr.nil?
|
89
|
+
if msgstr.empty?
|
90
|
+
nil
|
91
|
+
else
|
92
|
+
msgstr
|
93
|
+
end
|
90
94
|
elsif msgid.include?("\000")
|
91
|
-
# Check "aaa\000bbb" and show warning but return the
|
95
|
+
# Check "aaa\000bbb" and show warning but return the singular part.
|
92
96
|
ret = nil
|
93
97
|
msgid_single = msgid.split("\000")[0]
|
98
|
+
msgid_single_prefix_re = /^#{Regexp.quote(msgid_single)}\000/
|
94
99
|
mofile.each{|key, val|
|
95
|
-
if key =~
|
100
|
+
if key =~ msgid_single_prefix_re
|
96
101
|
# Usually, this is not caused to make po-files from rgettext.
|
97
102
|
warn %Q[Warning: n_("#{msgid_single}", "#{msgid.split("\000")[1]}") and n_("#{key.gsub(/\000/, '", "')}") are duplicated.]
|
98
103
|
ret = val
|
@@ -102,8 +107,9 @@ module GetText
|
|
102
107
|
ret
|
103
108
|
else
|
104
109
|
ret = nil
|
110
|
+
msgid_prefix_re = /^#{Regexp.quote(msgid)}\000/
|
105
111
|
mofile.each{|key, val|
|
106
|
-
if key =~
|
112
|
+
if key =~ msgid_prefix_re
|
107
113
|
ret = val.split("\000")[0]
|
108
114
|
break
|
109
115
|
end
|
@@ -122,7 +128,7 @@ module GetText
|
|
122
128
|
# * Returns: the translated string as an Array ([[msgstr1, msgstr2, ...], cond]) or nil.
|
123
129
|
def translate_plural_message(lang, msgid, msgid_plural) #:nodoc:
|
124
130
|
key = msgid + "\000" + msgid_plural
|
125
|
-
msg =
|
131
|
+
msg = translate_singular_message(lang, key)
|
126
132
|
ret = nil
|
127
133
|
if ! msg
|
128
134
|
ret = nil
|
@@ -95,14 +95,14 @@ module GetText
|
|
95
95
|
# * div: separator or nil.
|
96
96
|
# * Returns: the localized text by msgid. If there are no localized text,
|
97
97
|
# it returns a last part of msgid separeted "div".
|
98
|
-
def
|
98
|
+
def translate_singular_message(klass, msgid, div = nil)
|
99
99
|
klass = ClassInfo.normalize_class(klass)
|
100
100
|
key = [Locale.current, klass, msgid, div].hash
|
101
101
|
msg = @@singular_message_cache[key]
|
102
102
|
return msg if msg and @@cached
|
103
103
|
# Find messages from related classes.
|
104
104
|
each_textdomains(klass) do |textdomain, lang|
|
105
|
-
msg = textdomain.
|
105
|
+
msg = textdomain.translate_singular_message(lang, msgid)
|
106
106
|
break if msg
|
107
107
|
end
|
108
108
|
|
@@ -116,7 +116,7 @@ module GetText
|
|
116
116
|
@@singular_message_cache[key] = msg
|
117
117
|
end
|
118
118
|
|
119
|
-
# This function is similar to the
|
119
|
+
# This function is similar to the get_singular_message function
|
120
120
|
# as it finds the message catalogs in the same way.
|
121
121
|
# But it takes two extra arguments for plural form.
|
122
122
|
# The msgid parameter must contain the singular form of the string to be converted.
|
data/lib/gettext/task.rb
ADDED
@@ -0,0 +1,203 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
|
4
|
+
#
|
5
|
+
# License: Ruby's or LGPL
|
6
|
+
#
|
7
|
+
# This library is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This library is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU Lesser General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU Lesser General Public License
|
18
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
|
20
|
+
require "gettext/tools"
|
21
|
+
|
22
|
+
module GetText
|
23
|
+
class Task
|
24
|
+
include GetText
|
25
|
+
include Rake::DSL
|
26
|
+
|
27
|
+
attr_accessor :locales, :po_base_directory, :mo_base_directory, :domain
|
28
|
+
attr_accessor :namespace_prefix, :files
|
29
|
+
def initialize(spec)
|
30
|
+
@spec = spec
|
31
|
+
@locales = []
|
32
|
+
@po_base_directory = "po"
|
33
|
+
@mo_base_directory = "."
|
34
|
+
@files = target_files
|
35
|
+
@domain = @spec.name
|
36
|
+
@namespace_prefix = nil
|
37
|
+
yield(self) if block_given?
|
38
|
+
@locales = detect_locales if @locales.empty?
|
39
|
+
raise("must set locales: #{inspect}") if @locales.empty?
|
40
|
+
define
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
def define
|
45
|
+
define_file_tasks
|
46
|
+
if namespace_prefix
|
47
|
+
namespace_recursive namespace_prefix do
|
48
|
+
define_named_tasks
|
49
|
+
end
|
50
|
+
else
|
51
|
+
define_named_tasks
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def define_file_tasks
|
56
|
+
unless files.empty?
|
57
|
+
pot_dependencies = files.dup
|
58
|
+
unless File.exist?(po_base_directory)
|
59
|
+
directory po_base_directory
|
60
|
+
pot_dependencies << po_base_directory
|
61
|
+
end
|
62
|
+
file pot_file => pot_dependencies do
|
63
|
+
GetText::Tools::XGetText.run("--package-name", @spec.name,
|
64
|
+
"--package-version", @spec.version.to_s,
|
65
|
+
"--output", pot_file,
|
66
|
+
*files)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
locales.each do |locale|
|
71
|
+
_po_file = po_file(locale)
|
72
|
+
unless files.empty?
|
73
|
+
po_dependencies = [pot_file]
|
74
|
+
_po_directory = po_directory(locale)
|
75
|
+
unless File.exist?(_po_directory)
|
76
|
+
directory _po_directory
|
77
|
+
po_dependencies << _po_directory
|
78
|
+
end
|
79
|
+
file _po_file => po_dependencies do
|
80
|
+
if File.exist?(_po_file)
|
81
|
+
GetText::Tools::MsgMerge.run(po_file(locale), pot_file,
|
82
|
+
"--output", _po_file)
|
83
|
+
else
|
84
|
+
GetText::Tools::MsgInit.run("--input", pot_file,
|
85
|
+
"--output", _po_file,
|
86
|
+
"--locale", locale.to_s)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
mo_dependencies = [_po_file]
|
92
|
+
_mo_directory = mo_directory(locale)
|
93
|
+
unless File.exist?(_mo_directory)
|
94
|
+
directory _mo_directory
|
95
|
+
mo_dependencies << _mo_directory
|
96
|
+
end
|
97
|
+
_mo_file = mo_file(locale)
|
98
|
+
file _mo_file => mo_dependencies do
|
99
|
+
GetText::Tools::MsgFmt.run(_po_file, "--output", _mo_file)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def define_named_tasks
|
105
|
+
namespace :gettext do
|
106
|
+
namespace :pot do
|
107
|
+
desc "Create #{pot_file}"
|
108
|
+
task :create => pot_file
|
109
|
+
end
|
110
|
+
|
111
|
+
namespace :po do
|
112
|
+
update_tasks = []
|
113
|
+
@locales.each do |locale|
|
114
|
+
namespace locale do
|
115
|
+
desc "Update #{po_file(locale)}"
|
116
|
+
task :update => po_file(locale)
|
117
|
+
update_tasks << (current_scope + ["update"]).join(":")
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
desc "Update *.po"
|
122
|
+
task :update => update_tasks
|
123
|
+
end
|
124
|
+
|
125
|
+
namespace :mo do
|
126
|
+
update_tasks = []
|
127
|
+
@locales.each do |locale|
|
128
|
+
namespace locale do
|
129
|
+
desc "Update #{mo_file(locale)}"
|
130
|
+
task :update => mo_file(locale)
|
131
|
+
update_tasks << (current_scope + ["update"]).join(":")
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
desc "Update *.mo"
|
136
|
+
task :update => update_tasks
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
desc "Update *.mo"
|
141
|
+
task :gettext => (current_scope + ["gettext", "mo", "update"]).join(":")
|
142
|
+
end
|
143
|
+
|
144
|
+
def pot_file
|
145
|
+
File.join(po_base_directory, "#{domain}.pot")
|
146
|
+
end
|
147
|
+
|
148
|
+
def po_directory(locale)
|
149
|
+
File.join(po_base_directory, locale.to_s)
|
150
|
+
end
|
151
|
+
|
152
|
+
def po_file(locale)
|
153
|
+
File.join(po_directory(locale), "#{domain}.po")
|
154
|
+
end
|
155
|
+
|
156
|
+
def mo_directory(locale)
|
157
|
+
File.join(mo_base_directory, "locale", locale.to_s, "LC_MESSAGES")
|
158
|
+
end
|
159
|
+
|
160
|
+
def mo_file(locale)
|
161
|
+
File.join(mo_directory(locale), "#{domain}.mo")
|
162
|
+
end
|
163
|
+
|
164
|
+
def target_files
|
165
|
+
files = @spec.files.find_all do |file|
|
166
|
+
/\.(?:rb|erb|glade)/i =~ File.extname(file)
|
167
|
+
end
|
168
|
+
files += @spec.executables.collect do |executable|
|
169
|
+
"bin/#{executable}"
|
170
|
+
end
|
171
|
+
files
|
172
|
+
end
|
173
|
+
|
174
|
+
def detect_locales
|
175
|
+
locales = []
|
176
|
+
return locales unless File.exist?(po_base_directory)
|
177
|
+
|
178
|
+
Dir.open(po_base_directory) do |dir|
|
179
|
+
dir.each do |entry|
|
180
|
+
next unless /\A[a-z]{2}(?:_[A-Z]{2})?\z/ =~ entry
|
181
|
+
next unless File.directory?(File.join(dir.path, entry))
|
182
|
+
locales << entry
|
183
|
+
end
|
184
|
+
end
|
185
|
+
locales
|
186
|
+
end
|
187
|
+
|
188
|
+
def current_scope
|
189
|
+
Rake.application.current_scope
|
190
|
+
end
|
191
|
+
|
192
|
+
def namespace_recursive(namespace_spec, &block)
|
193
|
+
first, rest = namespace_spec.split(/:/, 2)
|
194
|
+
namespace first do
|
195
|
+
if rest.nil?
|
196
|
+
block.call
|
197
|
+
else
|
198
|
+
namespace_recursive(rest, &block)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|