在 PHP 中外部化字符串的最佳实践
我对 PHP 中的字符串外部化发现如此之少感到惊讶。每个人都使用 gettext,还是有其他我不知道的框架或工具?
I've been surprised by how little I've found on externalizing strings in PHP. Does everyone use gettext, or is there some other framework or tool that I'm not aware of?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
一旦您为应用程序本地化奠定了基础,如果您发现自己需要管理和/或只是完成实际翻译,我们有(显然是我喜欢的想法:)一个非常酷的工具,称为 String - http://mygengo.com/string
String 不仅适合管理翻译,您还可以邀请其他人参与项目来提供帮助翻译,但您也可以直接在服务中订购翻译。我们已将 API 集成到 String 中,以展示我们的 API 以及查看由真人翻译的大量(数百...数千)职位状态更新的能力!
如果您对 API 本身感兴趣,我们不久前为多个平台(Wordpress、Django 等)举办了一场赏金竞赛,其中包括一些有趣的获奖者:http://mygengo.com/services/api/lab/winners/
只是想分享一下。
Once you've set the foundation for localizing your application, if you find yourself needing to manage and / or just get the actual translation done we have (what I like to think, obviously :) a pretty cool tool called String - http://mygengo.com/string
String is great for not just managing translations, where you can invite others to projects to help with translation, but you can order translations right in the service too. We've integrated our API into String to showcase our API and the ability to see status updates for numerous (100s...1000s) of jobs, translated by real people!
If you're interested in the API itself, we held a bounty contest not long ago with some fun winners for a number of platforms (Wordpress, Django, etc.): http://mygengo.com/services/api/lab/winners/
Just thought I'd share.
我想说你应该使用 gettext 因为它很成熟并且易于设置。此外,使用 gettext BU,您将能够将其用途扩展到除 php 之外的其他类型的源。考虑 PO 文件格式作为此标准。
我在 i18n 领域工作了很多年,我可以告诉你,如果你的项目中有超过 50-100 个字符串,gettext 将为你提供最小努力的最佳结果。
I would say that you should use gettext because it is mature and easy to setup. Also BU using gettext you will be able to extend its useage for other type of sources than php. Consider the PO file format the standard for this.
Im working in i18n area for many years and I can tell you that gettext will provide you best results with minimal efforts if you have more than 50-100 strings in your project.
希望这个库可以帮助您:
Hope this library helps you:
Zend_Translate / Zend_Locale 很好而且非常灵活。他们不需要整个 Zend 框架。它们支持 gettext moo/.po 文件,还支持 CSV 和其他格式。
Zend_Translate / Zend_Locale are nice and very flexible. They do not need the whole Zend Framework to be present. They support gettext moo/.po files but also CSV and other formats.