Codeigniter更改加载的语言 [英] Codeigniter Change loaded language

查看:130
本文介绍了Codeigniter更改加载的语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我有一个语言加载MY_Controller,它扩展了CI_Controller。但是在一个特殊的页面中,控制器(让我们称之为ABC控制器)扩展了MY_Controller,我需要用另一种语言覆盖加载的语言。我试着在这个ABC控制器中加载另一种语言,但不成功。有没有办法卸载加载的语言并加载另一种语言?

Currently i have a language loaded inside MY_Controller which extends CI_Controller. But inside a special page which controller (let's call it ABC controller) extends MY_Controller, I need to override the loaded language with another language. I tried loading another language inside this ABC controller, but unsuccessful. Is there a way to unload the loaded language and load another language?

推荐答案

你需要吗?

$this->lang->load('filename', 'language');

它应该像默认语言一样可访问。我没有测试这个,但从我的理解,这应该是去的方式。

参考: http://codeigniter.com/user_guide/libraries/language.html

REVISED

我结束了更多挖掘,您无法加载默认语言(在您的控制器中将其定义为默认语言),然后尝试将其更改为其他语言。

I ended up digging a bit more for you, and found that you CANNOT load a default language (define it as default in your controller) and then later try to change it to something else.

请按照以下步骤操作:


  • 如果您需要非英语的语言(默认),请在您的配置中设置。

  • 要在控制器基础上加载ANOTHER语言,您需要定义(通常在构造函数中使用会话数组/用户选择。

  • 您无法加载2种语言(构造函数中有1个,不同类中的另一个不能使用!)

  • If you need a language OTHER than english (default), set that in your config.
  • If you want to load ANOTHER language on a controller basis, you need to define that (most commonly in your constructor using something like session array / user selection.
  • You cannot load 2 languages (1 in the constructor, then another in a different class.. won't work!)

参考每篇论坛帖子: http://codeigniter.com/forums/viewthread/176223/

这篇关于Codeigniter更改加载的语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆