dougaicha5258 2009-11-16 16:36
浏览 78
已采纳

PHP - 多语言应用程序设计

There are many ways to design a multilingual application in PHP. Some language file based, others database based.

  • I am looking to use it for mostly small amounts of text e.g errors - at most a paragraph.

  • I guess I will need twenty or so
    languages.

Really I am looking for recommendations rather than a definitive answer. What have you used before, what is fastest, easiest to update etc.

Many thanks,

  • 写回答

2条回答 默认 最新

  • dongtao9158 2009-11-16 16:38
    关注

    The Gettext family of functions is a good starting point:

    The gettext functions implement an NLS (Native Language Support) API which can be used to internationalize your PHP applications.

    Zend_Translate is extremely flexible and has a thread-safe implementation of gettext. The manual states that it addresses the following problems with native internationalization implementations:

    • Inconsistent API: There is no single API for the different source formats. The usage of gettext for example is very complicated.
    • PHP supports only gettext and native array: PHP itself offers only support for array or gettext. All other source formats have to be coded manually, because there is no native support.
    • No detection of the default language:The default language of the user cannot be detected without deeper knowledge of the backgrounds for the different web browsers.
    • Gettext is not thread-safe: PHP's gettext library is not thread safe, and it should not be used in a multithreaded environment. This is due to problems with gettext itself, not PHP, but it is an existing problem.

    It is worth noting that the Zend Framework is not a full-stack framework - in other words, you will not need to use the whole thing just to make use of its internationalization API.

    What I really like about it is its support for multiple adapters for different data sources, which you can easily mix, match, and change only having to apply very light modifications to your application. Hope that helps.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 CMFCPropertyPage
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题
  • ¥15 谁会P4语言啊,我想请教一下
  • ¥15 这个怎么改成直流激励源给加热电阻提供5a电流呀