aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions.inc.php
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2013-10-19 09:21:01 +0000
committermistic100 <mistic@piwigo.org>2013-10-19 09:21:01 +0000
commit6313ae831dc0844267fc3676cbd0baa0ddfb90c9 (patch)
tree5137408fe7f33f51b93095187fb7184038256251 /include/functions.inc.php
parent2209edc7f070ff398b3bb8c64d5e7c036ecbb607 (diff)
feature 2978: l10n() and {translate} with additional arguments
TODO: apply in core git-svn-id: http://piwigo.org/svn/trunk@24988 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/functions.inc.php')
-rw-r--r--include/functions.inc.php19
1 files changed, 13 insertions, 6 deletions
diff --git a/include/functions.inc.php b/include/functions.inc.php
index be6c57114..09d104cdc 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -900,10 +900,11 @@ function get_name_from_file($filename)
}
/**
- * returns the corresponding value from $lang if existing. Else, the key is
- * returned
- *
- * @param string key
+ * translation function
+ * returns the corresponding value from $lang if existing, else the key is returned
+ * if more than one parameter is provided sprintf is applied
+ * @param string $key
+ * @param mixed $args,... optional arguments
* @return string
*/
function l10n($key)
@@ -914,15 +915,21 @@ function l10n($key)
{
if ($conf['debug_l10n'] and !isset($lang[$key]) and !empty($key))
{
- trigger_error('[l10n] language key "'.$key.'" is not defined', E_USER_WARNING);
+ trigger_error('[l10n] language key "'. $key .'" not defined', E_USER_WARNING);
}
$val = $key;
}
+
+ if (func_num_args() > 1)
+ {
+ $val = vsprintf($val, array_slice(func_get_args(), 1));
+ }
+
return $val;
}
/**
- * returns the prinft value for strings including %d
+ * returns the printf value for strings including %d
* return is concorded with decimal value (singular, plural)
*
* @param singular string key