How can I add internationalization to my Perl script?

前端 未结 4 1095
不思量自难忘°
不思量自难忘° 2020-12-14 11:09

I\'m looking at introducing multi-lingual support to a mature CGI application written in Perl. I had originally considered rolling my own solution using a Perl hash (stored

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-14 11:45

    If you have the time then do take a look at the way the I18N is done in the Jifty framework - although initially quite confusing it is very elegant and usable.

    They overload _ so that you can use _("text to translate") anywhere in the code. These strings are then translated using Locale::Maketext as normal.

    What makes it really powerful is that they defer the translation until the string is needed using Scalar::Defer so that you can start adding the strings at any time, even before you know which language they will be translated into. For example in config files etc. This really make I18N easy to work with.

提交回复
热议问题