问题
I'm trying to do something like:
$config['first_link'] = 'lang:pagination_first_link';
$config['prev_link'] = 'lang:pagination_prev_link';
$config['next_link'] = 'lang:pagination_next_link';
$config['last_link'] = 'lang:pagination_last_link';
Is there a simple way to do this ?
This configuration is specific to the Pagination config file, but the question is generic.
回答1:
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.
回答2:
My answer in the best way to make codeigniter website multi-language. calling from lang arrays depends on lang session? might help.
来源:https://stackoverflow.com/questions/1291318/internationalization-on-codeigniter-config-files