aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions.inc.php
diff options
context:
space:
mode:
authorrub <rub@piwigo.org>2007-03-15 23:20:41 +0000
committerrub <rub@piwigo.org>2007-03-15 23:20:41 +0000
commit6d2ea02a9591a219f5964ecc98ffa3f7796039fa (patch)
tree81caf2c1745f31910d61ae2dcce316f657ca7f6c /include/functions.inc.php
parentd98c48bc6e0e5ab7de21e5252889270ecdea6c89 (diff)
Add new translation functions.inc.php
Translate subject of information mail. Notification mails are sent on the default language. No mail is sent to the author witch are not done actions git-svn-id: http://piwigo.org/svn/trunk@1908 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/functions.inc.php65
1 files changed, 64 insertions, 1 deletions
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 00a915d90..b69c88a71 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -1018,7 +1018,7 @@ function l10n($key)
{
global $lang, $conf;
- if ($conf['debug_l10n'] and !isset($lang[$key]))
+ if ($conf['debug_l10n'] and !isset($lang[$key]) and !empty($key))
{
echo '[l10n] language key "'.$key.'" is not defined<br />';
}
@@ -1047,6 +1047,69 @@ function l10n_dec($singular_fmt_key, $plural_fmt_key, $decimal)
: $singular_fmt_key
)), $decimal);
}
+/*
+ * returns a single element to use with l10n_args
+ *
+ * @param string key: translation key
+ * @param array/string/../number args:
+ * arguments to use on sprintf($key, args)
+ * if args is a array, each values are used on sprintf
+ * @return string
+ */
+function get_l10n_args($key, $args)
+{
+ if (is_array($args))
+ {
+ $key_arg = array_merge(array($key), $args);
+ }
+ else
+ {
+ $key_arg = array($key, $args);
+ }
+ return array('key_args' => $key_arg);
+}
+
+/*
+ * returns a string with formated with l10n_args elements
+ *
+ * @param element/array $key_args: element or array of l10n_args elements
+ * @param $sep: if $key_args is array,
+ * separator is used when translated l10n_args elements are concated
+ * @return string
+ */
+function l10n_args($key_args, $sep = "\n")
+{
+ if (is_array($key_args))
+ {
+ foreach ($key_args as $key => $element)
+ {
+ if (isset($result))
+ {
+ $result .= $sep;
+ }
+ else
+ {
+ $result = '';
+ }
+
+ if ($key === 'key_args')
+ {
+ array_unshift($element, l10n(array_shift($element)));
+ $result .= call_user_func_array('sprintf', $element);
+ }
+ else
+ {
+ $result .= l10n_args($element, $sep);
+ }
+ }
+ }
+ else
+ {
+ die('l10n_args: Invalid arguments');
+ }
+
+ return $result;
+}
/**
* Translate string in string ascii7bits