|
本帖最后由 大道达人 于 2011-8-2 23:52 编辑
假设语言配置如下:
$lang['c_welcome']['c_hello'] = '欢迎您';//echo $this->lang->line('c_welcome');得到 Array
对CI_LANG修改了下,可以支持数组读取
Lang.php
function line($line = '' ,$index = NULL)
{
$line = ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line];
// Because killer robots like unicorns!
if ($line === FALSE)
{
log_message('error', 'Could not find the language line "'.$line.'"');
}
else
{
// Keys Value Check
if ($index !== NULL && is_array($line) && isset($line[$index]))
{
$line = $line[$index];
}
//TODO debug Code
}
return $line;
}
//调用直接 $this->lang->line('c_welcome','c_hello');
同时需要修改
language_helper.php
if ( ! function_exists('lang'))
{
function lang($line, $id = '', $index = NULL)
{
$CI =& get_instance();
if($index === NULL)
$line = $CI->lang->line($line);
else
$line = $CI->lang->line($line,$index);//exist key
if ($id != '')
{
$line = '<label for="'.$id.'">'.$line."</label>";
}
return $line;
}
}
|
|