1
votes

I have a custom directory, eg /www/phpstuff which is in my include_path. Inside of this phpstuff directory is a folder i18n. It contains server-side level .mo files.

Zend_Translate lets you specify a directory in the second parameter of the constructor, I can't really do

Zend_Translate( 'gettext', 'i18n/', 'en' );

It tries to read from the directory in which this script is invoked, is there any sort of trick I can use to not have to specify /www/phpstuff/i18n explicitly? Reason being this framework I'm working with will be used across many different platforms, and it would be easier specifying a directory in an include_path than an absolute path.

The only workaround I can come up with is manually reading the include path, splitting by the separator, checking if any of the directories are named 'gettext' and then grab the absolute path of the first directory found and set it.

1

1 Answers

1
votes

You'll need to define the application path somewhere. If you don't want to set an absolute path, you'll need to set a relative path. Take this dir structure for example:

/application/
/application/i18n/
/public_html/
/public_html/index.php

The application path in this case would be:

define('APPLICATION_PATH', '../application');

And you can use it like this:

Zend_Translate( 'gettext', APPLICATION_PATH . '/i18n', 'en' );

Hope that helps.