0

我的应用程序已在开发服务器上准备就绪。按预期工作。

我正在使用最新的 XAMPP / Codeigniter / HMVC

上传到生产服务器时,不会抛出任何错误。登录页面只显示没有文字

登录视图

<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){
            $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());
        }

编辑:

应用程序/config/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";

我已经通过很多问题和答案都没有成功。

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

谢谢!

4

1 回答 1

1

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

于 2013-10-12T14:28:00.260 回答