来自 CodeIgniter 用户指南
If you find that you need a particular language globally throughout your application, you can tell CodeIgniter to auto-load it during system initialization. This is done by opening the application/config/autoload.php file and adding the language(s) to the autoload array.
我在 session 中存储有关用户语言的信息。
$this->session->set_userdata('lang', $lang);
如何更改自动加载的全局 lang 文件的语言(到用户使用的语言)(默认语言是从 config.php 加载的 - 这显然是可以理解的)
$autoload['language'] = array('global');
这是否可能,如果不可能,应该怎么做? 我需要扩展 CI_Controller 吗?
最佳答案
毕竟,我认为最好的解决方案是扩展 CI_controller 就这么简单
class MY_Controller extends CI_Controller {
function __construct() {
parent::__construct();
// Global Lang File
$this->lang->load('global', $this->session->userdata('lang'));
}
}
关于php - 代码点火器 2 : How to switch auto-loaded lang file to different language,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14748869/