Let say the input of my custom language was:
$lang['number.you.got'] = 'Number you got was %1, %2 and %3';
I've modified the Lang.php in /system/core/ codeigniter 2 folder. Here is the code:
function line($line = '')
{
//get the arguments passed to the function
$args = func_get_args();
//count the number of arguments
$c = count($args);
//if one or more arguments, perform the necessary processing
if ($c)
{
//first argument should be the actual language line key
//so remove it from the array (pop from front)
$line = array_shift($args);
//check to make sure the key is valid and load the line
$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.'"');
}
//if the line exists and more function arguments remain
//perform wildcard replacements
if ($line && $args)
{
$i = 1;
foreach ($args as $arg)
{
$line = preg_replace('/\%'.$i.'/', $arg, $line);
$i++;
}
}
}
else
{
//if no arguments given, no language line available
$line = false;
}
return $line;
}
The modified codes above is to implement the language in the website, let say:
$this->lang->line('number.you.got','number1','number2','number3');
and the output will be
Number you got was number1, number2 and number3
Now, I used language_helper
in codeigniter v2
function lang($line)
{
$CI =& get_instance();
$line = $CI->lang->line($line);
$line = '<label>'.$line."</label>";
return $line;
}
But the result was not the same as I got before.
My expected result that if I can easily use helper lang('number.you.got','number1','number2','number3')
...
Anybody can help me?