i18n 与 gettext 但没有语言环境的麻烦?
我正在寻找一种符合标准的方式来存储 Web 应用程序的多语言内容.到目前为止,我使用了自己的translate()"函数从文件或数据库中的字典表中读取数据.但是,如果您使用 Web 应用程序的不同副本,则在数据库表中保持字典是最新的会非常麻烦.
I am looking for a standards-compliant way to store multi-language content for a Web Application. Until now, I have employed my own "translate()" functions that read data from a file or a dictionary table in a database. However, keeping the dictionaries up to date in a database table is very cumbersome if you work with different copies of the web app.
我喜欢 gettext,因为有很多工具可供它使用.但是,我为不同平台开发应用程序.我绝对不愿意处理 setlocale() 和 consorts 的蹩脚方式 - 即几十种不同的语言环境字符串变体,这些变体因系统而异,您需要提供这些变体才能使其正常工作.永远不能.我有一组语言——比如 de、en 和 es——我想加载适当的字典并使用 _() 而不接触 setlocale() 或 bindtexdomain() 一次.
I like gettext because there is a multitude of tools available for it. However, I develop applications for different platforms. I am absolutely unwilling to deal with the crappy ways of setlocale() and consorts - namely the dozens of different locale string variations differing from system to system that you need to provide for to get it working. Never ever. I have a set of languages - say de, en, and es - and I want to load the appropriate dictionary and work with _() without touching setlocale() or bindtexdomain() once.
这是否可以使用 gettext 实现?或者有人知道另一种简单、小巧、快速 (!) i18n 的 PHP 解决方案,它可以处理 .po/.mo 文件,最好不需要 PHP 扩展?
Is this somehow possible using gettext? Or does somebody know another simple, small, fast (!) i18n solution for PHP that can work with .po/.mo files, preferably without requiring a PHP extension?
推荐答案
Zend_Translate 使用它
Zend_Translate works with it
http://framework.zend.com/manual/en/zend.translate.adapter.html#zend.translate.adapter.gettext
相关文章