如何在MVC中包含Zend_Translate?

时间:2019-01-17 11:38:32

标签: php model-view-controller zend-translate

我需要帮助。所以我的问题是 我连接了Zend_Translate适配器。然后创建具有该内容的文件

libs / lang.php

$file = 'kk_KZ';
set_include_path("./libs");
// Include and load the lib
require('./libs/Zend/Translate.php');
Zend_Loader::loadClass('Zend_Translate');

// Init the class
$translate = new Zend_Translate(
    array(
        'adapter' => 'gettext',
        'content' => 'langs/'.$file.'/LC_MESSAGES/'.$file.'.mo',
        'locale' => 'kk_KZ',
        'scan' => Zend_Translate::LOCALE_DIRECTORY
    )
);

之后,我将此文件包含在 index.php

require 'libs/bootstrap.php';
require 'libs/controller.php';
require 'libs/view.php';
require 'libs/model.php';
require 'libs/lang.php';

$app = new Bootstrap();

然后我想翻译这样的字符串 $ translate-> _('Home'); ,但是我遇到了下一个错误

<b>Notice</b>:  Undefined variable: translate in <b>C:\OpenServer\domains\site\views\header.php</b> on line <b>99</b><br />
<br />
<b>Fatal error</b>:  Call to a member function translate() on null in <b>C:\OpenServer\domains\site\views\header.php</b> on line <b>99</b><br />

谁遇到过这样的问题?

0 个答案:

没有答案