PHP - ZendFramework: how to use Zend_Translate without the whole structure?

I am creating a simple PHP site and want to translate it into 2 languages ​​(Spanish, English). I read a few questions here and everyone recommends Zend_Translate. I read the documentation and it seems pretty good.

I read that I can use the Zend_Translate component without using the entire Framework, only this component, but I can not. I tried everything. I downloaded the framework and placed it in the libs . And I tried several 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?

+4
source share
3 answers

Per @santiagobasulto, I am creating an answer for this question.

Make sure Zend/ is in your path, as the Zend Framework expects the folder to be there.

+1
source

Thanks to this post, I was finally able to make it work!

For people like me who are looking for a working example of using zend_translate without using the Zend Framework, here it is:

https://github.com/26medias/zend_translate

If you use Windows (like me), you need to install gettext first: http://gnuwin32.sourceforge.net/packages/gettext.htm

To edit translations:

  • open / locale / [locale name] /messages.po
  • add your translations
  • Run translate.bat (if you did not 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!

+2
source

You must put your "libs" in your include path. It is pretty simple:

 set_include_path( implode( PATH_SEPARATOR, array( '/path/to/your/libs', get_include_path(), ) ) ); 
+1
source

All Articles