Ignore:
Timestamp:
Oct 19, 2013, 11:21:01 AM (7 years ago)
Author:
mistic100
Message:

feature 2978: l10n() and {translate} with additional arguments
TODO: apply in core

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions.inc.php

    r24833 r24988  
    901901
    902902/**
    903  * returns the corresponding value from $lang if existing. Else, the key is
    904  * returned
    905  *
    906  * @param string key
     903 * translation function
     904 * returns the corresponding value from $lang if existing, else the key is returned
     905 * if more than one parameter is provided sprintf is applied
     906 * @param string $key
     907 * @param mixed $args,... optional arguments
    907908 * @return string
    908909 */
     
    915916    if ($conf['debug_l10n'] and !isset($lang[$key]) and !empty($key))
    916917    {
    917       trigger_error('[l10n] language key "'.$key.'" is not defined', E_USER_WARNING);
     918      trigger_error('[l10n] language key "'. $key .'" not defined', E_USER_WARNING);
    918919    }
    919920    $val = $key;
    920921  }
     922
     923  if (func_num_args() > 1)
     924  {
     925    $val = vsprintf($val, array_slice(func_get_args(), 1));
     926  }
     927
    921928  return $val;
    922929}
    923930
    924931/**
    925  * returns the prinft value for strings including %d
     932 * returns the printf value for strings including %d
    926933 * return is concorded with decimal value (singular, plural)
    927934 *
Note: See TracChangeset for help on using the changeset viewer.