Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
508 views
in Technique[技术] by (71.8m points)

php - Autoload language codeigniter

making a multi-language site with codeginiter. I have created two folders. One for french language files and one for english. When I go to autoload the languages (English and French) as such

($autoload['language'] = array('en', 'fr');)

I get an error "Unable to load the requested language file: language/english/fr_lang.php"

How can I get it to look in the proper folder?

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
$config['language']

is the default folder used for loading language files, which is why your

fr_lang.php

is loaded from there.

Either change the value of:

$config['language']

when needed, like:

$this->config->set_item('language', 'value');

(Remember this has to be done before the languages load, so you would use a hook for that http://codeigniter.com/user_guide/general/hooks.html.)

Or else, load your language files on the fly:

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

You should definitely check out the core classes to get a better understanding of how things work. You can browse the code easily here: https://github.com/EllisLab/CodeIgniter For instance, the languages are loaded with this class: https://github.com/EllisLab/CodeIgniter/blob/develop/system/core/Lang.php

If you need any more help, let me know.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...