experteer-gettext 2.0.4
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 +55 -0
- data/ChangeLog +57 -0
- data/ChangeLog-1 +2016 -0
- data/NEWS-1 +414 -0
- data/README.rdoc +251 -0
- data/Rakefile +260 -0
- data/VERSION +2 -0
- data/bin/rgettext +24 -0
- data/bin/rmsgfmt +24 -0
- data/bin/rmsgmerge +24 -0
- data/gettext.gemspec +494 -0
- data/lib/gettext/cgi.rb +39 -0
- data/lib/gettext/class_info.rb +67 -0
- data/lib/gettext/core_ext/iconv.rb +112 -0
- data/lib/gettext/core_ext/string.rb +84 -0
- data/lib/gettext/locale_path.rb +123 -0
- data/lib/gettext/mofile.rb +330 -0
- data/lib/gettext/parser/erb.rb +54 -0
- data/lib/gettext/parser/glade.rb +100 -0
- data/lib/gettext/parser/ruby.rb +193 -0
- data/lib/gettext/poparser.rb +355 -0
- data/lib/gettext/textdomain.rb +179 -0
- data/lib/gettext/textdomain_group.rb +24 -0
- data/lib/gettext/textdomain_manager.rb +212 -0
- data/lib/gettext/tools/rgettext.rb +236 -0
- data/lib/gettext/tools/rmsgfmt.rb +84 -0
- data/lib/gettext/tools/rmsgmerge.rb +498 -0
- data/lib/gettext/tools.rb +195 -0
- data/lib/gettext/translation_target.rb +93 -0
- data/lib/gettext/utils.rb +37 -0
- data/lib/gettext/version.rb +12 -0
- data/lib/gettext.rb +312 -0
- data/po/bg/rgettext.po +130 -0
- data/po/bs/rgettext.po +131 -0
- data/po/ca/rgettext.po +129 -0
- data/po/cs/rgettext.po +132 -0
- data/po/de/rgettext.po +137 -0
- data/po/el/rgettext.po +128 -0
- data/po/eo/rgettext.po +129 -0
- data/po/es/rgettext.po +130 -0
- data/po/et/rgettext.po +127 -0
- data/po/fr/rgettext.po +133 -0
- data/po/hr/rgettext.po +131 -0
- data/po/hu/rgettext.po +129 -0
- data/po/it/rgettext.po +130 -0
- data/po/ja/rgettext.po +129 -0
- data/po/ko/rgettext.po +129 -0
- data/po/lv/rgettext.po +130 -0
- data/po/nb/rgettext.po +131 -0
- data/po/nl/rgettext.po +130 -0
- data/po/pt_BR/rgettext.po +132 -0
- data/po/rgettext.pot +121 -0
- data/po/ru/rgettext.po +131 -0
- data/po/sr/rgettext.po +130 -0
- data/po/sv/rgettext.po +123 -0
- data/po/ua/rgettext.po +134 -0
- data/po/vi/rgettext.po +128 -0
- data/po/zh/rgettext.po +129 -0
- data/po/zh_TW/rgettext.po +128 -0
- data/samples/README +16 -0
- data/samples/cgi/README +43 -0
- data/samples/cgi/Rakefile +27 -0
- data/samples/cgi/cookie.cgi +64 -0
- data/samples/cgi/gettext.css +116 -0
- data/samples/cgi/helloerb.rhtml +28 -0
- data/samples/cgi/helloerb1.cgi +58 -0
- data/samples/cgi/helloerb2.cgi +51 -0
- data/samples/cgi/hellolib.rb +20 -0
- data/samples/cgi/http.rb +51 -0
- data/samples/cgi/index.cgi +111 -0
- data/samples/cgi/other.rhtml +20 -0
- data/samples/cgi/po/bg/helloerb1.po +59 -0
- data/samples/cgi/po/bg/helloerb2.po +51 -0
- data/samples/cgi/po/bg/hellolib.po +23 -0
- data/samples/cgi/po/bg/main.po +83 -0
- data/samples/cgi/po/bs/helloerb1.po +59 -0
- data/samples/cgi/po/bs/helloerb2.po +51 -0
- data/samples/cgi/po/bs/hellolib.po +23 -0
- data/samples/cgi/po/bs/main.po +83 -0
- data/samples/cgi/po/ca/helloerb1.po +59 -0
- data/samples/cgi/po/ca/helloerb2.po +51 -0
- data/samples/cgi/po/ca/hellolib.po +23 -0
- data/samples/cgi/po/ca/main.po +83 -0
- data/samples/cgi/po/cs/helloerb1.po +61 -0
- data/samples/cgi/po/cs/helloerb2.po +52 -0
- data/samples/cgi/po/cs/hellolib.po +25 -0
- data/samples/cgi/po/cs/main.po +85 -0
- data/samples/cgi/po/de/helloerb1.po +61 -0
- data/samples/cgi/po/de/helloerb2.po +52 -0
- data/samples/cgi/po/de/hellolib.po +24 -0
- data/samples/cgi/po/de/main.po +86 -0
- data/samples/cgi/po/el/helloerb1.po +60 -0
- data/samples/cgi/po/el/helloerb2.po +51 -0
- data/samples/cgi/po/el/hellolib.po +23 -0
- data/samples/cgi/po/el/main.po +84 -0
- data/samples/cgi/po/eo/helloerb1.po +60 -0
- data/samples/cgi/po/eo/helloerb2.po +52 -0
- data/samples/cgi/po/eo/hellolib.po +24 -0
- data/samples/cgi/po/eo/main.po +84 -0
- data/samples/cgi/po/es/helloerb1.po +59 -0
- data/samples/cgi/po/es/helloerb2.po +50 -0
- data/samples/cgi/po/es/hellolib.po +22 -0
- data/samples/cgi/po/es/main.po +83 -0
- data/samples/cgi/po/fr/helloerb1.po +59 -0
- data/samples/cgi/po/fr/helloerb2.po +51 -0
- data/samples/cgi/po/fr/hellolib.po +22 -0
- data/samples/cgi/po/fr/main.po +85 -0
- data/samples/cgi/po/helloerb1.pot +60 -0
- data/samples/cgi/po/helloerb2.pot +52 -0
- data/samples/cgi/po/hellolib.pot +24 -0
- data/samples/cgi/po/hr/helloerb1.po +59 -0
- data/samples/cgi/po/hr/helloerb2.po +51 -0
- data/samples/cgi/po/hr/hellolib.po +23 -0
- data/samples/cgi/po/hr/main.po +83 -0
- data/samples/cgi/po/hu/helloerb1.po +59 -0
- data/samples/cgi/po/hu/helloerb2.po +51 -0
- data/samples/cgi/po/hu/hellolib.po +23 -0
- data/samples/cgi/po/hu/main.po +82 -0
- data/samples/cgi/po/it/helloerb1.po +60 -0
- data/samples/cgi/po/it/helloerb2.po +52 -0
- data/samples/cgi/po/it/hellolib.po +24 -0
- data/samples/cgi/po/it/main.po +84 -0
- data/samples/cgi/po/ja/helloerb1.po +60 -0
- data/samples/cgi/po/ja/helloerb2.po +52 -0
- data/samples/cgi/po/ja/hellolib.po +24 -0
- data/samples/cgi/po/ja/main.po +85 -0
- data/samples/cgi/po/ko/helloerb1.po +59 -0
- data/samples/cgi/po/ko/helloerb2.po +51 -0
- data/samples/cgi/po/ko/hellolib.po +23 -0
- data/samples/cgi/po/ko/main.po +84 -0
- data/samples/cgi/po/lv/helloerb1.po +65 -0
- data/samples/cgi/po/lv/helloerb2.po +52 -0
- data/samples/cgi/po/lv/hellolib.po +24 -0
- data/samples/cgi/po/lv/main.po +77 -0
- data/samples/cgi/po/main.pot +80 -0
- data/samples/cgi/po/nb/helloerb1.po +60 -0
- data/samples/cgi/po/nb/helloerb2.po +52 -0
- data/samples/cgi/po/nb/hellolib.po +24 -0
- data/samples/cgi/po/nb/main.po +84 -0
- data/samples/cgi/po/nl/helloerb1.po +61 -0
- data/samples/cgi/po/nl/helloerb2.po +52 -0
- data/samples/cgi/po/nl/hellolib.po +24 -0
- data/samples/cgi/po/nl/main.po +86 -0
- data/samples/cgi/po/pt_BR/helloerb1.po +59 -0
- data/samples/cgi/po/pt_BR/helloerb2.po +51 -0
- data/samples/cgi/po/pt_BR/hellolib.po +23 -0
- data/samples/cgi/po/pt_BR/main.po +84 -0
- data/samples/cgi/po/ru/helloerb1.po +58 -0
- data/samples/cgi/po/ru/helloerb2.po +50 -0
- data/samples/cgi/po/ru/hellolib.po +22 -0
- data/samples/cgi/po/ru/main.po +82 -0
- data/samples/cgi/po/sr/helloerb1.po +60 -0
- data/samples/cgi/po/sr/helloerb2.po +52 -0
- data/samples/cgi/po/sr/hellolib.po +24 -0
- data/samples/cgi/po/sr/main.po +80 -0
- data/samples/cgi/po/ua/helloerb1.po +62 -0
- data/samples/cgi/po/ua/helloerb2.po +54 -0
- data/samples/cgi/po/ua/hellolib.po +26 -0
- data/samples/cgi/po/ua/main.po +84 -0
- data/samples/cgi/po/vi/helloerb1.po +65 -0
- data/samples/cgi/po/vi/helloerb2.po +52 -0
- data/samples/cgi/po/vi/hellolib.po +24 -0
- data/samples/cgi/po/vi/main.po +77 -0
- data/samples/cgi/po/zh/helloerb1.po +60 -0
- data/samples/cgi/po/zh/helloerb2.po +52 -0
- data/samples/cgi/po/zh/hellolib.po +24 -0
- data/samples/cgi/po/zh/main.po +80 -0
- data/samples/cgi/po/zh_TW/helloerb1.po +67 -0
- data/samples/cgi/po/zh_TW/helloerb2.po +54 -0
- data/samples/cgi/po/zh_TW/hellolib.po +26 -0
- data/samples/cgi/po/zh_TW/main.po +79 -0
- data/samples/hello.rb +36 -0
- data/samples/hello2.rb +23 -0
- data/samples/hello_glade2.glade +70 -0
- data/samples/hello_glade2.rb +25 -0
- data/samples/hello_gtk2.rb +27 -0
- data/samples/hello_noop.rb +31 -0
- data/samples/hello_plural.rb +26 -0
- data/samples/hello_tk.rb +19 -0
- data/samples/makemo.rb +4 -0
- data/samples/po/bg/hello.po +24 -0
- data/samples/po/bg/hello2.po +31 -0
- data/samples/po/bg/hello_glade2.po +31 -0
- data/samples/po/bg/hello_gtk.po +23 -0
- data/samples/po/bg/hello_noop.po +27 -0
- data/samples/po/bg/hello_plural.po +25 -0
- data/samples/po/bg/hello_tk.po +23 -0
- data/samples/po/bs/hello.po +23 -0
- data/samples/po/bs/hello2.po +31 -0
- data/samples/po/bs/hello_glade2.po +31 -0
- data/samples/po/bs/hello_gtk.po +23 -0
- data/samples/po/bs/hello_noop.po +27 -0
- data/samples/po/bs/hello_plural.po +26 -0
- data/samples/po/bs/hello_tk.po +23 -0
- data/samples/po/ca/hello.po +23 -0
- data/samples/po/ca/hello2.po +31 -0
- data/samples/po/ca/hello_glade2.po +31 -0
- data/samples/po/ca/hello_gtk.po +23 -0
- data/samples/po/ca/hello_noop.po +27 -0
- data/samples/po/ca/hello_plural.po +25 -0
- data/samples/po/ca/hello_tk.po +23 -0
- data/samples/po/cs/hello.po +23 -0
- data/samples/po/cs/hello2.po +31 -0
- data/samples/po/cs/hello_glade2.po +37 -0
- data/samples/po/cs/hello_gtk.po +23 -0
- data/samples/po/cs/hello_noop.po +27 -0
- data/samples/po/cs/hello_plural.po +26 -0
- data/samples/po/cs/hello_tk.po +23 -0
- data/samples/po/de/hello.po +20 -0
- data/samples/po/de/hello2.po +28 -0
- data/samples/po/de/hello_glade2.po +27 -0
- data/samples/po/de/hello_gtk.po +20 -0
- data/samples/po/de/hello_noop.po +24 -0
- data/samples/po/de/hello_plural.po +25 -0
- data/samples/po/de/hello_tk.po +20 -0
- data/samples/po/el/hello.po +23 -0
- data/samples/po/el/hello2.po +31 -0
- data/samples/po/el/hello_glade2.po +31 -0
- data/samples/po/el/hello_gtk.po +22 -0
- data/samples/po/el/hello_noop.po +27 -0
- data/samples/po/el/hello_plural.po +25 -0
- data/samples/po/el/hello_tk.po +23 -0
- data/samples/po/eo/hello.po +23 -0
- data/samples/po/eo/hello2.po +31 -0
- data/samples/po/eo/hello_glade2.po +32 -0
- data/samples/po/eo/hello_gtk.po +23 -0
- data/samples/po/eo/hello_noop.po +27 -0
- data/samples/po/eo/hello_plural.po +26 -0
- data/samples/po/eo/hello_tk.po +24 -0
- data/samples/po/es/hello.po +21 -0
- data/samples/po/es/hello2.po +28 -0
- data/samples/po/es/hello_glade2.po +28 -0
- data/samples/po/es/hello_gtk.po +20 -0
- data/samples/po/es/hello_noop.po +24 -0
- data/samples/po/es/hello_plural.po +23 -0
- data/samples/po/es/hello_tk.po +20 -0
- data/samples/po/fr/hello.po +18 -0
- data/samples/po/fr/hello2.po +26 -0
- data/samples/po/fr/hello_glade2.po +27 -0
- data/samples/po/fr/hello_gtk.po +18 -0
- data/samples/po/fr/hello_noop.po +22 -0
- data/samples/po/fr/hello_plural.po +21 -0
- data/samples/po/fr/hello_tk.po +18 -0
- data/samples/po/hello.pot +23 -0
- data/samples/po/hello2.pot +31 -0
- data/samples/po/hello_glade2.pot +32 -0
- data/samples/po/hello_gtk.pot +23 -0
- data/samples/po/hello_noop.pot +27 -0
- data/samples/po/hello_plural.pot +26 -0
- data/samples/po/hello_tk.pot +24 -0
- data/samples/po/hr/hello.po +23 -0
- data/samples/po/hr/hello2.po +31 -0
- data/samples/po/hr/hello_glade2.po +31 -0
- data/samples/po/hr/hello_gtk.po +23 -0
- data/samples/po/hr/hello_noop.po +27 -0
- data/samples/po/hr/hello_plural.po +26 -0
- data/samples/po/hr/hello_tk.po +23 -0
- data/samples/po/hu/hello.po +22 -0
- data/samples/po/hu/hello2.po +30 -0
- data/samples/po/hu/hello_glade2.po +31 -0
- data/samples/po/hu/hello_gtk.po +22 -0
- data/samples/po/hu/hello_noop.po +26 -0
- data/samples/po/hu/hello_plural.po +25 -0
- data/samples/po/hu/hello_tk.po +23 -0
- data/samples/po/it/hello.po +20 -0
- data/samples/po/it/hello2.po +28 -0
- data/samples/po/it/hello_glade2.po +28 -0
- data/samples/po/it/hello_gtk.po +21 -0
- data/samples/po/it/hello_noop.po +24 -0
- data/samples/po/it/hello_plural.po +23 -0
- data/samples/po/it/hello_tk.po +21 -0
- data/samples/po/ja/hello.po +20 -0
- data/samples/po/ja/hello2.po +28 -0
- data/samples/po/ja/hello_glade2.po +26 -0
- data/samples/po/ja/hello_gtk.po +19 -0
- data/samples/po/ja/hello_noop.po +23 -0
- data/samples/po/ja/hello_plural.po +21 -0
- data/samples/po/ja/hello_tk.po +19 -0
- data/samples/po/ko/hello.po +18 -0
- data/samples/po/ko/hello2.po +26 -0
- data/samples/po/ko/hello_glade2.po +29 -0
- data/samples/po/ko/hello_gtk.po +18 -0
- data/samples/po/ko/hello_noop.po +22 -0
- data/samples/po/ko/hello_plural.po +25 -0
- data/samples/po/ko/hello_tk.po +19 -0
- data/samples/po/lv/hello.po +24 -0
- data/samples/po/lv/hello2.po +32 -0
- data/samples/po/lv/hello_glade2.po +38 -0
- data/samples/po/lv/hello_gtk.po +24 -0
- data/samples/po/lv/hello_noop.po +28 -0
- data/samples/po/lv/hello_plural.po +26 -0
- data/samples/po/lv/hello_tk.po +24 -0
- data/samples/po/nb/hello.po +23 -0
- data/samples/po/nb/hello2.po +31 -0
- data/samples/po/nb/hello_glade2.po +31 -0
- data/samples/po/nb/hello_gtk.po +23 -0
- data/samples/po/nb/hello_noop.po +27 -0
- data/samples/po/nb/hello_plural.po +26 -0
- data/samples/po/nb/hello_tk.po +24 -0
- data/samples/po/nl/hello.po +24 -0
- data/samples/po/nl/hello2.po +32 -0
- data/samples/po/nl/hello_glade2.po +31 -0
- data/samples/po/nl/hello_gtk.po +24 -0
- data/samples/po/nl/hello_noop.po +28 -0
- data/samples/po/nl/hello_plural.po +25 -0
- data/samples/po/nl/hello_tk.po +24 -0
- data/samples/po/pt_BR/hello.po +21 -0
- data/samples/po/pt_BR/hello2.po +29 -0
- data/samples/po/pt_BR/hello_glade2.po +29 -0
- data/samples/po/pt_BR/hello_gtk.po +21 -0
- data/samples/po/pt_BR/hello_noop.po +25 -0
- data/samples/po/pt_BR/hello_plural.po +23 -0
- data/samples/po/pt_BR/hello_tk.po +21 -0
- data/samples/po/ru/hello.po +22 -0
- data/samples/po/ru/hello2.po +30 -0
- data/samples/po/ru/hello_glade2.po +30 -0
- data/samples/po/ru/hello_gtk.po +22 -0
- data/samples/po/ru/hello_noop.po +26 -0
- data/samples/po/ru/hello_plural.po +28 -0
- data/samples/po/ru/hello_tk.po +22 -0
- data/samples/po/sr/hello.po +22 -0
- data/samples/po/sr/hello2.po +30 -0
- data/samples/po/sr/hello_glade2.po +32 -0
- data/samples/po/sr/hello_gtk.po +22 -0
- data/samples/po/sr/hello_noop.po +26 -0
- data/samples/po/sr/hello_plural.po +26 -0
- data/samples/po/sr/hello_tk.po +24 -0
- data/samples/po/sv/hello.po +20 -0
- data/samples/po/sv/hello2.po +28 -0
- data/samples/po/sv/hello_glade2.po +28 -0
- data/samples/po/sv/hello_gtk.po +20 -0
- data/samples/po/sv/hello_noop.po +24 -0
- data/samples/po/sv/hello_plural.po +23 -0
- data/samples/po/sv/hello_tk.po +20 -0
- data/samples/po/test.rb +11 -0
- data/samples/po/ua/hello.po +22 -0
- data/samples/po/ua/hello2.po +30 -0
- data/samples/po/ua/hello_glade2.po +34 -0
- data/samples/po/ua/hello_gtk.po +22 -0
- data/samples/po/ua/hello_noop.po +26 -0
- data/samples/po/ua/hello_plural.po +29 -0
- data/samples/po/ua/hello_tk.po +26 -0
- data/samples/po/vi/hello.po +23 -0
- data/samples/po/vi/hello2.po +31 -0
- data/samples/po/vi/hello_glade2.po +38 -0
- data/samples/po/vi/hello_gtk.po +23 -0
- data/samples/po/vi/hello_noop.po +27 -0
- data/samples/po/vi/hello_plural.po +26 -0
- data/samples/po/vi/hello_tk.po +24 -0
- data/samples/po/zh/hello.po +23 -0
- data/samples/po/zh/hello2.po +31 -0
- data/samples/po/zh/hello_glade2.po +31 -0
- data/samples/po/zh/hello_gtk.po +23 -0
- data/samples/po/zh/hello_noop.po +27 -0
- data/samples/po/zh/hello_plural.po +25 -0
- data/samples/po/zh/hello_tk.po +23 -0
- data/samples/po/zh_TW/hello.po +26 -0
- data/samples/po/zh_TW/hello2.po +34 -0
- data/samples/po/zh_TW/hello_glade2.po +40 -0
- data/samples/po/zh_TW/hello_gtk.po +25 -0
- data/samples/po/zh_TW/hello_noop.po +30 -0
- data/samples/po/zh_TW/hello_plural.po +28 -0
- data/samples/po/zh_TW/hello_tk.po +26 -0
- data/test/README +1 -0
- data/test/Rakefile +17 -0
- data/test/po/cr/plural.po +23 -0
- data/test/po/da/plural.po +22 -0
- data/test/po/da/plural_error.po +22 -0
- data/test/po/fr/plural.po +28 -0
- data/test/po/fr/plural_error.po +20 -0
- data/test/po/fr/test1.po +23 -0
- data/test/po/fr/test2.po +19 -0
- data/test/po/ir/plural.po +23 -0
- data/test/po/ja/npgettext.po +46 -0
- data/test/po/ja/nsgettext.po +65 -0
- data/test/po/ja/pgettext.po +41 -0
- data/test/po/ja/plural.po +28 -0
- data/test/po/ja/plural_error.po +20 -0
- data/test/po/ja/rubyparser.po +43 -0
- data/test/po/ja/sgettext.po +47 -0
- data/test/po/ja/test1.po +23 -0
- data/test/po/ja/test2.po +19 -0
- data/test/po/ja/test3.po +19 -0
- data/test/po/la/plural.po +23 -0
- data/test/po/la/plural_error.po +21 -0
- data/test/po/li/plural.po +23 -0
- data/test/po/li/plural_error.po +27 -0
- data/test/po/po/plural.po +23 -0
- data/test/po/sl/plural.po +24 -0
- data/test/test_class_info.rb +83 -0
- data/test/test_gettext.rb +311 -0
- data/test/test_locale_path.rb +50 -0
- data/test/test_parser.rb +157 -0
- data/test/test_po_generation.rb +20 -0
- data/test/test_string.rb +65 -0
- data/test/test_textdomain_bind.rb +37 -0
- data/test/test_textdomain_multi.rb +80 -0
- data/test/test_textdomain_toplevel.rb +42 -0
- data/test/test_thread.rb +41 -0
- data/test/test_translation_target.rb +29 -0
- data/test/testlib/N_.rb +66 -0
- data/test/testlib/erb.rhtml +15 -0
- data/test/testlib/erb.rxml +16 -0
- data/test/testlib/gettext.rb +113 -0
- data/test/testlib/gladeparser.glade +183 -0
- data/test/testlib/helper.rb +11 -0
- data/test/testlib/multi_textdomain.rb +131 -0
- data/test/testlib/ngettext.rb +79 -0
- data/test/testlib/npgettext.rb +31 -0
- data/test/testlib/nsgettext.rb +42 -0
- data/test/testlib/pgettext.rb +36 -0
- data/test/testlib/sgettext.rb +46 -0
- data/test/testlib/simple.rb +14 -0
- data/test/tools/files/app.pot +0 -0
- data/test/tools/files/de/app.po +0 -0
- data/test/tools/files/en/app.po +0 -0
- data/test/tools/files/en/test.po +21 -0
- data/test/tools/files/simple_1.po +2 -0
- data/test/tools/files/simple_2.po +2 -0
- data/test/tools/files/simple_translation.rb +1 -0
- data/test/tools/files/version.po +7 -0
- data/test/tools/test.pot +21 -0
- data/test/tools/test_tools.rb +61 -0
- metadata +510 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
textdomain.rb - GetText::Textdomain
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2001-2009 Masao Mutoh
|
|
5
|
+
Copyright (C) 2001-2003 Masahiro Sakai
|
|
6
|
+
|
|
7
|
+
Masahiro Sakai <s01397ms@sfc.keio.ac.jp>
|
|
8
|
+
Masao Mutoh <mutomasa at gmail.com>
|
|
9
|
+
|
|
10
|
+
You may redistribute it and/or modify it under the same
|
|
11
|
+
license terms as Ruby.
|
|
12
|
+
|
|
13
|
+
$Id$
|
|
14
|
+
=end
|
|
15
|
+
|
|
16
|
+
require 'gettext/core_ext/string'
|
|
17
|
+
require 'gettext/mofile'
|
|
18
|
+
require 'gettext/locale_path'
|
|
19
|
+
|
|
20
|
+
module GetText
|
|
21
|
+
# GetText::TextDomain class manages mo-files of a textdomain.
|
|
22
|
+
#
|
|
23
|
+
# Usually, you don't need to use this class directly.
|
|
24
|
+
#
|
|
25
|
+
# Notice: This class is unstable. APIs will be changed.
|
|
26
|
+
class TextDomain
|
|
27
|
+
|
|
28
|
+
attr_reader :output_charset
|
|
29
|
+
attr_reader :mofiles
|
|
30
|
+
attr_reader :name
|
|
31
|
+
|
|
32
|
+
@@cached = ! $DEBUG
|
|
33
|
+
# Cache the mo-file or not.
|
|
34
|
+
# Default is true. If $DEBUG is set then false.
|
|
35
|
+
def self.cached?
|
|
36
|
+
@@cached
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Set to cache the mo-file or not.
|
|
40
|
+
# * val: true if cached, otherwise false.
|
|
41
|
+
def self.cached=(val)
|
|
42
|
+
@@cached = val
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Add default locale path. Usually you should use GetText.add_default_locale_path instead.
|
|
46
|
+
# * path: a new locale path. (e.g.) "/usr/share/locale/%{lang}/LC_MESSAGES/%{name}.mo"
|
|
47
|
+
# ('locale' => "ja_JP", 'name' => "textdomain")
|
|
48
|
+
# * Returns: the new DEFAULT_LOCALE_PATHS
|
|
49
|
+
def self.add_default_locale_path(path)
|
|
50
|
+
warn "Deprecated. Use GetText::LocalePath.add_default_rule instead."
|
|
51
|
+
LocalePath.add_default_rule(path)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Creates a new GetText::TextDomain.
|
|
55
|
+
# * name: the textdomain name.
|
|
56
|
+
# * topdir: the locale path ("%{topdir}/%{lang}/LC_MESSAGES/%{name}.mo") or nil.
|
|
57
|
+
# * output_charset: output charset.
|
|
58
|
+
# * Returns: a newly created GetText::TextDomain object.
|
|
59
|
+
def initialize(name, topdir = nil, output_charset = nil)
|
|
60
|
+
@name, @output_charset = name, output_charset
|
|
61
|
+
|
|
62
|
+
@locale_path = LocalePath.new(@name, topdir)
|
|
63
|
+
@mofiles = {}
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Translates the translated string.
|
|
67
|
+
# * lang: Locale::Tag::Simple's subclass.
|
|
68
|
+
# * msgid: the original message.
|
|
69
|
+
# * Returns: the translated string or nil.
|
|
70
|
+
def translate_singluar_message(lang, msgid)
|
|
71
|
+
return "" if msgid == "" or msgid.nil?
|
|
72
|
+
|
|
73
|
+
lang_key = lang.to_s
|
|
74
|
+
|
|
75
|
+
mofile = nil
|
|
76
|
+
if self.class.cached?
|
|
77
|
+
mofile = @mofiles[lang_key]
|
|
78
|
+
end
|
|
79
|
+
unless mofile
|
|
80
|
+
mofile = load_mo(lang)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
if (! mofile) or (mofile ==:empty)
|
|
84
|
+
return nil
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
msgstr = mofile[msgid]
|
|
88
|
+
if msgstr and (msgstr.size > 0)
|
|
89
|
+
msgstr
|
|
90
|
+
elsif msgid.include?("\000")
|
|
91
|
+
# Check "aaa\000bbb" and show warning but return the singluar part.
|
|
92
|
+
ret = nil
|
|
93
|
+
msgid_single = msgid.split("\000")[0]
|
|
94
|
+
mofile.each{|key, val|
|
|
95
|
+
if key =~ /^#{Regexp.quote(msgid_single)}\000/
|
|
96
|
+
# Usually, this is not caused to make po-files from rgettext.
|
|
97
|
+
warn %Q[Warning: n_("#{msgid_single}", "#{msgid.split("\000")[1]}") and n_("#{key.gsub(/\000/, '", "')}") are duplicated.]
|
|
98
|
+
ret = val
|
|
99
|
+
break
|
|
100
|
+
end
|
|
101
|
+
}
|
|
102
|
+
ret
|
|
103
|
+
else
|
|
104
|
+
ret = nil
|
|
105
|
+
mofile.each{|key, val|
|
|
106
|
+
if key =~ /^#{Regexp.quote(msgid)}\000/
|
|
107
|
+
ret = val.split("\000")[0]
|
|
108
|
+
break
|
|
109
|
+
end
|
|
110
|
+
}
|
|
111
|
+
ret
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
DEFAULT_PLURAL_CALC = Proc.new{|n| n != 1}
|
|
116
|
+
DEFAULT_SINGLE_CALC = Proc.new{|n| 0}
|
|
117
|
+
|
|
118
|
+
# Translates the translated string.
|
|
119
|
+
# * lang: Locale::Tag::Simple's subclass.
|
|
120
|
+
# * msgid: the original message.
|
|
121
|
+
# * msgid_plural: the original message(plural).
|
|
122
|
+
# * Returns: the translated string as an Array ([[msgstr1, msgstr2, ...], cond]) or nil.
|
|
123
|
+
def translate_plural_message(lang, msgid, msgid_plural) #:nodoc:
|
|
124
|
+
key = msgid + "\000" + msgid_plural
|
|
125
|
+
msg = translate_singluar_message(lang, key)
|
|
126
|
+
ret = nil
|
|
127
|
+
if ! msg
|
|
128
|
+
ret = nil
|
|
129
|
+
elsif msg.include?("\000")
|
|
130
|
+
# [[msgstr[0], msgstr[1], msgstr[2],...], cond]
|
|
131
|
+
mofile = @mofiles[lang.to_posix.to_s]
|
|
132
|
+
cond = (mofile and mofile != :empty) ? mofile.plural_as_proc : DEFAULT_PLURAL_CALC
|
|
133
|
+
ret = [msg.split("\000"), cond]
|
|
134
|
+
else
|
|
135
|
+
ret = [[msg], DEFAULT_SINGLE_CALC]
|
|
136
|
+
end
|
|
137
|
+
ret
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# Clear cached mofiles.
|
|
141
|
+
def clear
|
|
142
|
+
@mofiles = {}
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# Set output_charset.
|
|
146
|
+
# * charset: output charset.
|
|
147
|
+
def output_charset=(charset)
|
|
148
|
+
@output_charset = charset
|
|
149
|
+
clear
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
private
|
|
153
|
+
# Load a mo-file from the file.
|
|
154
|
+
# lang is the subclass of Locale::Tag::Simple.
|
|
155
|
+
def load_mo(lang)
|
|
156
|
+
lang = lang.to_posix unless lang.kind_of? Locale::Tag::Posix
|
|
157
|
+
lang_key = lang.to_s
|
|
158
|
+
|
|
159
|
+
mofile = @mofiles[lang_key]
|
|
160
|
+
if mofile
|
|
161
|
+
if mofile == :empty
|
|
162
|
+
return :empty
|
|
163
|
+
elsif ! self.class.cached?
|
|
164
|
+
mofile.update!
|
|
165
|
+
end
|
|
166
|
+
return mofile
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
path = @locale_path.current_path(lang)
|
|
170
|
+
|
|
171
|
+
if path
|
|
172
|
+
charset = @output_charset || lang.charset || Locale.charset || "UTF-8"
|
|
173
|
+
@mofiles[lang_key] = MOFile.open(path, charset)
|
|
174
|
+
else
|
|
175
|
+
@mofiles[lang_key] = :empty
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
gettext/textdomain_group - GetText::TextDomainGroup class
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2009 Masao Mutoh
|
|
5
|
+
|
|
6
|
+
You may redistribute it and/or modify it under the same
|
|
7
|
+
license terms as Ruby.
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
module GetText
|
|
12
|
+
|
|
13
|
+
class TextDomainGroup
|
|
14
|
+
attr_reader :textdomains
|
|
15
|
+
|
|
16
|
+
def initialize
|
|
17
|
+
@textdomains = []
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def add(textdomain)
|
|
21
|
+
@textdomains.unshift(textdomain) unless @textdomains.include? textdomain
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
gettext/textdomain_manager - GetText::TextDomainManager class
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2009 Masao Mutoh
|
|
5
|
+
|
|
6
|
+
You may redistribute it and/or modify it under the same
|
|
7
|
+
license terms as Ruby.
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
require 'gettext/class_info'
|
|
12
|
+
require 'gettext/textdomain'
|
|
13
|
+
require 'gettext/textdomain_group'
|
|
14
|
+
|
|
15
|
+
module GetText
|
|
16
|
+
|
|
17
|
+
module TextDomainManager
|
|
18
|
+
|
|
19
|
+
@@textdomain_pool = {}
|
|
20
|
+
@@textdomain_group_pool = {}
|
|
21
|
+
|
|
22
|
+
@@output_charset = nil
|
|
23
|
+
@@gettext_classes = []
|
|
24
|
+
|
|
25
|
+
@@singular_message_cache = {}
|
|
26
|
+
@@plural_message_cache = {}
|
|
27
|
+
@@cached = ! $DEBUG
|
|
28
|
+
|
|
29
|
+
extend self
|
|
30
|
+
|
|
31
|
+
# Find textdomain by name
|
|
32
|
+
def textdomain_pool(domainname)
|
|
33
|
+
@@textdomain_pool[domainname]
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Set the value whether cache messages or not.
|
|
37
|
+
# true to cache messages, otherwise false.
|
|
38
|
+
#
|
|
39
|
+
# Default is true. If $DEBUG is false, messages are not checked even if
|
|
40
|
+
# this value is true.
|
|
41
|
+
def cached=(val)
|
|
42
|
+
@@cached = val
|
|
43
|
+
TextDomain.cached = val
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Return the cached value.
|
|
47
|
+
def cached?
|
|
48
|
+
TextDomain.cached?
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Gets the output charset.
|
|
52
|
+
def output_charset
|
|
53
|
+
@@output_charset
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Sets the output charset.The program can have a output charset.
|
|
57
|
+
def output_charset=(charset)
|
|
58
|
+
@@output_charset = charset
|
|
59
|
+
@@textdomain_pool.each do |key, textdomain|
|
|
60
|
+
textdomain.output_charset = charset
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# bind textdomain to the class.
|
|
65
|
+
def bind_to(klass, domainname, options = {})
|
|
66
|
+
warn "Bind the domain '#{domainname}' to '#{klass}'. " if $DEBUG
|
|
67
|
+
|
|
68
|
+
charset = options[:output_charset] || self.output_charset
|
|
69
|
+
textdomain = create_or_find_textdomain(domainname,options[:path],charset)
|
|
70
|
+
|
|
71
|
+
target_klass = ClassInfo.normalize_class(klass)
|
|
72
|
+
create_or_find_textdomain_group(target_klass).add(textdomain)
|
|
73
|
+
@@gettext_classes << target_klass unless @@gettext_classes.include? target_klass
|
|
74
|
+
|
|
75
|
+
textdomain
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def each_textdomains(klass) #:nodoc:
|
|
79
|
+
lang = Locale.candidates[0]
|
|
80
|
+
ClassInfo.related_classes(klass, @@gettext_classes).each do |target|
|
|
81
|
+
msg = nil
|
|
82
|
+
if group = @@textdomain_group_pool[target]
|
|
83
|
+
group.textdomains.each do |textdomain|
|
|
84
|
+
yield textdomain, lang
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Translates msgid, but if there are no localized text,
|
|
91
|
+
# it returns a last part of msgid separeted "div" or whole of the msgid with no "div".
|
|
92
|
+
#
|
|
93
|
+
# * msgid: the message id.
|
|
94
|
+
# * div: separator or nil.
|
|
95
|
+
# * Returns: the localized text by msgid. If there are no localized text,
|
|
96
|
+
# it returns a last part of msgid separeted "div".
|
|
97
|
+
def translate_singluar_message(klass, msgid, div = nil)
|
|
98
|
+
klass = ClassInfo.normalize_class(klass)
|
|
99
|
+
key = [Locale.current, klass, msgid, div].hash
|
|
100
|
+
msg = @@singular_message_cache[key]
|
|
101
|
+
return msg if msg and @@cached
|
|
102
|
+
# Find messages from related classes.
|
|
103
|
+
each_textdomains(klass) do |textdomain, lang|
|
|
104
|
+
msg = textdomain.translate_singluar_message(lang, msgid)
|
|
105
|
+
break if msg
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# If not found, return msgid.
|
|
109
|
+
msg ||= msgid
|
|
110
|
+
if div and msg == msgid
|
|
111
|
+
if index = msg.rindex(div)
|
|
112
|
+
msg = msg[(index + 1)..-1]
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
@@singular_message_cache[key] = msg
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# This function is similar to the get_singluar_message function
|
|
119
|
+
# as it finds the message catalogs in the same way.
|
|
120
|
+
# But it takes two extra arguments for plural form.
|
|
121
|
+
# The msgid parameter must contain the singular form of the string to be converted.
|
|
122
|
+
# It is also used as the key for the search in the catalog.
|
|
123
|
+
# The msgid_plural parameter is the plural form.
|
|
124
|
+
# The parameter n is used to determine the plural form.
|
|
125
|
+
# If no message catalog is found msgid1 is returned if n == 1, otherwise msgid2.
|
|
126
|
+
# And if msgid includes "div", it returns a last part of msgid separeted "div".
|
|
127
|
+
#
|
|
128
|
+
# * msgid: the singular form with "div". (e.g. "Special|An apple", "An apple")
|
|
129
|
+
# * msgid_plural: the plural form. (e.g. "%{num} Apples")
|
|
130
|
+
# * n: a number used to determine the plural form.
|
|
131
|
+
# * div: the separator. Default is "|".
|
|
132
|
+
# * Returns: the localized text which key is msgid_plural if n is plural(follow plural-rule) or msgid.
|
|
133
|
+
# "plural-rule" is defined in po-file.
|
|
134
|
+
#
|
|
135
|
+
# or
|
|
136
|
+
#
|
|
137
|
+
# * [msgid, msgid_plural] : msgid and msgid_plural an Array
|
|
138
|
+
# * n: a number used to determine the plural form.
|
|
139
|
+
# * div: the separator. Default is "|".
|
|
140
|
+
def translate_plural_message(klass, arg1, arg2, arg3 = "|", arg4 = "|")
|
|
141
|
+
klass = ClassInfo.normalize_class(klass)
|
|
142
|
+
# parse arguments
|
|
143
|
+
if arg1.kind_of?(Array)
|
|
144
|
+
msgid = arg1[0]
|
|
145
|
+
msgid_plural = arg1[1]
|
|
146
|
+
n = arg2
|
|
147
|
+
if arg3 and arg3.kind_of? Numeric
|
|
148
|
+
raise ArgumentError, _("3rd parmeter is wrong: value = %{number}") % {:number => arg3}
|
|
149
|
+
end
|
|
150
|
+
div = arg3
|
|
151
|
+
else
|
|
152
|
+
msgid = arg1
|
|
153
|
+
msgid_plural = arg2
|
|
154
|
+
n = arg3
|
|
155
|
+
div = arg4
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
key = [Locale.current, klass, msgid, msgid_plural, div].hash
|
|
159
|
+
msgs = @@plural_message_cache[key]
|
|
160
|
+
unless (msgs and @@cached)
|
|
161
|
+
# Find messages from related classes.
|
|
162
|
+
msgs = nil
|
|
163
|
+
each_textdomains(klass) do |textdomain, lang|
|
|
164
|
+
msgs = textdomain.translate_plural_message(lang, msgid, msgid_plural)
|
|
165
|
+
break if msgs
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
msgs = [[msgid, msgid_plural], TextDomain::DEFAULT_PLURAL_CALC] unless msgs
|
|
169
|
+
|
|
170
|
+
msgstrs = msgs[0]
|
|
171
|
+
if div and msgstrs[0] == msgid and index = msgstrs[0].rindex(div)
|
|
172
|
+
msgstrs[0] = msgstrs[0][(index + 1)..-1]
|
|
173
|
+
end
|
|
174
|
+
@@plural_message_cache[key] = msgs
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
# Return the singular or plural message.
|
|
178
|
+
msgstrs = msgs[0]
|
|
179
|
+
plural = msgs[1].call(n)
|
|
180
|
+
return msgstrs[plural] if plural.kind_of?(Numeric)
|
|
181
|
+
return plural ? msgstrs[1] : msgstrs[0]
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
# for testing.
|
|
185
|
+
def clear_all_textdomains
|
|
186
|
+
@@textdomain_pool = {}
|
|
187
|
+
@@textdomain_group_pool = {}
|
|
188
|
+
@@gettext_classes = []
|
|
189
|
+
clear_caches
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
# for testing.
|
|
193
|
+
def clear_caches
|
|
194
|
+
@@singular_message_cache = {}
|
|
195
|
+
@@plural_message_cache = {}
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
def create_or_find_textdomain_group(klass) #:nodoc:
|
|
199
|
+
group = @@textdomain_group_pool[klass]
|
|
200
|
+
return group if group
|
|
201
|
+
|
|
202
|
+
@@textdomain_group_pool[klass] = TextDomainGroup.new
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
def create_or_find_textdomain(name, path, charset)#:nodoc:
|
|
206
|
+
textdomain = @@textdomain_pool[name]
|
|
207
|
+
return textdomain if textdomain
|
|
208
|
+
|
|
209
|
+
@@textdomain_pool[name] = TextDomain.new(name, path, charset)
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
end
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
#! /usr/bin/env ruby
|
|
2
|
+
=begin
|
|
3
|
+
rgettext.rb - Generate a .pot file.
|
|
4
|
+
|
|
5
|
+
Copyright (C) 2003-2009 Masao Mutoh
|
|
6
|
+
Copyright (C) 2001,2002 Yasushi Shoji, Masao Mutoh
|
|
7
|
+
|
|
8
|
+
Yasushi Shoji <yashi at atmark-techno.com>
|
|
9
|
+
Masao Mutoh <mutomasa at gmail.com>
|
|
10
|
+
|
|
11
|
+
You may redistribute it and/or modify it under the same
|
|
12
|
+
license terms as Ruby.
|
|
13
|
+
=end
|
|
14
|
+
|
|
15
|
+
require 'optparse'
|
|
16
|
+
require 'gettext'
|
|
17
|
+
require 'rbconfig'
|
|
18
|
+
|
|
19
|
+
module GetText
|
|
20
|
+
|
|
21
|
+
module RGetText #:nodoc:
|
|
22
|
+
extend GetText
|
|
23
|
+
|
|
24
|
+
bindtextdomain("rgettext")
|
|
25
|
+
|
|
26
|
+
# constant values
|
|
27
|
+
VERSION = GetText::VERSION
|
|
28
|
+
DATE = %w($Date: 2008/08/06 17:35:52 $)[1]
|
|
29
|
+
MAX_LINE_LEN = 70
|
|
30
|
+
|
|
31
|
+
@ex_parsers = []
|
|
32
|
+
[
|
|
33
|
+
["glade.rb", "GladeParser"],
|
|
34
|
+
["erb.rb", "ErbParser"],
|
|
35
|
+
# ["active_record.rb", "ActiveRecordParser"],
|
|
36
|
+
# ["ripper.rb", "RipperParser"],
|
|
37
|
+
["ruby.rb", "RubyParser"] # Default parser.
|
|
38
|
+
].each do |f, klass|
|
|
39
|
+
begin
|
|
40
|
+
require "gettext/parser/#{f}"
|
|
41
|
+
@ex_parsers << GetText.const_get(klass)
|
|
42
|
+
rescue
|
|
43
|
+
$stderr.puts _("'%{klass}' is ignored.") % {:klass => klass}
|
|
44
|
+
$stderr.puts $! if $DEBUG
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
module_function
|
|
49
|
+
|
|
50
|
+
# Add an option parser
|
|
51
|
+
# the option parser module requires to have target?(file) and parser(file, ary) method.
|
|
52
|
+
#
|
|
53
|
+
# require 'gettext/rgettext'
|
|
54
|
+
# module FooParser
|
|
55
|
+
# module_function
|
|
56
|
+
# def target?(file)
|
|
57
|
+
# File.extname(file) == '.foo' # *.foo file only.
|
|
58
|
+
# end
|
|
59
|
+
# def parse(file, ary)
|
|
60
|
+
# :
|
|
61
|
+
# return ary # [["msgid1", "foo.rb:200"], ["msgid2", "bar.rb:300", "baz.rb:400"], ...]
|
|
62
|
+
# end
|
|
63
|
+
# end
|
|
64
|
+
#
|
|
65
|
+
# GetText::RGetText.add_parser(FooParser)
|
|
66
|
+
def add_parser(klass)
|
|
67
|
+
@ex_parsers.insert(0, klass)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def generate_pot_header # :nodoc:
|
|
71
|
+
time = Time.now.strftime("%Y-%m-%d %H:%M")
|
|
72
|
+
off = Time.now.utc_offset
|
|
73
|
+
sign = off <= 0 ? '-' : '+'
|
|
74
|
+
time += sprintf('%s%02d%02d', sign, *(off.abs / 60).divmod(60))
|
|
75
|
+
|
|
76
|
+
<<TITLE
|
|
77
|
+
# SOME DESCRIPTIVE TITLE.
|
|
78
|
+
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
|
79
|
+
# This file is distributed under the same license as the PACKAGE package.
|
|
80
|
+
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
|
81
|
+
#
|
|
82
|
+
#, fuzzy
|
|
83
|
+
msgid ""
|
|
84
|
+
msgstr ""
|
|
85
|
+
"Project-Id-Version: PACKAGE VERSION\\n"
|
|
86
|
+
"POT-Creation-Date: #{time}\\n"
|
|
87
|
+
"PO-Revision-Date: #{time}\\n"
|
|
88
|
+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"
|
|
89
|
+
"Language-Team: LANGUAGE <LL@li.org>\\n"
|
|
90
|
+
"MIME-Version: 1.0\\n"
|
|
91
|
+
"Content-Type: text/plain; charset=UTF-8\\n"
|
|
92
|
+
"Content-Transfer-Encoding: 8bit\\n"
|
|
93
|
+
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n"
|
|
94
|
+
TITLE
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def generate_pot(ary) # :nodoc:
|
|
98
|
+
str = ""
|
|
99
|
+
ary.each do |target|
|
|
100
|
+
# extracted comments
|
|
101
|
+
if target.extracted_comment
|
|
102
|
+
target.extracted_comment.split("\n").each do |comment_line|
|
|
103
|
+
str << "\n#. #{comment_line.strip}"
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# references
|
|
108
|
+
curr_pos = MAX_LINE_LEN
|
|
109
|
+
target.occurrences.each do |e|
|
|
110
|
+
if curr_pos + e.size > MAX_LINE_LEN
|
|
111
|
+
str << "\n#:"
|
|
112
|
+
curr_pos = 3
|
|
113
|
+
else
|
|
114
|
+
curr_pos += (e.size + 1)
|
|
115
|
+
end
|
|
116
|
+
str << " " << e
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# msgctxt, msgid, msgstr
|
|
120
|
+
str << "\nmsgctxt \"" << target.msgctxt << "\"" if target.msgctxt
|
|
121
|
+
str << "\nmsgid \"" << target.escaped(:msgid) << "\"\n"
|
|
122
|
+
if target.plural
|
|
123
|
+
str << "msgid_plural \"" << target.escaped(:plural) << "\"\n"
|
|
124
|
+
str << "msgstr[0] \"\"\n"
|
|
125
|
+
str << "msgstr[1] \"\"\n"
|
|
126
|
+
else
|
|
127
|
+
str << "msgstr \"\"\n"
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
str
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def parse(files) # :nodoc:
|
|
134
|
+
ary = []
|
|
135
|
+
files.each do |file|
|
|
136
|
+
begin
|
|
137
|
+
@ex_parsers.each do |klass|
|
|
138
|
+
if klass.target?(file)
|
|
139
|
+
ary = klass.parse(file, ary)
|
|
140
|
+
break
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
rescue
|
|
144
|
+
puts "Error parsing " + file
|
|
145
|
+
raise
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
ary
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def check_options # :nodoc:
|
|
152
|
+
output = STDOUT
|
|
153
|
+
|
|
154
|
+
opts = OptionParser.new
|
|
155
|
+
opts.banner = _("Usage: %s input.rb [-r parser.rb] [-o output.pot]") % $0
|
|
156
|
+
opts.separator("")
|
|
157
|
+
opts.separator(_("Extract translatable strings from given input files."))
|
|
158
|
+
opts.separator("")
|
|
159
|
+
opts.separator(_("Specific options:"))
|
|
160
|
+
|
|
161
|
+
opts.on("-o", "--output=FILE", _("write output to specified file")) do |out|
|
|
162
|
+
unless FileTest.exist? out
|
|
163
|
+
output = File.new(File.expand_path(out), "w+")
|
|
164
|
+
else
|
|
165
|
+
$stderr.puts(_("File '%s' already exists.") % out)
|
|
166
|
+
exit 1
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
opts.on("-r", "--require=library", _("require the library before executing rgettext")) do |out|
|
|
171
|
+
require out
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
opts.on("-d", "--debug", _("run in debugging mode")) do
|
|
175
|
+
$DEBUG = true
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
opts.on_tail("--version", _("display version information and exit")) do
|
|
179
|
+
puts "#{$0} #{VERSION} (#{DATE})"
|
|
180
|
+
puts "#{File.join(Config::CONFIG["bindir"], Config::CONFIG["RUBY_INSTALL_NAME"])} #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
|
181
|
+
exit
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
opts.parse!(ARGV)
|
|
185
|
+
|
|
186
|
+
if ARGV.size == 0
|
|
187
|
+
puts opts.help
|
|
188
|
+
exit 1
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
[ARGV, output]
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def run(targetfiles = nil, out = STDOUT) # :nodoc:
|
|
195
|
+
if targetfiles.is_a? String
|
|
196
|
+
targetfiles = [targetfiles]
|
|
197
|
+
elsif ! targetfiles
|
|
198
|
+
targetfiles, out = check_options
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
if targetfiles.size == 0
|
|
202
|
+
raise ArgumentError, _("no input files")
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
if out.is_a? String
|
|
206
|
+
File.open(File.expand_path(out), "w+") do |file|
|
|
207
|
+
file.puts generate_pot_header
|
|
208
|
+
file.puts generate_pot(parse(targetfiles))
|
|
209
|
+
end
|
|
210
|
+
else
|
|
211
|
+
out.puts generate_pot_header
|
|
212
|
+
out.puts generate_pot(parse(targetfiles))
|
|
213
|
+
end
|
|
214
|
+
self
|
|
215
|
+
end
|
|
216
|
+
end
|
|
217
|
+
extend self
|
|
218
|
+
# Creates a po-file from targetfiles(ruby-script-files, .rhtml files, glade-2 XML files),
|
|
219
|
+
# then output the result to out. If no parameter is set, it behaves same as command line tools(rgettet).
|
|
220
|
+
#
|
|
221
|
+
# This function is a part of GetText.create_pofiles.
|
|
222
|
+
# Usually you don't need to call this function directly.
|
|
223
|
+
#
|
|
224
|
+
# * targetfiles: An Array of po-files or nil.
|
|
225
|
+
# * out: output IO or output path.
|
|
226
|
+
# * Returns: self
|
|
227
|
+
def rgettext(targetfiles = nil, out = STDOUT)
|
|
228
|
+
RGetText.run(targetfiles, out)
|
|
229
|
+
self
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
if $0 == __FILE__
|
|
234
|
+
GetText.rgettext
|
|
235
|
+
# GetText.rgettext($0, "tmp.txt")
|
|
236
|
+
end
|