I've trying to use Zend_Translate from Zend Framework
I am using "POEdit" to generate "gettext" translation files.
My files are under /www/mysite.com/webapps/includes/locale (this path is in my include path). I have: pictures.en.mo pictures.en.po (I plan on having pictures.es.mo soon)
It all works fine if I manually do addTranslation() for each file. However I want to use the automatic file scanning method.
I tried both of those:
<?php
/*Localization*/
require_once 'Zend/Translate.php';
require_once 'Zend/Locale.php';
define('LOCALE','/www/mysite.com/webapps/includes/locale');
if(!empty($_GET['locale'])){
$locale = new Zend_Locale($_GET['locale']);
}
else{
$locale = new Zend_Locale();
}
$translate = new Zend_Translate('gettext', LOCALE, null, array('scan' => Zend_Translate::LOCALE_FILENAME));
if ( $translate->isAvailable( $locale->getLanguage() ) ){
$translate->setLocale($locale);
}
else{
$translate->setLocale('en');
}
And this:
<?php
/*Localization*/
require_once 'Zend/Translate.php';
require_once 'Zend/Locale.php';
define('LOCALE','/www/mysite.com/webapps/includes/locale');
if(!empty($_GET['locale'])){
$locale = new Zend_Locale($_GET['locale']);
}
else{
$locale = new Zend_Locale();
}
$translate = new Zend_Translate('gettext', LOCALE);
if ( $translate->isAvailable( $locale->getLanguage() ) ){
$translate->setLocale($locale);
}
else{
$translate->setLocale('en');
}
In both cases, I get a Notice: No translation for the language 'en' available. in /www/mysite.com/webapps/includes/Zend/Translate/Adapter.php on line 411
It also worked if I tried to do directory scanning.