diff --git a/lib/SimpleSAML/Locale/Translate.php b/lib/SimpleSAML/Locale/Translate.php index a01ee48ffc56f96cfa90a889ae54572e20a6aebe..1480ee0cbbd87e337c35717a06233e27a61fd5ed 100644 --- a/lib/SimpleSAML/Locale/Translate.php +++ b/lib/SimpleSAML/Locale/Translate.php @@ -495,4 +495,32 @@ class Translate return strtr($text, is_array($args[0]) ? $args[0] : $args); } + + + public static function translateSingularNativeGettext($original) + { + $text = gettext($original); + + if (func_num_args() === 1) { + return $text; + } + + $args = array_slice(func_get_args(), 1); + + return strtr($text, is_array($args[0]) ? $args[0] : $args); + } + + + public static function translatePluralNativeGettext($original, $plural, $value) + { + $text = ngettext($original, $plural, $value); + + if (func_num_args() === 3) { + return $text; + } + + $args = array_slice(func_get_args(), 3); + + return strtr($text, is_array($args[0]) ? $args[0] : $args); + } } diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php index 268e6dc279481b64f49e74f16298f95f615bf7ae..d7c089ee285c07c9ba0fb15ddda4411b12abeea0 100644 --- a/lib/SimpleSAML/XHTML/Template.php +++ b/lib/SimpleSAML/XHTML/Template.php @@ -168,8 +168,8 @@ class SimpleSAML_XHTML_Template $options = array( 'cache' => $cache, 'auto_reload' => $auto_reload, - 'translation_function' => 'gettext', - 'translation_function_plural' => 'ngettext', + 'translation_function' => array('\SimpleSAML\Locale\Translate', 'translateSingularNativeGettext'), + 'translation_function_plural' => array('\SimpleSAML\Locale\Translate', 'translatePluralNativeGettext'), ); // set up translation