Search code examples
phpzend-frameworktranslate

Zend_translate class not found


I simply want to start using the Zend_translate

  $translate = new Zend_Translate('array',array(),'en_EN');

$fi = array(
    'Hello World' => 'Hei Maailma'
);

$translate->addTranslation($fi,'fi_FI');
$translate->setLocale('fi_FI');
echo $translate->_('Hello World');

on this I get `Class 'Zend_Translate' not found

Of course I need to install something first...BUT there is nowhere said what I should set and how to install. The Zend documentation does not say how to install these stuff and I could not find it on internet, please help


Solution

  • Nope - it's not bundled. Also - the tutorial or sample code you have is not using ZF3, but ZF1. You can already tell from the underscore class name (Zend_Translate).

    In ZF3 you have to install the modules:

    composer require zendframework/zend-i18n and optionally (if you use the MVC compoments) composer require zendframework/zend-mvc-i18n

    The 2 tutorials / docs relevant for i18n can be found here

    https://docs.zendframework.com/tutorials/i18n/

    https://docs.zendframework.com/zend-i18n/translation