$这个 - >负载>帮手( '语言');不管用

时间:2013-08-03 20:37:55

标签: codeigniter helper hmvc

我的应用已在开发服务器上准备就绪。按预期工作。 我正在使用最新的XAMPP / Codeigniter / HMVC

上传到生产服务器时,不会抛出任何错误。

登录页面只显示WITHOUT TEXT !!!

登录视图

    //Example code
    <a href="login/switchLanguage/italian"><i class="icon-font"></i>&nbsp;<?php echo lang('language'); ?></a>

执行时,这是输出

    <a href="login/switchLanguage/italian"><i class="icon-font"></i>&nbsp;</a>
                                                                          ^
                                                                          |
                                                                  Here's supposed 
                                                                 to write "Italian"

登录控制器

    class Login extends MX_Controller{

function __construct(){
    parent::__construct();
    $this->load->helper('language');
}

function index($msg = NULL){
    // Load our view to be displayed
    // to the user
    $data['msg'] = $msg;
    $this->load->view('login', $data);
}

    public function switchLanguage($language = "") {
            $language = ($language != "") ? $language : "english";
            $this->session->set_userdata('site_lang', $language);
            redirect(base_url());
    }

编辑:

应用/配置/ hooks.php

    $hook['post_controller_constructor'] = array(
'class' => 'LanguageLoader',
'function' => 'initialize',
'filename' => 'LanguageLoader.php',
'filepath' => 'hooks'

);

应用程序/钩/ Languageloader.php

    <?php 

    class LanguageLoader {
        function initialize() {
            $ci =& get_instance();
            $ci->load->helper('language');
            $site_lang = $ci->session->userdata('site_lang');
            if ($site_lang) {
                $ci->lang->load('login',$ci->session->userdata('site_lang'));
            } else {
                $ci->lang->load('login','english');
            }
        }
    }

编辑:

示例语言文件:application / language / italian / common_lang.php

    <?php
    //Application Global
    $lang["common_appName"] ="Customer App";
    $lang["common_search"] = "Cercare";
    $lang["common_search_go"] = "Andare";
    $lang["common_label_created_by"] = "Creato da";

    //Menus
    $lang["common_menu_home"] = "Home";
    $lang["common_menu_dashboard"] = "Cruscotto";
    $lang["common_menu_production"] = "Produzione";
    $lang["common_menu_inventory"] = "Inventario";
    $lang["common_menu_user_edit"] = "Modificare";
    $lang["common_menu_logout"] = "Il logout";
    $lang["common_menu_new_notifications"] = "Ci sono nuove notifiche";

    //Submenus
    $lang["common_submenu_dashboard"] = "Cruscotto";
    $lang["common_submenu_production"] = "Produzione";
    $lang["common_submenu_inventory"] = "Inventario";
    $lang["common_submenu_orderlist"] = "Lista ordini";
    $lang["common_submenu_calendar"] = "Calendario";

我已经通过很多问题了解答案不成功。

非常欢迎任何建议......

谢谢!

1 个答案:

答案 0 :(得分:1)

不知道你是否解决了这个问题。但是当我将项目更新到主服务器时,我遇到了同样的问题。 实际问题是文件名。 在你的hooks.php中你提到文件名为'LanguageLoader.php',但我认为你创建了一个文件Languageloader.php(Application / hooks / Languageloader.php)。请检查..