fair-gettext 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +56 -0
- data/ChangeLog-1 +2016 -0
- data/NEWS-1 +414 -0
- data/benchmark/1.93.0.txt +8 -0
- data/benchmark/2.0.0.txt +8 -0
- data/benchmark/2.0.4.txt +11 -0
- data/benchmark/2.1.0.txt +11 -0
- data/benchmark/benchmark.rb +68 -0
- data/benchmark/test.rb +28 -0
- 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/ua/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/gettext-2.0.0.gem +0 -0
- data/gettext.gemspec +2 -3
- data/lib/gettext/runtime/class_info.rb +67 -0
- data/lib/gettext/runtime/locale_path.rb +122 -0
- data/lib/gettext/runtime/mofile.rb +330 -0
- data/lib/gettext/runtime/textdomain.rb +177 -0
- data/lib/gettext/runtime/textdomain_group.rb +24 -0
- data/lib/gettext/runtime/textdomain_manager.rb +211 -0
- data/lib/gettext/tools.rb +38 -31
- data/lib/gettext/tools/parser/erb.rb +52 -0
- data/lib/gettext/tools/parser/glade.rb +98 -0
- data/lib/gettext/tools/parser/ruby.rb +226 -0
- data/lib/gettext/tools/pomessage.rb +197 -0
- data/lib/gettext/tools/poparser.rb +356 -0
- data/lib/gettext/tools/rgettext.rb +55 -33
- data/replace.rb +8 -0
- 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/hellolib.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/hellolib.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/hellolib.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/hellolib.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/hellolib.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/hellolib.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/hellolib.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/hellolib.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/hellolib.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/hellolib.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/hellolib.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/hellolib.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/hellolib.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/hellolib.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/hellolib.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/hellolib.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/hellolib.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/hellolib.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/hellolib.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/hellolib.mo +0 -0
- data/samples/cgi/locale/sr/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/ua/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/ua/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/ua/LC_MESSAGES/hellolib.mo +0 -0
- data/samples/cgi/locale/ua/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/hellolib.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/hellolib.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/hellolib.mo +0 -0
- data/samples/cgi/locale/zh_TW/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/po/bg/#main.po# +84 -0
- data/samples/locale/bg/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/bg/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/bg/LC_MESSAGES/hello_glade2.mo +0 -0
- data/samples/locale/bg/LC_MESSAGES/hello_gtk.mo +0 -0
- data/samples/locale/bg/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/bg/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/bg/LC_MESSAGES/hello_tk.mo +0 -0
- data/samples/locale/bs/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/bs/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/bs/LC_MESSAGES/hello_glade2.mo +0 -0
- data/samples/locale/bs/LC_MESSAGES/hello_gtk.mo +0 -0
- data/samples/locale/bs/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/bs/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/bs/LC_MESSAGES/hello_tk.mo +0 -0
- data/samples/locale/ca/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/ca/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/ca/LC_MESSAGES/hello_glade2.mo +0 -0
- data/samples/locale/ca/LC_MESSAGES/hello_gtk.mo +0 -0
- data/samples/locale/ca/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/ca/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/ca/LC_MESSAGES/hello_tk.mo +0 -0
- data/samples/locale/cs/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/cs/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/cs/LC_MESSAGES/hello_glade2.mo +0 -0
- data/samples/locale/cs/LC_MESSAGES/hello_gtk.mo +0 -0
- data/samples/locale/cs/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/cs/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/cs/LC_MESSAGES/hello_tk.mo +0 -0
- data/samples/locale/de/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/de/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/de/LC_MESSAGES/hello_glade2.mo +0 -0
- data/samples/locale/de/LC_MESSAGES/hello_gtk.mo +0 -0
- data/samples/locale/de/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/de/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/de/LC_MESSAGES/hello_tk.mo +0 -0
- data/samples/locale/el/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/el/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/el/LC_MESSAGES/hello_glade2.mo +0 -0
- data/samples/locale/el/LC_MESSAGES/hello_gtk.mo +0 -0
- data/samples/locale/el/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/el/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/el/LC_MESSAGES/hello_tk.mo +0 -0
- data/samples/locale/eo/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/eo/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/eo/LC_MESSAGES/hello_glade2.mo +0 -0
- data/samples/locale/eo/LC_MESSAGES/hello_gtk.mo +0 -0
- data/samples/locale/eo/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/eo/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/eo/LC_MESSAGES/hello_tk.mo +0 -0
- data/samples/locale/es/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/es/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/es/LC_MESSAGES/hello_glade2.mo +0 -0
- data/samples/locale/es/LC_MESSAGES/hello_gtk.mo +0 -0
- data/samples/locale/es/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/es/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/es/LC_MESSAGES/hello_tk.mo +0 -0
- data/samples/locale/fr/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/fr/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/fr/LC_MESSAGES/hello_glade2.mo +0 -0
- data/samples/locale/fr/LC_MESSAGES/hello_gtk.mo +0 -0
- data/samples/locale/fr/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/fr/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/fr/LC_MESSAGES/hello_tk.mo +0 -0
- data/samples/locale/hr/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/hr/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/hr/LC_MESSAGES/hello_glade2.mo +0 -0
- data/samples/locale/hr/LC_MESSAGES/hello_gtk.mo +0 -0
- data/samples/locale/hr/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/hr/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/hr/LC_MESSAGES/hello_tk.mo +0 -0
- data/samples/locale/hu/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/hu/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/hu/LC_MESSAGES/hello_glade2.mo +0 -0
- data/samples/locale/hu/LC_MESSAGES/hello_gtk.mo +0 -0
- data/samples/locale/hu/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/hu/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/hu/LC_MESSAGES/hello_tk.mo +0 -0
- data/samples/locale/it/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/it/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/it/LC_MESSAGES/hello_glade2.mo +0 -0
- data/samples/locale/it/LC_MESSAGES/hello_gtk.mo +0 -0
- data/samples/locale/it/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/it/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/it/LC_MESSAGES/hello_tk.mo +0 -0
- data/samples/locale/ja/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/ja/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/ja/LC_MESSAGES/hello_glade2.mo +0 -0
- data/samples/locale/ja/LC_MESSAGES/hello_gtk.mo +0 -0
- data/samples/locale/ja/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/ja/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/ja/LC_MESSAGES/hello_tk.mo +0 -0
- data/samples/locale/ko/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/ko/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/ko/LC_MESSAGES/hello_glade2.mo +0 -0
- data/samples/locale/ko/LC_MESSAGES/hello_gtk.mo +0 -0
- data/samples/locale/ko/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/ko/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/ko/LC_MESSAGES/hello_tk.mo +0 -0
- data/samples/locale/lv/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/lv/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/lv/LC_MESSAGES/hello_glade2.mo +0 -0
- data/samples/locale/lv/LC_MESSAGES/hello_gtk.mo +0 -0
- data/samples/locale/lv/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/lv/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/lv/LC_MESSAGES/hello_tk.mo +0 -0
- data/samples/locale/nb/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/nb/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/nb/LC_MESSAGES/hello_glade2.mo +0 -0
- data/samples/locale/nb/LC_MESSAGES/hello_gtk.mo +0 -0
- data/samples/locale/nb/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/nb/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/nb/LC_MESSAGES/hello_tk.mo +0 -0
- data/samples/locale/nl/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/nl/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/nl/LC_MESSAGES/hello_glade2.mo +0 -0
- data/samples/locale/nl/LC_MESSAGES/hello_gtk.mo +0 -0
- data/samples/locale/nl/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/nl/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/nl/LC_MESSAGES/hello_tk.mo +0 -0
- data/samples/locale/pt_BR/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/pt_BR/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/pt_BR/LC_MESSAGES/hello_glade2.mo +0 -0
- data/samples/locale/pt_BR/LC_MESSAGES/hello_gtk.mo +0 -0
- data/samples/locale/pt_BR/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/pt_BR/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/pt_BR/LC_MESSAGES/hello_tk.mo +0 -0
- data/samples/locale/ru/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/ru/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/ru/LC_MESSAGES/hello_glade2.mo +0 -0
- data/samples/locale/ru/LC_MESSAGES/hello_gtk.mo +0 -0
- data/samples/locale/ru/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/ru/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/ru/LC_MESSAGES/hello_tk.mo +0 -0
- data/samples/locale/sr/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/sr/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/sr/LC_MESSAGES/hello_glade2.mo +0 -0
- data/samples/locale/sr/LC_MESSAGES/hello_gtk.mo +0 -0
- data/samples/locale/sr/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/sr/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/sr/LC_MESSAGES/hello_tk.mo +0 -0
- data/samples/locale/sv/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/sv/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/sv/LC_MESSAGES/hello_glade2.mo +0 -0
- data/samples/locale/sv/LC_MESSAGES/hello_gtk.mo +0 -0
- data/samples/locale/sv/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/sv/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/sv/LC_MESSAGES/hello_tk.mo +0 -0
- data/samples/locale/ua/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/ua/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/ua/LC_MESSAGES/hello_glade2.mo +0 -0
- data/samples/locale/ua/LC_MESSAGES/hello_gtk.mo +0 -0
- data/samples/locale/ua/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/ua/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/ua/LC_MESSAGES/hello_tk.mo +0 -0
- data/samples/locale/vi/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/vi/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/vi/LC_MESSAGES/hello_glade2.mo +0 -0
- data/samples/locale/vi/LC_MESSAGES/hello_gtk.mo +0 -0
- data/samples/locale/vi/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/vi/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/vi/LC_MESSAGES/hello_tk.mo +0 -0
- data/samples/locale/zh/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/zh/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/zh/LC_MESSAGES/hello_glade2.mo +0 -0
- data/samples/locale/zh/LC_MESSAGES/hello_gtk.mo +0 -0
- data/samples/locale/zh/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/zh/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/zh/LC_MESSAGES/hello_tk.mo +0 -0
- data/samples/locale/zh_TW/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/zh_TW/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/zh_TW/LC_MESSAGES/hello_glade2.mo +0 -0
- data/samples/locale/zh_TW/LC_MESSAGES/hello_gtk.mo +0 -0
- data/samples/locale/zh_TW/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/zh_TW/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/zh_TW/LC_MESSAGES/hello_tk.mo +0 -0
- data/test.rb +33 -0
- data/test/locale/cr/LC_MESSAGES/plural.mo +0 -0
- data/test/locale/da/LC_MESSAGES/plural.mo +0 -0
- data/test/locale/da/LC_MESSAGES/plural_error.mo +0 -0
- data/test/locale/fr/LC_MESSAGES/plural.mo +0 -0
- data/test/locale/fr/LC_MESSAGES/plural_error.mo +0 -0
- data/test/locale/fr/LC_MESSAGES/test1.mo +0 -0
- data/test/locale/fr/LC_MESSAGES/test2.mo +0 -0
- data/test/locale/ir/LC_MESSAGES/plural.mo +0 -0
- data/test/locale/ja/LC_MESSAGES/npgettext.mo +0 -0
- data/test/locale/ja/LC_MESSAGES/nsgettext.mo +0 -0
- data/test/locale/ja/LC_MESSAGES/pgettext.mo +0 -0
- data/test/locale/ja/LC_MESSAGES/plural.mo +0 -0
- data/test/locale/ja/LC_MESSAGES/plural_error.mo +0 -0
- data/test/locale/ja/LC_MESSAGES/rubyparser.mo +0 -0
- data/test/locale/ja/LC_MESSAGES/sgettext.mo +0 -0
- data/test/locale/ja/LC_MESSAGES/test1.mo +0 -0
- data/test/locale/ja/LC_MESSAGES/test2.mo +0 -0
- data/test/locale/ja/LC_MESSAGES/test3.mo +0 -0
- data/test/locale/la/LC_MESSAGES/plural.mo +0 -0
- data/test/locale/la/LC_MESSAGES/plural_error.mo +0 -0
- data/test/locale/li/LC_MESSAGES/plural.mo +0 -0
- data/test/locale/li/LC_MESSAGES/plural_error.mo +0 -0
- data/test/locale/po/LC_MESSAGES/plural.mo +0 -0
- data/test/locale/sl/LC_MESSAGES/plural.mo +0 -0
- data/test/po/ja/test3.po +19 -0
- data/test/po/li/plural_error.po +27 -0
- data/test/test_locale_path.rb +50 -0
- data/test/test_po_generation.rb +20 -0
- data/test/test_pomessage.rb +99 -0
- data/test/test_textdomain_bind.rb +37 -0
- data/test/test_thread.rb +41 -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 +710 -348
@@ -0,0 +1,68 @@
|
|
1
|
+
$:.unshift "../../locale/lib"
|
2
|
+
$:.unshift "../../gettext/lib"
|
3
|
+
|
4
|
+
#require 'rubygems'
|
5
|
+
require 'benchmark'
|
6
|
+
require 'gettext'
|
7
|
+
|
8
|
+
num = 100000
|
9
|
+
|
10
|
+
def memory
|
11
|
+
pid = Process.pid
|
12
|
+
map = `pmap -d #{pid}`
|
13
|
+
map.split("\n").last.strip.squeeze(' ').split(' ')[3].to_i
|
14
|
+
end
|
15
|
+
|
16
|
+
curr_mem = memory
|
17
|
+
|
18
|
+
class Test
|
19
|
+
include GetText
|
20
|
+
bindtextdomain("test1", :path => "../test/locale")
|
21
|
+
def test
|
22
|
+
_("language")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
p GetText::VERSION
|
27
|
+
Benchmark.bm(25){|x|
|
28
|
+
x.report("bindtextdomain"){ num.times{|i|
|
29
|
+
GetText.bindtextdomain("test1", :path => "../test/locale")
|
30
|
+
#GetText.bindtextdomain("test1", "../test/locale")
|
31
|
+
} }
|
32
|
+
x.report("set_locale"){ num.times{|i|
|
33
|
+
GetText.locale = "ja"
|
34
|
+
} }
|
35
|
+
GetText.locale = "ja"
|
36
|
+
x.report("gettext ja"){ num.times{|i|
|
37
|
+
GetText._("language")
|
38
|
+
} }
|
39
|
+
GetText.locale = "en"
|
40
|
+
x.report("gettext en (not found)"){ num.times{|i|
|
41
|
+
GetText._("language")
|
42
|
+
} }
|
43
|
+
|
44
|
+
GetText.bindtextdomain("plural", :path => "../test/locale")
|
45
|
+
#GetText.bindtextdomain("plural", "../test/locale")
|
46
|
+
GetText.locale = "ja"
|
47
|
+
x.report("ngettext ja"){ (num / 2).times{|i|
|
48
|
+
GetText.n_("single", "plural", 1)
|
49
|
+
GetText.n_("single", "plural", 2)
|
50
|
+
} }
|
51
|
+
GetText.locale = "en"
|
52
|
+
x.report("ngettext en (not found)"){ (num / 2).times{|i|
|
53
|
+
GetText.n_("single", "plural", 1)
|
54
|
+
GetText.n_("single", "plural", 2)
|
55
|
+
} }
|
56
|
+
|
57
|
+
GetText.locale = "ja"
|
58
|
+
x.report("create object ja"){ num.times{|i|
|
59
|
+
Test.new.test
|
60
|
+
} }
|
61
|
+
GetText.locale = "en"
|
62
|
+
x.report("create object en"){ num.times{|i|
|
63
|
+
Test.new.test
|
64
|
+
} }
|
65
|
+
}
|
66
|
+
|
67
|
+
GC.start
|
68
|
+
puts "#{memory - curr_mem}K "
|
data/benchmark/test.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'benchmark'
|
2
|
+
|
3
|
+
def test(s)
|
4
|
+
ret = ""
|
5
|
+
if s =~ /^\#<|^$/ or s == "GetText"
|
6
|
+
#if s.size == 0 or s[0..1] = "#<" or s == "GetText"
|
7
|
+
ret = Object
|
8
|
+
end
|
9
|
+
ret
|
10
|
+
end
|
11
|
+
|
12
|
+
num = 100000
|
13
|
+
|
14
|
+
Benchmark.bm(25){|x|
|
15
|
+
x.report("test matched"){ num.times{|i|
|
16
|
+
test("#<foo>")
|
17
|
+
} }
|
18
|
+
x.report("test matched nodata"){ num.times{|i|
|
19
|
+
test("")
|
20
|
+
} }
|
21
|
+
x.report("test matched GetText"){ num.times{|i|
|
22
|
+
test("GetText")
|
23
|
+
} }
|
24
|
+
x.report("test not matched"){ num.times{|i|
|
25
|
+
test("FooBar")
|
26
|
+
} }
|
27
|
+
|
28
|
+
}
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/gettext-2.0.0.gem
ADDED
Binary file
|
data/gettext.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{fair-gettext}
|
5
|
-
s.version = "2.0.
|
5
|
+
s.version = "2.0.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Masao Mutoh"]
|
@@ -11,8 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.email = %q{mutomasa at gmail.com}
|
12
12
|
s.executables = ["rgettext", "rmsgmerge", "rmsgfmt"]
|
13
13
|
s.extra_rdoc_files = ["lib/gettext.rb", "lib/gettext/tools.rb", "lib/gettext/core_ext/string.rb", "lib/gettext/version.rb", "README.rdoc"]
|
14
|
-
s.files = ["
|
15
|
-
"po/el/rgettext.po", "po/bs/rgettext.po", "po/et/rgettext.po", "po/vi/rgettext.po", "po/pt_BR/rgettext.po", "po/nb/rgettext.po", "po/ko/rgettext.po", "po/lv/rgettext.po", "po/ru/rgettext.po", "po/zh_TW/rgettext.po", "po/rgettext.pot", "po/ca/rgettext.po", "po/de/rgettext.po", "po/es/rgettext.po", "po/eo/rgettext.po", "po/nl/rgettext.po", "po/sr/rgettext.po", "po/hu/rgettext.po", "po/zh/rgettext.po", "po/ja/rgettext.po", "po/bg/rgettext.po", "po/ua/rgettext.po", "po/fr/rgettext.po", "po/sv/rgettext.po", "po/it/rgettext.po", "lib/gettext.rb", "lib/gettext/cgi.rb", "lib/gettext/utils.rb", "lib/gettext/tools.rb", "lib/gettext/core_ext/iconv.rb", "lib/gettext/core_ext/string.rb", "lib/gettext/version.rb", "lib/gettext/parser/glade.rb", "lib/gettext/parser/erb.rb", "lib/gettext/parser/ruby.rb", "lib/gettext/tools/rgettext.rb", "lib/gettext/tools/rmsgmerge.rb", "lib/gettext/tools/rmsgfmt.rb", "test/po/po/plural.po", "test/po/cr/plural.po", "test/po/sl/plural.po", "test/po/li/plural.po", "test/po/ir/plural.po", "test/po/ja/sgettext.po", "test/po/ja/test2.po", "test/po/ja/pgettext.po", "test/po/ja/test1.po", "test/po/ja/nsgettext.po", "test/po/ja/plural_error.po", "test/po/ja/plural.po", "test/po/ja/rubyparser.po", "test/po/ja/npgettext.po", "test/po/fr/test2.po", "test/po/fr/test1.po", "test/po/fr/plural_error.po", "test/po/fr/plural.po", "test/po/la/plural_error.po", "test/po/la/plural.po", "test/po/da/plural_error.po", "test/po/da/plural.po", "test/test_textdomain_toplevel.rb", "test/test_gettext.rb", "test/test_parser.rb", "test/README", "test/test_string.rb", "test/Rakefile", "test/test_class_info.rb", "test/test_textdomain_multi.rb", "test/testlib/simple.rb", "test/testlib/gettext.rb", "test/testlib/gladeparser.glade", "test/testlib/npgettext.rb", "test/testlib/multi_textdomain.rb", "test/testlib/erb.rhtml", "test/testlib/nsgettext.rb", "test/testlib/erb.rxml", "test/testlib/pgettext.rb", "test/testlib/helper.rb", "test/testlib/N_.rb", "test/testlib/ngettext.rb", "test/testlib/sgettext.rb", "bin/rgettext", "bin/rmsgmerge", "bin/rmsgfmt", "Rakefile", "README.rdoc", "ChangeLog", "src/poparser.ry", "samples/cgi/po/hr/main.po", "samples/cgi/po/hr/hellolib.po", "samples/cgi/po/hr/helloerb1.po", "samples/cgi/po/hr/helloerb2.po", "samples/cgi/po/cs/main.po", "samples/cgi/po/cs/hellolib.po", "samples/cgi/po/cs/helloerb1.po", "samples/cgi/po/cs/helloerb2.po", "samples/cgi/po/hellolib.pot", "samples/cgi/po/el/main.po", "samples/cgi/po/el/hellolib.po", "samples/cgi/po/el/helloerb1.po", "samples/cgi/po/el/helloerb2.po", "samples/cgi/po/bs/main.po", "samples/cgi/po/bs/hellolib.po", "samples/cgi/po/bs/helloerb1.po", "samples/cgi/po/bs/helloerb2.po", "samples/cgi/po/vi/main.po", "samples/cgi/po/vi/hellolib.po", "samples/cgi/po/vi/helloerb1.po", "samples/cgi/po/vi/helloerb2.po", "samples/cgi/po/pt_BR/main.po", "samples/cgi/po/pt_BR/hellolib.po", "samples/cgi/po/pt_BR/helloerb1.po", "samples/cgi/po/pt_BR/helloerb2.po", "samples/cgi/po/nb/main.po", "samples/cgi/po/nb/hellolib.po", "samples/cgi/po/nb/helloerb1.po", "samples/cgi/po/nb/helloerb2.po", "samples/cgi/po/ko/main.po", "samples/cgi/po/ko/hellolib.po", "samples/cgi/po/ko/helloerb1.po", "samples/cgi/po/ko/helloerb2.po", "samples/cgi/po/lv/main.po", "samples/cgi/po/lv/hellolib.po", "samples/cgi/po/lv/helloerb1.po", "samples/cgi/po/lv/helloerb2.po", "samples/cgi/po/ru/main.po", "samples/cgi/po/ru/hellolib.po", "samples/cgi/po/ru/helloerb1.po", "samples/cgi/po/ru/helloerb2.po", "samples/cgi/po/zh_TW/main.po", "samples/cgi/po/zh_TW/hellolib.po", "samples/cgi/po/zh_TW/helloerb1.po", "samples/cgi/po/zh_TW/helloerb2.po", "samples/cgi/po/ca/main.po", "samples/cgi/po/ca/hellolib.po", "samples/cgi/po/ca/helloerb1.po", "samples/cgi/po/ca/helloerb2.po", "samples/cgi/po/de/main.po", "samples/cgi/po/de/hellolib.po", "samples/cgi/po/de/helloerb1.po", "samples/cgi/po/de/helloerb2.po", "samples/cgi/po/es/main.po", "samples/cgi/po/es/hellolib.po", "samples/cgi/po/es/helloerb1.po", "samples/cgi/po/es/helloerb2.po", "samples/cgi/po/eo/main.po", "samples/cgi/po/eo/hellolib.po", "samples/cgi/po/eo/helloerb1.po", "samples/cgi/po/eo/helloerb2.po", "samples/cgi/po/nl/main.po", "samples/cgi/po/nl/hellolib.po", "samples/cgi/po/nl/helloerb1.po", "samples/cgi/po/nl/helloerb2.po", "samples/cgi/po/sr/main.po", "samples/cgi/po/sr/hellolib.po", "samples/cgi/po/sr/helloerb1.po", "samples/cgi/po/sr/helloerb2.po", "samples/cgi/po/hu/main.po", "samples/cgi/po/hu/hellolib.po", "samples/cgi/po/hu/helloerb1.po", "samples/cgi/po/hu/helloerb2.po", "samples/cgi/po/helloerb1.pot", "samples/cgi/po/helloerb2.pot", "samples/cgi/po/zh/main.po", "samples/cgi/po/zh/hellolib.po", "samples/cgi/po/zh/helloerb1.po", "samples/cgi/po/zh/helloerb2.po", "samples/cgi/po/ja/main.po", "samples/cgi/po/ja/hellolib.po", "samples/cgi/po/ja/helloerb1.po", "samples/cgi/po/ja/helloerb2.po", "samples/cgi/po/bg/main.po", "samples/cgi/po/bg/hellolib.po", "samples/cgi/po/bg/helloerb1.po", "samples/cgi/po/bg/helloerb2.po", "samples/cgi/po/main.pot", "samples/cgi/po/ua/main.po", "samples/cgi/po/ua/hellolib.po", "samples/cgi/po/ua/helloerb1.po", "samples/cgi/po/ua/helloerb2.po", "samples/cgi/po/fr/main.po", "samples/cgi/po/fr/hellolib.po", "samples/cgi/po/fr/helloerb1.po", "samples/cgi/po/fr/helloerb2.po", "samples/cgi/po/it/main.po", "samples/cgi/po/it/hellolib.po", "samples/cgi/po/it/helloerb1.po", "samples/cgi/po/it/helloerb2.po", "samples/cgi/hellolib.rb", "samples/cgi/helloerb1.cgi", "samples/cgi/cookie.cgi", "samples/cgi/README", "samples/cgi/other.rhtml", "samples/cgi/Rakefile", "samples/cgi/gettext.css", "samples/cgi/helloerb2.cgi", "samples/cgi/http.rb", "samples/cgi/helloerb.rhtml", "samples/cgi/index.cgi", "samples/po/hello_plural.pot", "samples/po/hr/hello_glade2.po", "samples/po/hr/hello_plural.po", "samples/po/hr/hello_noop.po", "samples/po/hr/hello.po", "samples/po/hr/hello2.po", "samples/po/hr/hello_tk.po", "samples/po/hr/hello_gtk.po", "samples/po/cs/hello_glade2.po", "samples/po/cs/hello_plural.po", "samples/po/cs/hello_noop.po", "samples/po/cs/hello.po", "samples/po/cs/hello2.po", "samples/po/cs/hello_tk.po", "samples/po/cs/hello_gtk.po", "samples/po/el/hello_glade2.po", "samples/po/el/hello_plural.po", "samples/po/el/hello_noop.po", "samples/po/el/hello.po", "samples/po/el/hello2.po", "samples/po/el/hello_tk.po", "samples/po/el/hello_gtk.po", "samples/po/bs/hello_glade2.po", "samples/po/bs/hello_plural.po", "samples/po/bs/hello_noop.po", "samples/po/bs/hello.po", "samples/po/bs/hello2.po", "samples/po/bs/hello_tk.po", "samples/po/bs/hello_gtk.po", "samples/po/vi/hello_glade2.po", "samples/po/vi/hello_plural.po", "samples/po/vi/hello_noop.po", "samples/po/vi/hello.po", "samples/po/vi/hello2.po", "samples/po/vi/hello_tk.po", "samples/po/vi/hello_gtk.po", "samples/po/pt_BR/hello_glade2.po", "samples/po/pt_BR/hello_plural.po", "samples/po/pt_BR/hello_noop.po", "samples/po/pt_BR/hello.po", "samples/po/pt_BR/hello2.po", "samples/po/pt_BR/hello_tk.po", "samples/po/pt_BR/hello_gtk.po", "samples/po/nb/hello_glade2.po", "samples/po/nb/hello_plural.po", "samples/po/nb/hello_noop.po", "samples/po/nb/hello.po", "samples/po/nb/hello2.po", "samples/po/nb/hello_tk.po", "samples/po/nb/hello_gtk.po", "samples/po/hello_noop.pot", "samples/po/ko/hello_glade2.po", "samples/po/ko/hello_plural.po", "samples/po/ko/hello_noop.po", "samples/po/ko/hello.po", "samples/po/ko/hello2.po", "samples/po/ko/hello_tk.po", "samples/po/ko/hello_gtk.po", "samples/po/lv/hello_glade2.po", "samples/po/lv/hello_plural.po", "samples/po/lv/hello_noop.po", "samples/po/lv/hello.po", "samples/po/lv/hello2.po", "samples/po/lv/hello_tk.po", "samples/po/lv/hello_gtk.po", "samples/po/ru/hello_glade2.po", "samples/po/ru/hello_plural.po", "samples/po/ru/hello_noop.po", "samples/po/ru/hello.po", "samples/po/ru/hello2.po", "samples/po/ru/hello_tk.po", "samples/po/ru/hello_gtk.po", "samples/po/zh_TW/hello_glade2.po", "samples/po/zh_TW/hello_plural.po", "samples/po/zh_TW/hello_noop.po", "samples/po/zh_TW/hello.po", "samples/po/zh_TW/hello2.po", "samples/po/zh_TW/hello_tk.po", "samples/po/zh_TW/hello_gtk.po", "samples/po/ca/hello_glade2.po", "samples/po/ca/hello_plural.po", "samples/po/ca/hello_noop.po", "samples/po/ca/hello.po", "samples/po/ca/hello2.po", "samples/po/ca/hello_tk.po", "samples/po/ca/hello_gtk.po", "samples/po/hello2.pot", "samples/po/de/hello_glade2.po", "samples/po/de/hello_plural.po", "samples/po/de/hello_noop.po", "samples/po/de/hello.po", "samples/po/de/hello2.po", "samples/po/de/hello_tk.po", "samples/po/de/hello_gtk.po", "samples/po/es/hello_glade2.po", "samples/po/es/hello_plural.po", "samples/po/es/hello_noop.po", "samples/po/es/hello.po", "samples/po/es/hello2.po", "samples/po/es/hello_tk.po", "samples/po/es/hello_gtk.po", "samples/po/hello_gtk.pot", "samples/po/eo/hello_glade2.po", "samples/po/eo/hello_plural.po", "samples/po/eo/hello_noop.po", "samples/po/eo/hello.po", "samples/po/eo/hello2.po", "samples/po/eo/hello_tk.po", "samples/po/eo/hello_gtk.po", "samples/po/nl/hello_glade2.po", "samples/po/nl/hello_plural.po", "samples/po/nl/hello_noop.po", "samples/po/nl/hello.po", "samples/po/nl/hello2.po", "samples/po/nl/hello_tk.po", "samples/po/nl/hello_gtk.po", "samples/po/sr/hello_glade2.po", "samples/po/sr/hello_plural.po", "samples/po/sr/hello_noop.po", "samples/po/sr/hello.po", "samples/po/sr/hello2.po", "samples/po/sr/hello_tk.po", "samples/po/sr/hello_gtk.po", "samples/po/hello.pot", "samples/po/hu/hello_glade2.po", "samples/po/hu/hello_plural.po", "samples/po/hu/hello_noop.po", "samples/po/hu/hello.po", "samples/po/hu/hello2.po", "samples/po/hu/hello_tk.po", "samples/po/hu/hello_gtk.po", "samples/po/zh/hello_glade2.po", "samples/po/zh/hello_plural.po", "samples/po/zh/hello_noop.po", "samples/po/zh/hello.po", "samples/po/zh/hello2.po", "samples/po/zh/hello_tk.po", "samples/po/zh/hello_gtk.po", "samples/po/test.rb", "samples/po/ja/hello_glade2.po", "samples/po/ja/hello_plural.po", "samples/po/ja/hello_noop.po", "samples/po/ja/hello.po", "samples/po/ja/hello2.po", "samples/po/ja/hello_tk.po", "samples/po/ja/hello_gtk.po", "samples/po/bg/hello_glade2.po", "samples/po/bg/hello_plural.po", "samples/po/bg/hello_noop.po", "samples/po/bg/hello.po", "samples/po/bg/hello2.po", "samples/po/bg/hello_tk.po", "samples/po/bg/hello_gtk.po", "samples/po/ua/hello_glade2.po", "samples/po/ua/hello_plural.po", "samples/po/ua/hello_noop.po", "samples/po/ua/hello.po", "samples/po/ua/hello2.po", "samples/po/ua/hello_tk.po", "samples/po/ua/hello_gtk.po", "samples/po/fr/hello_glade2.po", "samples/po/fr/hello_plural.po", "samples/po/fr/hello_noop.po", "samples/po/fr/hello.po", "samples/po/fr/hello2.po", "samples/po/fr/hello_tk.po", "samples/po/fr/hello_gtk.po", "samples/po/hello_tk.pot", "samples/po/sv/hello_glade2.po", "samples/po/sv/hello_plural.po", "samples/po/sv/hello_noop.po", "samples/po/sv/hello.po", "samples/po/sv/hello2.po", "samples/po/sv/hello_tk.po", "samples/po/sv/hello_gtk.po", "samples/po/hello_glade2.pot", "samples/po/it/hello_glade2.po", "samples/po/it/hello_plural.po", "samples/po/it/hello_noop.po", "samples/po/it/hello.po", "samples/po/it/hello2.po", "samples/po/it/hello_tk.po", "samples/po/it/hello_gtk.po", "samples/hello_noop.rb", "samples/hello_plural.rb", "samples/makemo.rb", "samples/hello_glade2.glade", "samples/hello.rb", "samples/hello_gtk2.rb", "samples/README", "samples/hello_glade2.rb", "samples/hello2.rb", "samples/hello_tk.rb", "gettext.gemspec"]
|
14
|
+
s.files = Dir["**/*"].to_a
|
16
15
|
s.has_rdoc = true
|
17
16
|
s.homepage = %q{http://gettext.rubyforge.org/}
|
18
17
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "GetText", "--main", "README.rdoc"]
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'locale/util/memoizable'
|
2
|
+
|
3
|
+
module GetText
|
4
|
+
# For normalize/finding the related classes/modules.
|
5
|
+
# This is used for realizing the scope of TextDomain.
|
6
|
+
# (see: http://www.yotabanana.com/hiki/ruby-gettext-scope.html)
|
7
|
+
module ClassInfo
|
8
|
+
extend self
|
9
|
+
include Locale::Util::Memoizable
|
10
|
+
|
11
|
+
# normalize the class name
|
12
|
+
# klass should kind of the class, not object.
|
13
|
+
def normalize_class(klass)
|
14
|
+
ret = (klass.kind_of? Module) ? klass : klass.class
|
15
|
+
if ret.name =~ /^\#<|^$/ or ret == GetText
|
16
|
+
ret = Object
|
17
|
+
end
|
18
|
+
ret
|
19
|
+
end
|
20
|
+
|
21
|
+
def root_ancestors # :nodoc:
|
22
|
+
Object.ancestors
|
23
|
+
end
|
24
|
+
memoize :root_ancestors
|
25
|
+
|
26
|
+
# Internal method for related_classes.
|
27
|
+
def related_classes_internal(klass, all_classes = [], analyzed_classes = [] )
|
28
|
+
ret = []
|
29
|
+
klass = normalize_class(klass)
|
30
|
+
|
31
|
+
return [Object] if root_ancestors.include? klass
|
32
|
+
|
33
|
+
ary = klass.name.split(/::/)
|
34
|
+
while(v = ary.shift)
|
35
|
+
ret.unshift(((ret.size == 0) ? Object.const_get(v) : ret[0].const_get(v)))
|
36
|
+
end
|
37
|
+
ret -= analyzed_classes
|
38
|
+
if ret.size > 1
|
39
|
+
ret += related_classes_internal(ret[1], all_classes, analyzed_classes)
|
40
|
+
ret.uniq!
|
41
|
+
end
|
42
|
+
analyzed_classes << klass unless analyzed_classes.include? klass
|
43
|
+
|
44
|
+
klass.ancestors[1..-1].each do |a|
|
45
|
+
ret += related_classes_internal(a, all_classes, analyzed_classes)
|
46
|
+
ret.uniq!
|
47
|
+
end
|
48
|
+
|
49
|
+
if all_classes.size > 0
|
50
|
+
(ret & all_classes).uniq
|
51
|
+
else
|
52
|
+
ret.uniq
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Returns the classes which related to klass
|
57
|
+
# (klass's ancestors, included modules and nested modules)
|
58
|
+
def related_classes(klass, all_classes = [])
|
59
|
+
ret = related_classes_internal(klass, all_classes)
|
60
|
+
unless ret.include? Object
|
61
|
+
ret += [Object]
|
62
|
+
end
|
63
|
+
ret
|
64
|
+
end
|
65
|
+
memoize :related_classes
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
=begin
|
2
|
+
locale_path.rb - GetText::LocalePath
|
3
|
+
|
4
|
+
Copyright (C) 2001-2009 Masao Mutoh
|
5
|
+
|
6
|
+
You may redistribute it and/or modify it under the same
|
7
|
+
license terms as Ruby or LGPL.
|
8
|
+
|
9
|
+
=end
|
10
|
+
|
11
|
+
require 'rbconfig'
|
12
|
+
require 'gettext/core_ext/string'
|
13
|
+
|
14
|
+
module GetText
|
15
|
+
# Treats locale-path for mo-files.
|
16
|
+
class LocalePath
|
17
|
+
include Locale::Util::Memoizable
|
18
|
+
|
19
|
+
# The default locale paths.
|
20
|
+
CONFIG_PREFIX = Config::CONFIG['prefix'].gsub(/\/local/, "")
|
21
|
+
DEFAULT_RULES = [
|
22
|
+
"./locale/%{lang}/LC_MESSAGES/%{name}.mo",
|
23
|
+
"./locale/%{lang}/%{name}.mo",
|
24
|
+
"#{Config::CONFIG['datadir']}/locale/%{lang}/LC_MESSAGES/%{name}.mo",
|
25
|
+
"#{Config::CONFIG['datadir'].gsub(/\/local/, "")}/locale/%{lang}/LC_MESSAGES/%{name}.mo",
|
26
|
+
"#{CONFIG_PREFIX}/share/locale/%{lang}/LC_MESSAGES/%{name}.mo",
|
27
|
+
"#{CONFIG_PREFIX}/local/share/locale/%{lang}/LC_MESSAGES/%{name}.mo"
|
28
|
+
].uniq
|
29
|
+
|
30
|
+
class << self
|
31
|
+
include Locale::Util::Memoizable
|
32
|
+
|
33
|
+
# Add default locale path. Usually you should use GetText.add_default_locale_path instead.
|
34
|
+
# * path: a new locale path. (e.g.) "/usr/share/locale/%{lang}/LC_MESSAGES/%{name}.mo"
|
35
|
+
# ('locale' => "ja_JP", 'name' => "textdomain")
|
36
|
+
# * Returns: the new DEFAULT_LOCALE_PATHS
|
37
|
+
def add_default_rule(path)
|
38
|
+
DEFAULT_RULES.unshift(path)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Returns path rules as an Array.
|
42
|
+
# (e.g.) ["/usr/share/locale/%{lang}/LC_MESSAGES/%{name}.mo", ...]
|
43
|
+
def default_path_rules
|
44
|
+
default_path_rules = []
|
45
|
+
|
46
|
+
if ENV["GETTEXT_PATH"]
|
47
|
+
ENV["GETTEXT_PATH"].split(/,/).each {|i|
|
48
|
+
default_path_rules = ["#{i}/%{lang}/LC_MESSAGES/%{name}.mo", "#{i}/%{lang}/%{name}.mo"]
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
default_path_rules += DEFAULT_RULES
|
53
|
+
|
54
|
+
load_path = $LOAD_PATH
|
55
|
+
if defined? ::Gem
|
56
|
+
load_path += Gem.all_load_paths
|
57
|
+
end
|
58
|
+
load_path.map!{|v| v.match(/(.*?)(\/lib)*?$/); $1}
|
59
|
+
load_path.each {|path|
|
60
|
+
default_path_rules += [
|
61
|
+
"#{path}/data/locale/%{lang}/LC_MESSAGES/%{name}.mo",
|
62
|
+
"#{path}/data/locale/%{lang}/%{name}.mo",
|
63
|
+
"#{path}/locale/%{lang}/%{name}.mo"]
|
64
|
+
}
|
65
|
+
# paths existed only.
|
66
|
+
default_path_rules = default_path_rules.select{|path|
|
67
|
+
Dir.glob(path % {:lang => "*", :name => "*"}).size > 0}.uniq
|
68
|
+
default_path_rules
|
69
|
+
end
|
70
|
+
memoize_dup :default_path_rules
|
71
|
+
end
|
72
|
+
|
73
|
+
attr_reader :locale_paths, :supported_locales
|
74
|
+
|
75
|
+
# Creates a new GetText::TextDomain.
|
76
|
+
# * name: the textdomain name.
|
77
|
+
# * topdir: the locale path ("%{topdir}/%{lang}/LC_MESSAGES/%{name}.mo") or nil.
|
78
|
+
def initialize(name, topdir = nil)
|
79
|
+
@name = name
|
80
|
+
|
81
|
+
if topdir
|
82
|
+
path_rules = ["#{topdir}/%{lang}/LC_MESSAGES/%{name}.mo", "#{topdir}/%{lang}/%{name}.mo"]
|
83
|
+
else
|
84
|
+
path_rules = self.class.default_path_rules
|
85
|
+
end
|
86
|
+
|
87
|
+
@locale_paths = {}
|
88
|
+
path_rules.each do |rule|
|
89
|
+
this_path_rules = rule % {:lang => "([^\/]+)", :name => name}
|
90
|
+
Dir.glob(rule %{:lang => "*", :name => name}).each do |path|
|
91
|
+
if /#{this_path_rules}/ =~ path
|
92
|
+
@locale_paths[$1] = path unless @locale_paths[$1]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
@supported_locales = @locale_paths.keys.sort
|
97
|
+
end
|
98
|
+
|
99
|
+
# Gets the current path.
|
100
|
+
# * lang: a Locale::Tag.
|
101
|
+
def current_path(lang)
|
102
|
+
lang_candidates = lang.to_posix.candidates
|
103
|
+
search_files = []
|
104
|
+
|
105
|
+
lang_candidates.each do |tag|
|
106
|
+
path = @locale_paths[tag.to_s]
|
107
|
+
warn "GetText::TextDomain#load_mo: mo-file is #{path}" if $DEBUG
|
108
|
+
return path if path
|
109
|
+
end
|
110
|
+
|
111
|
+
if $DEBUG
|
112
|
+
warn "MO file is not found in"
|
113
|
+
@locale_paths.each do |path|
|
114
|
+
warn " #{path[1]}"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
nil
|
118
|
+
end
|
119
|
+
memoize :current_path
|
120
|
+
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,330 @@
|
|
1
|
+
=begin
|
2
|
+
mofile.rb - A simple class for operating GNU MO file.
|
3
|
+
|
4
|
+
Copyright (C) 2003-2009 Masao Mutoh
|
5
|
+
Copyright (C) 2002 Masahiro Sakai, Masao Mutoh
|
6
|
+
Copyright (C) 2001 Masahiro Sakai
|
7
|
+
|
8
|
+
Masahiro Sakai <s01397ms at sfc.keio.ac.jp>
|
9
|
+
Masao Mutoh <mutomasa at gmail.com>
|
10
|
+
|
11
|
+
You can redistribute this file and/or modify it under the same term
|
12
|
+
of Ruby. License of Ruby is included with Ruby distribution in
|
13
|
+
the file "README".
|
14
|
+
|
15
|
+
=end
|
16
|
+
|
17
|
+
require 'gettext/core_ext/iconv'
|
18
|
+
require 'stringio'
|
19
|
+
|
20
|
+
module GetText
|
21
|
+
class MOFile < Hash
|
22
|
+
class InvalidFormat < RuntimeError; end;
|
23
|
+
|
24
|
+
attr_reader :filename
|
25
|
+
|
26
|
+
Header = Struct.new(:magic,
|
27
|
+
:revision,
|
28
|
+
:nstrings,
|
29
|
+
:orig_table_offset,
|
30
|
+
:translated_table_offset,
|
31
|
+
:hash_table_size,
|
32
|
+
:hash_table_offset)
|
33
|
+
|
34
|
+
# The following are only used in .mo files
|
35
|
+
# with minor revision >= 1.
|
36
|
+
class HeaderRev1 < Header
|
37
|
+
attr_accessor :n_sysdep_segments,
|
38
|
+
:sysdep_segments_offset,
|
39
|
+
:n_sysdep_strings,
|
40
|
+
:orig_sysdep_tab_offset,
|
41
|
+
:trans_sysdep_tab_offset
|
42
|
+
end
|
43
|
+
|
44
|
+
MAGIC_BIG_ENDIAN = "\x95\x04\x12\xde"
|
45
|
+
MAGIC_LITTLE_ENDIAN = "\xde\x12\x04\x95"
|
46
|
+
|
47
|
+
def self.open(arg = nil, output_charset = nil)
|
48
|
+
result = self.new(output_charset)
|
49
|
+
result.load(arg)
|
50
|
+
end
|
51
|
+
|
52
|
+
def initialize(output_charset = nil)
|
53
|
+
@filename = nil
|
54
|
+
@last_modified = nil
|
55
|
+
@little_endian = true
|
56
|
+
@output_charset = output_charset
|
57
|
+
@plural_proc = nil
|
58
|
+
super()
|
59
|
+
end
|
60
|
+
|
61
|
+
def update!
|
62
|
+
if FileTest.exist?(@filename)
|
63
|
+
st = File.stat(@filename)
|
64
|
+
load(@filename) unless (@last_modified == [st.ctime, st.mtime])
|
65
|
+
else
|
66
|
+
warn "#{@filename} was lost." if $DEBUG
|
67
|
+
clear
|
68
|
+
end
|
69
|
+
self
|
70
|
+
end
|
71
|
+
|
72
|
+
def load(arg)
|
73
|
+
if arg.kind_of? String
|
74
|
+
begin
|
75
|
+
st = File.stat(arg)
|
76
|
+
@last_modified = [st.ctime, st.mtime]
|
77
|
+
rescue Exception
|
78
|
+
end
|
79
|
+
load_from_file(arg)
|
80
|
+
else
|
81
|
+
load_from_stream(arg)
|
82
|
+
end
|
83
|
+
@filename = arg
|
84
|
+
self
|
85
|
+
end
|
86
|
+
|
87
|
+
def load_from_stream(io)
|
88
|
+
magic = io.read(4)
|
89
|
+
case magic
|
90
|
+
when MAGIC_BIG_ENDIAN
|
91
|
+
@little_endian = false
|
92
|
+
when MAGIC_LITTLE_ENDIAN
|
93
|
+
@little_endian = true
|
94
|
+
else
|
95
|
+
raise InvalidFormat.new(sprintf("Unknown signature %s", magic.dump))
|
96
|
+
end
|
97
|
+
|
98
|
+
endian_type6 = @little_endian ? 'V6' : 'N6'
|
99
|
+
endian_type_astr = @little_endian ? 'V*' : 'N*'
|
100
|
+
|
101
|
+
header = HeaderRev1.new(magic, *(io.read(4 * 6).unpack(endian_type6)))
|
102
|
+
|
103
|
+
if header.revision == 1
|
104
|
+
# FIXME: It doesn't support sysdep correctly.
|
105
|
+
header.n_sysdep_segments = io.read(4).unpack(endian_type6)
|
106
|
+
header.sysdep_segments_offset = io.read(4).unpack(endian_type6)
|
107
|
+
header.n_sysdep_strings = io.read(4).unpack(endian_type6)
|
108
|
+
header.orig_sysdep_tab_offset = io.read(4).unpack(endian_type6)
|
109
|
+
header.trans_sysdep_tab_offset = io.read(4).unpack(endian_type6)
|
110
|
+
elsif header.revision > 1
|
111
|
+
raise InvalidFormat.new(sprintf("file format revision %d isn't supported", header.revision))
|
112
|
+
end
|
113
|
+
io.pos = header.orig_table_offset
|
114
|
+
orig_table_data = io.read((4 * 2) * header.nstrings).unpack(endian_type_astr)
|
115
|
+
|
116
|
+
io.pos = header.translated_table_offset
|
117
|
+
trans_table_data = io.read((4 * 2) * header.nstrings).unpack(endian_type_astr)
|
118
|
+
|
119
|
+
original_strings = Array.new(header.nstrings)
|
120
|
+
for i in 0...header.nstrings
|
121
|
+
io.pos = orig_table_data[i * 2 + 1]
|
122
|
+
original_strings[i] = io.read(orig_table_data[i * 2 + 0])
|
123
|
+
end
|
124
|
+
|
125
|
+
clear
|
126
|
+
for i in 0...header.nstrings
|
127
|
+
io.pos = trans_table_data[i * 2 + 1]
|
128
|
+
str = io.read(trans_table_data[i * 2 + 0])
|
129
|
+
|
130
|
+
if (! original_strings[i]) || original_strings[i] == ""
|
131
|
+
if str
|
132
|
+
@charset = nil
|
133
|
+
@nplurals = nil
|
134
|
+
@plural = nil
|
135
|
+
str.each_line{|line|
|
136
|
+
if /^Content-Type:/i =~ line and /charset=((?:\w|-)+)/i =~ line
|
137
|
+
@charset = $1
|
138
|
+
elsif /^Plural-Forms:\s*nplurals\s*\=\s*(\d*);\s*plural\s*\=\s*([^;]*)\n?/ =~ line
|
139
|
+
@nplurals = $1
|
140
|
+
@plural = $2
|
141
|
+
end
|
142
|
+
break if @charset and @nplurals
|
143
|
+
}
|
144
|
+
@nplurals = "1" unless @nplurals
|
145
|
+
@plural = "0" unless @plural
|
146
|
+
end
|
147
|
+
else
|
148
|
+
if @output_charset
|
149
|
+
begin
|
150
|
+
str = Iconv.conv(@output_charset, @charset, str) if @charset
|
151
|
+
rescue Iconv::Failure
|
152
|
+
if $DEBUG
|
153
|
+
warn "@charset = ", @charset
|
154
|
+
warn"@output_charset = ", @output_charset
|
155
|
+
warn "msgid = ", original_strings[i]
|
156
|
+
warn "msgstr = ", str
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
self[original_strings[i]] = str.freeze
|
162
|
+
end
|
163
|
+
self
|
164
|
+
end
|
165
|
+
|
166
|
+
def prime?(number)
|
167
|
+
('1' * number) !~ /^1?$|^(11+?)\1+$/
|
168
|
+
end
|
169
|
+
|
170
|
+
begin
|
171
|
+
require 'prime'
|
172
|
+
def next_prime(seed)
|
173
|
+
Prime.instance.find{|x| x > seed }
|
174
|
+
end
|
175
|
+
rescue LoadError
|
176
|
+
def next_prime(seed)
|
177
|
+
require 'mathn'
|
178
|
+
prime = Prime.new
|
179
|
+
while current = prime.succ
|
180
|
+
return current if current > seed
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
HASHWORDBITS = 32
|
186
|
+
# From gettext-0.12.1/gettext-runtime/intl/hash-string.h
|
187
|
+
# Defines the so called `hashpjw' function by P.J. Weinberger
|
188
|
+
# [see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools,
|
189
|
+
# 1986, 1987 Bell Telephone Laboratories, Inc.]
|
190
|
+
def hash_string(str)
|
191
|
+
hval = 0
|
192
|
+
i = 0
|
193
|
+
str.each_byte do |b|
|
194
|
+
break if b == '\0'
|
195
|
+
hval <<= 4
|
196
|
+
hval += b.to_i
|
197
|
+
g = hval & (0xf << (HASHWORDBITS - 4))
|
198
|
+
if (g != 0)
|
199
|
+
hval ^= g >> (HASHWORDBITS - 8)
|
200
|
+
hval ^= g
|
201
|
+
end
|
202
|
+
end
|
203
|
+
hval
|
204
|
+
end
|
205
|
+
|
206
|
+
#Save data as little endian format.
|
207
|
+
def save_to_stream(io)
|
208
|
+
header_size = 4 * 7
|
209
|
+
table_size = 4 * 2 * size
|
210
|
+
|
211
|
+
hash_table_size = next_prime((size * 4) / 3)
|
212
|
+
hash_table_size = 3 if hash_table_size <= 2
|
213
|
+
header = Header.new(
|
214
|
+
MAGIC_LITTLE_ENDIAN, # magic
|
215
|
+
0, # revision
|
216
|
+
size, # nstrings
|
217
|
+
header_size, # orig_table_offset
|
218
|
+
header_size + table_size, # translated_table_offset
|
219
|
+
hash_table_size, # hash_table_size
|
220
|
+
header_size + table_size * 2 # hash_table_offset
|
221
|
+
)
|
222
|
+
io.write(header.to_a.pack('a4V*'))
|
223
|
+
|
224
|
+
ary = to_a
|
225
|
+
ary.sort!{|a, b| a[0] <=> b[0]} # sort by original string
|
226
|
+
|
227
|
+
pos = header.hash_table_size * 4 + header.hash_table_offset
|
228
|
+
|
229
|
+
orig_table_data = Array.new()
|
230
|
+
ary.each{|item, _|
|
231
|
+
orig_table_data.push(item.bytesize)
|
232
|
+
orig_table_data.push(pos)
|
233
|
+
pos += item.bytesize + 1 # +1 is <NUL>
|
234
|
+
}
|
235
|
+
io.write(orig_table_data.pack('V*'))
|
236
|
+
|
237
|
+
trans_table_data = Array.new()
|
238
|
+
ary.each{|_, item|
|
239
|
+
trans_table_data.push(item.bytesize)
|
240
|
+
trans_table_data.push(pos)
|
241
|
+
pos += item.bytesize + 1 # +1 is <NUL>
|
242
|
+
}
|
243
|
+
io.write(trans_table_data.pack('V*'))
|
244
|
+
|
245
|
+
hash_tab = Array.new(hash_table_size)
|
246
|
+
j = 0
|
247
|
+
ary[0...size].each {|key, _|
|
248
|
+
hash_val = hash_string(key)
|
249
|
+
idx = hash_val % hash_table_size
|
250
|
+
if hash_tab[idx] != nil
|
251
|
+
incr = 1 + (hash_val % (hash_table_size - 2))
|
252
|
+
begin
|
253
|
+
if (idx >= hash_table_size - incr)
|
254
|
+
idx -= hash_table_size - incr
|
255
|
+
else
|
256
|
+
idx += incr
|
257
|
+
end
|
258
|
+
end until (hash_tab[idx] == nil)
|
259
|
+
end
|
260
|
+
hash_tab[idx] = j + 1
|
261
|
+
j += 1
|
262
|
+
}
|
263
|
+
hash_tab.collect!{|i| i ? i : 0}
|
264
|
+
|
265
|
+
io.write(hash_tab.pack('V*'))
|
266
|
+
|
267
|
+
ary.each{|item, _| io.write(item); io.write("\0") }
|
268
|
+
ary.each{|_, item| io.write(item); io.write("\0") }
|
269
|
+
|
270
|
+
self
|
271
|
+
end
|
272
|
+
|
273
|
+
def load_from_file(filename)
|
274
|
+
@filename = filename
|
275
|
+
begin
|
276
|
+
File.open(filename, 'rb'){|f| load_from_stream(f)}
|
277
|
+
rescue => e
|
278
|
+
e.set_backtrace("File: #{@filename}")
|
279
|
+
raise e
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
def save_to_file(filename)
|
284
|
+
File.open(filename, 'wb'){|f| save_to_stream(f)}
|
285
|
+
end
|
286
|
+
|
287
|
+
def set_comment(msgid_or_sym, comment)
|
288
|
+
#Do nothing
|
289
|
+
end
|
290
|
+
|
291
|
+
def plural_as_proc
|
292
|
+
unless @plural_proc
|
293
|
+
@plural_proc = Proc.new{|n| eval(@plural)}
|
294
|
+
begin
|
295
|
+
@plural_proc.call(1)
|
296
|
+
rescue
|
297
|
+
@plural_proc = Proc.new{|n| 0}
|
298
|
+
end
|
299
|
+
end
|
300
|
+
@plural_proc
|
301
|
+
end
|
302
|
+
|
303
|
+
attr_accessor :little_endian, :path, :last_modified
|
304
|
+
attr_reader :charset, :nplurals, :plural
|
305
|
+
end
|
306
|
+
|
307
|
+
end
|
308
|
+
|
309
|
+
# Test
|
310
|
+
|
311
|
+
if $0 == __FILE__
|
312
|
+
if (ARGV.include? "-h") or (ARGV.include? "--help")
|
313
|
+
STDERR.puts("mo.rb [filename.mo ...]")
|
314
|
+
exit
|
315
|
+
end
|
316
|
+
|
317
|
+
ARGV.each{ |item|
|
318
|
+
mo = GetText::MOFile.open(item)
|
319
|
+
puts "------------------------------------------------------------------"
|
320
|
+
puts "charset = \"#{mo.charset}\""
|
321
|
+
puts "nplurals = \"#{mo.nplurals}\""
|
322
|
+
puts "plural = \"#{mo.plural}\""
|
323
|
+
puts "------------------------------------------------------------------"
|
324
|
+
mo.each do |key, value|
|
325
|
+
puts "original message = #{key.inspect}"
|
326
|
+
puts "translated message = #{value.inspect}"
|
327
|
+
puts "--------------------------------------------------------------------"
|
328
|
+
end
|
329
|
+
}
|
330
|
+
end
|