PHP - ZendFramework:如何在没有整个框架的情况下使用 Zend_Translate?
我正在构建一个简单的 PHP 网站,并希望将其翻译成 2 种语言(西班牙语、英语)。 我在这里阅读了一些问题,每个人都推荐 Zend_Translate。我已经阅读了文档,看起来相当不错。
我读过我可以使用 Zend_Translate 组件而不使用整个框架,仅使用该组件,但我不能。我已经尝试了一切。我下载了该框架并将其放置在 libs
子目录中。我尝试了几种导入它的方法:
// First try
require('libs/Zend/Translate.php'); //Fail
//Second try
require('libs/Zend/Loader.php'); //Good
Zend_Loader::loadClass('Zend_Translate'); //Fail
你能帮我吗?
i'm building a simple PHP website and want to translate it into 2 languages (spanish,english).
I've read some questions here and everybody recommend Zend_Translate. I've read the documentation and seems pretty good.
I've read I can use the Zend_Translate component without using the entire Framework, just that component, but i cannot. I've tryed everything. I downloaded the framework and placed it in a libs
subdirectory. And i've tryed severals ways to import it:
// First try
require('libs/Zend/Translate.php'); //Fail
//Second try
require('libs/Zend/Loader.php'); //Good
Zend_Loader::loadClass('Zend_Translate'); //Fail
Can you help me please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
感谢这篇文章,我终于能够让它发挥作用了!
对于像我这样正在寻找使用 zend_translate 而不使用 Zend Framework 的工作示例的人,这里是:
https:// /github.com/26medias/zend_translate
如果您使用 Windows(像我一样),则需要先安装 gettext:
http://gnuwin32.sourceforge.net/packages/gettext.htm
编辑翻译:
你就完成了!
Thanks to this post, I was able to finally make it work!
For people like me who are searching for a working example of using zend_translate without using the Zend Framework, here it is:
https://github.com/26medias/zend_translate
If you are using Windows (like I do), you'll need to install gettext first:
http://gnuwin32.sourceforge.net/packages/gettext.htm
To edit the translations:
And you're done!
根据@santiagobasulto,我正在为这个问题创建一个答案。
确保
Zend/
在您的路径中,因为 Zend Framework 期望该文件夹位于该位置。Per @santiagobasulto, I'm creating an answer for this question.
Make sure that
Zend/
is in your path, as the Zend Framework expects that folder to be there.您必须将“库”放入包含路径中。这很简单:
You have to put your 'libs' in your include path. It's quite simple :