gpt4 book ai didi

php - 代码点火器 2 : How to switch auto-loaded lang file to different language

转载 作者:可可西里 更新时间:2023-11-01 00:47:27 25 4
gpt4 key购买 nike

来自 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com