• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
$this->lang->line with passing parameters

#3
(10-02-2015, 05:22 AM)ciadmin Wrote: Here's the idea...

$lang["error"]="this is error %s with msg %s"

then

$result = sprintf($this->lang('error'),"crazy,"want to do something good");

Display $result on your webpage or whatever.
This is the exact solution I was going to suggest.

If you want, you could do something like extend the lang library and either create a new method that will do this, or change the Lang::line method to look for parameters via Variadic functions, or if you dont have PHP 5.6 or later, use func_num_args to check if any arguments were passed, if not, just use the parent::line(), if there were, then handle them using func_get_args and sprintf, thats what I would do anyways.
Reply


Messages In This Thread
RE: $this->lang->line with passing parameters - by jLinux - 10-02-2015, 06:19 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.