Using PHP Gettext Extension vs PHP Arrays in Multilingual Websites?

后端 未结 5 802
礼貌的吻别
礼貌的吻别 2021-01-02 07:39

So far the only 2 good things that I\'ve seen about using gettext instead of arrays is that I don\'t have to create the \"greeting\" \"sub-array\" (or whatever its called).

5条回答
  •  醉梦人生
    2021-01-02 08:07

    In my opinion it does not make too much sense to use a binary format (gettext's .mo files) for a dynamical language such as php.

    However, a pro of gettext is the existence of a huge ecosystem of tools that translators of your software are able to use (e.g. Poedit). Downside is that you always have to compile your .po to .mo before you deploy it while you can just replace a php file containing an array on the fly.

    Another con is, as you've already recognized, it is not available on all installations of php.

提交回复
热议问题