Internationalization on CodeIgniter config files?

假如想象 提交于 2019-12-02 09:45:24

You have language folders for that. If you take a look at system/language/english, you can see how CodeIgniter deals with internationalization.

For your example, you would create a file in system/language/english, called pagination.php, for example.

$lang['first_link'] = 'First Link';
$lang['prev_link']  = 'Previous Link';
etc...

If you wanted to create more languages, you could just create folders for them under system/language. Then you could just load the language file before setting the configurations, and then it's as easy as writing this:

$config['first_link'] = $this->lang->line('first_link');

If you have those pagination configurations inside a config file, not on your controller, I can't think of an easy to do it, without a bit of a hack. You would have this:

$CI =& get_instance();
$CI->lang->load('pagination', 'english');

$config['first_link'] = $CI->lang->line('first_link');
$config['prev_link']  = $CI->lang->line('prev_link');

I hope I was able to help.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!