2015-04-27 22 views
2

我製作了一個工作應用程序的副本,對模塊做了一些更改,但在某些時候我注意到語言文件未被加載。Codeigniter + HMVC只請求login_lang文件...所有其他模塊的lang文件未被加載

例如,在登錄(myApp/login)時,請求文件login_lang.php,如果不存在(我將文件重命名爲無法找到它),則會引發錯誤。

應用(myApp/dashboard)內的其他模塊甚至不(dashboard_lang.php)但再次請求相應的語言文件,如果我有任何其他名稱重命名login_lang.php,該模塊將引發"login_lang.php file was not found"錯誤。

我認爲所有的模塊都請求的第一個文件(login_lang.php

我已經通了很多論壇,問題等不成功的。

任何想法可能會導致此行爲?

在此先感謝。

這是我autoload.php文件內容:

-----開始文件------文件

<?php if (! defined('BASEPATH')) exit('No direct script access allowed'); 
    /* 
    | ------------------------------------------------------------------- 
    | AUTO-LOADER 
    | ------------------------------------------------------------------- 
    | This file specifies which systems should be loaded by default. 
    | 
    | In order to keep the framework as light-weight as possible only the 
    | absolute minimal resources are loaded by default. For example, 
    | the database is not connected to automatically since no assumption 
    | is made regarding whether you intend to use it. This file lets 
    | you globally define which systems you would like loaded with every 
    | request. 
    | 
    | ------------------------------------------------------------------- 
    | Instructions 
    | ------------------------------------------------------------------- 
    | 
    | These are the things you can load automatically: 
    | 
    | 1. Packages 
    | 2. Libraries 
    | 3. Helper files 
    | 4. Custom config files 
    | 5. Language files 
    | 6. Models 
    | 
    */ 

    /* 
    | ------------------------------------------------------------------- 
    | Auto-load Packges 
    | ------------------------------------------------------------------- 
    | Prototype: 
    | 
    | $autoload['packages'] = array(APPPATH.'third_party', '/usr/local/shared'); 
    | 
    */ 

    $autoload['packages'] = array(APPPATH.'third_party'); 


    /* 
    | ------------------------------------------------------------------- 
    | Auto-load Libraries 
    | ------------------------------------------------------------------- 
    | These are the classes located in the system/libraries folder 
    | or in your application/libraries folder. 
    | 
    | Prototype: 
    | 
    | $autoload['libraries'] = array('database', 'session', 'xmlrpc'); 
    */ 

    $autoload['libraries'] = array('database','session'); 


    /* 
    | ------------------------------------------------------------------- 
    | Auto-load Helper Files 
    | ------------------------------------------------------------------- 
    | Prototype: 
    | 
    | $autoload['helper'] = array('url', 'file'); 
    */ 

    $autoload['helper'] = array('url','html'); 


    /* 
| ------------------------------------------------------------------- 
| Auto-load Config files 
| ------------------------------------------------------------------- 
| Prototype: 
| 
| $autoload['config'] = array('config1', 'config2'); 
| 
| NOTE: This item is intended for use ONLY if you have created custom 
| config files. Otherwise, leave it blank. 
| 
*/ 

$autoload['config'] = array(); 


/* 
| ------------------------------------------------------------------- 
| Auto-load Language files 
| ------------------------------------------------------------------- 
| Prototype: 
| 
| $autoload['language'] = array('lang1', 'lang2'); 
| 
| NOTE: Do not include the "_lang" part of your file. For example 
| "codeigniter_lang.php" would be referenced as array('codeigniter'); 
| 
*/ 

$autoload['language'] = array(); 


/* 
| ------------------------------------------------------------------- 
| Auto-load Models 
| ------------------------------------------------------------------- 
| Prototype: 
| 
| $autoload['model'] = array('model1', 'model2'); 
| 
*/ 

$autoload['model'] = array(); 


/* End of file autoload.php */ 
/* Location: ./application/config/autoload.php */ 

-----結束---- ----

+0

你怎麼能指望它會加載'dashboard_lang'除非,如果你不加載它。我想'login_lang'加載你的'autoload.php'爲什麼使用所有控制器,它這裏面,你會得到錯誤,如果你重命名它。 –

+0

感謝Shaiful Islam爲你提供如此簡短的回覆,正如我所提到的,我製作了一個工作應用程序的副本,可將每個lang文件加載到相應的模塊中。 我確定我做了一些誤導這個功能的東西。我已經通過很多事情(取消變更)失敗。任何想法都歡迎。 –

回答

1

用語言把模塊名稱放在第一位。您可以創建一個語言文件夾中的模塊可以說模塊=>管理員=>語言=>連接

模塊=>管理員=>語言=> EN => dashboard_lang.php

$autoload['language'] = array('admin/dashboard'); 

或控制器

模塊=>管理員=>語言=> EN => dashboard_lang.php

$this->lang->load('admin/dashboard', 'english'); 

具有子文件夾

模塊=>管理員=>語言=> EN =>常見=> dashboard_lang.php

$autoload['language'] = array('admin/common/dashboard'); 

或控制器

modules => admin => language => en => common => dashboard_lang.php

$this->lang->load('admin/common/dashboard', 'english');