I used this code to try and add a translation array from /resources/languages ANd to add a translation from /application/languages/nl.mo (gettext)
$translate = new Zend_Translate(
array(
'adapter' => 'array',
'content' => APPLICATION_PATH . '/resources/languages',
'locale' => 'nl',
'scan' => Zend_Translate::LOCALE_DIRECTORY
)
);
$translate->addTranslation(
array(
'adapter' => 'gettext',
'content' => APPLICATION_PATH.DIRECTORY_SEPARATOR.'languages'.DIRECTORY_SEPARATOR.'nl_NL.mo',
'locale' => 'nl'
)
);
When i try to add a single translation everything works ok (in both cases) When i'm adding a second translation i get this error:
Fatal error: Uncaught exception 'Zend_Translate_Exception' with message 'Error including array or file '1'' in blabla.php on line 61
can someone tell me how to add those translation files from my bootstrap, without getting these errors?
I'm not 100% sure, but I think you cannot mix types of translation files. The reason is that
$translate->addTranslation()
will actually call a methodaddTranslation()
onZend_Translate_Adapter_Array
, which in turn will call a method_loadTranslationData
also onZend_Translate_Adapter_Array
. ThusZend_Translate_Adapter_Array
tries to read filenl_NL.mo
as an array which results in Error including array or file error.However, if the translation file 'nl' is the one from zend resources, and you want to use it only for translating zend_form messages, I think you could define a separate translator for this as follows:
And the 'nl_NL' you can make your default for the rest:
P.S. I have not tested this, hence I cannot grantee it works, but this is how I would at least try to do it.