2010年12月20日 星期一

Announcing I18N::Handle

Since every web frameworks use their class and different way to make localization, and some don't have it. To use L10N stuff, you need to declare a class which inherits from Locale::Maketext if your web framework doesn't handle it. And Locale::Maketext is not simple enough. You will need to use $hl->maketext everywhere.

So I am thinking about a common handler that doing L10N for most application or frameworks.

I18N::Handle is a common handler for web frameworks and applications.

I18N::Handle also provides a global locale function to make localization, you can use Gettext style locale function to make localization in every packages, the default loc function name is "_". To change the exporting loc function name , please use loc option.

The difference between I18N::Handle and Locale::Maketext is that I18N::Handle automatically does most things for you, and it provides simple API like speak, can_speak instead of get_handle, languages.

To generate po/mo files, App::I18N is an utility for this, App::I18N is a command-line tool for parsing, exporting, managing, editing, translating i18n messages. See also App::I18N.

Here is a simple usage:


More is on github.

6 則留言:

  1. Not yet another Locale::Maketext wrapper :(

    Please read this: http://rassie.org/archives/247

    Sorry to criticize your work in this way, but Locale::Maketext is a serious PITA for every i18n and project.

    回覆刪除
  2. Hi Pronik,

    yes, it's a locale::maketext wrapper. (currently).

    thanks for the comments. I will study that. :-)

    回覆刪除
  3. I18N::Handle would support more backends later. but currently only Locale::Maketext.

    This information is helpful, hope in the new backend (?) can resolve the problem (?). (hope)

    回覆刪除
  4. The problem is: .po files are different for Maketext and original Gettext. One example is the plural form handling, another could be the translation contexts. So it's not a matter of another backend.

    回覆刪除
  5. Do you mean the plural forms like this: http://www.gnu.org/software/hello/manual/gettext/Plural-forms.html

    and the local::maketext is doing like this _('Hello %1 %2',$arg1,$arg2) or .. _('Hello [_1] [_2]',$arg1,$arg2) ?

    or do you mean the po file format?

    I am sure gettext like php-gettext can do like this ngettext('Hello %1',$arg1)

    回覆刪除
  6. Locale::Maketext provides a nice solution for i18n.

    but for those people wants a *real* gettext, they should just use Gettext module.

    回覆刪除