PHP - ZendFramework: How to use Zend_Translate without the whole framework?
i'm building a simple PHP website and want to translate it into 2 languages (spanish,english). I've read some ques开发者_StackOverflowtions 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?
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:
- open /locale/[locale name]/messages.po
- add your translations
- Execute translate.bat (if you didn't install gettext in the default directory, update the path to the bin folder). It will generate/update the messages.mo file.
And you're done!
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 :
set_include_path( implode( PATH_SEPARATOR, array(
'/path/to/your/libs',
get_include_path(),
)
)
);
精彩评论