0

While translation works fine on the development server we get the following notice on the production server: No translation for the language 'fr' available.

Here is the translation configuration in the bootstrap (forcing the locale for the test) :

$locale = "fr_CA.utf8";
$translate = new Zend_Translate( 
    array(
        'adapter'=>'gettext', 
        'content' => APPLICATION_PATH . '/lang',
        'locale' => $locale,
        'scan' => Zend_Translate::LOCALE_DIRECTORY, 
        'disableNotices' => false,
        'clear' =>true,
        'reload'=>true,
    )
);

The .mo file is in APPLICATION_PATH/lang/fr_CA.utf8/LC_MESSAGES/messages.mo

There are translated strings in the .mo file and the locale exists on both servers, according to "locale -a".

Any clue as to why such a setup could work on one server and not the other?

EDIT :

I got it to work with the following configuration :

        $translate = new Zend_Translate( 
        array(
            'adapter'=>'gettext', 
            'content' => APPLICATION_PATH.'/lang/'.$locale.'/LC_MESSAGES/messages.mo',
            'locale' => $locale,
            'disableNotices' => true,
            'clear' =>true,
            'reload'=>true,
        )
    );

It seems like the scanning was not working.

Devil
  • 1
  • 1
  • 3

2 Answers2

1

I had a similar problem (using the array adapter)

Reason: production site webroot path contains hidden directory /home/.sites/path/to/my/webroot/

// Settings:
$locale = new Zend_Locale('browser');
$language = $locale->getLanguage();

// Solution: added option 'ignore'  => '===' to override
// default $_options settings in Zend_Translate_Adapter

$translate = new Zend_Translate(array(
    'adapter' => 'array',
    'content' => APPLICATION_PATH . '/languages/' . $language,
    'scan'    => Zend_Translate::LOCALE_DIRECTORY,
    'locale'  => $locale,
    'ignore'  => '===',        // override default '.'

));
John Conde
  • 217,595
  • 99
  • 455
  • 496
hkk
  • 40
  • 1
  • 3
0

I had a similar problem but using application.ini to configure translation.

These were the Zend_Translate related lines:

resources.translate.adapter = "gettext"
resources.translate.content = APPLICATION_PATH "/languages"
resources.translate.options.scan = 'directory'

This worked fine on our development server but not on our staging server. We had to remove the quotes from the scan option:

resources.translate.options.scan = directory

Without quotes it worked. But I have no idea why this particular config line can't handle quotes on our staging server.

toonevdb
  • 329
  • 1
  • 13