What are good tools/frameworks for i18n of a php codebase?

前端 未结 5 1770
走了就别回头了
走了就别回头了 2020-12-19 23:05

I have been looking at a few options for enabling localization and internationalization of a dynamic php application. There appears to be a variety of tools available such a

相关标签:
5条回答
  • 2020-12-19 23:25

    There are a number of useful extensions in pecl: http://pecl.php.net/packages.php?catpid=28&catname=Internationalization

    In particular, you may want to check out php-intl, which provides most of the key i18n functions from International Components for Unicode (ICU)

    0 讨论(0)
  • 2020-12-19 23:36

    PHP gettext implementation works very smoothly. And po files with po edit and gettext are about as good a way as you can get to deal with localization bearing in mind that no solution of this kind can completely handle the complexities of the various languages. For example, the gettext method is very good on plural forms, but nothing I've seen can handle things like conjugation.

    For more info see my post here: How do you build a multi-language web site?

    0 讨论(0)
  • 2020-12-19 23:41

    We've been tinkering withZend_Translate, since we use the Zend Framework anyway. It's very well documented and so far extremly solid.

    In the past, I've pretty much used my own home-grown solution mostly. Which involves language files with constants or variables which hold all text parts and are just echo'ed in the view/template later on.

    As for gettext, in the past I've heard references about PHP's gettext implementation being faulty, but I can't really back that up nor do I have any references right now.

    0 讨论(0)
  • 2020-12-19 23:41

    the database driven solution to show the messages is not always the good one, I worked in a site with more than 15 languages and translations were an issue.

    so our design was:

    • translation app in php-mysql (translation access, etc.)
    • then translations are written in php arrrays
    • these arrays are also cached in APC to speed up the site.

    so to localize different languages you only need do an include

    like

    <?php
    include('lang/en.php');
    include('lang/en_us.php'); // this file overrides few keys from the last one.
    ?>
    
    0 讨论(0)
  • 2020-12-19 23:42

    Xataface can be used to quite easily internationalize an arbitrary PHP/MySQL application. It support translation of both your static text, and your database data. All you have to do is add a line or 2 of code to a couple of places in your application and it's good to go.

    http://xataface.com/documentation/tutorial/internationalization-with-dataface-0.6

    0 讨论(0)
提交回复
热议问题