Using PHP Gettext Extension vs PHP Arrays in Multilingual Websites?

后端 未结 5 842
礼貌的吻别
礼貌的吻别 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:15

    Using GNU gettext you get support for placeholders like with printf and international plural forms. Placeholders order can be changed in translation or skipped.

    Example from PHP documentation:

    
    
    

    Another pro is that you can use standard tools for terminology management, translations memory and machine translation as pointed by @middus.

    For shared environments there is a great php-gettext library from Danilo Segan.

提交回复
热议问题