Commit 4ca1a09c authored by Benoit Mortier's avatar Benoit Mortier
Browse files

Fixes: #1011 smarty3 with gettext generate funky errors :/

Showing with 12 additions and 9 deletions
+12 -9
......@@ -26,7 +26,7 @@
* @author Sagi Bashari <sagi@boom.org.il>
* @copyright 2004-2005 Sagi Bashari
*/
/**
* Replaces arguments in a string with their values.
* Arguments are represented by % followed by their number.
......@@ -42,7 +42,7 @@ function smarty_gettext_strarg($str)
for ($i=1; $i < func_num_args(); $i++) {
$arg = func_get_arg($i);
if (is_array($arg)) {
foreach ($arg as $aarg) {
$tr['%'.++$p] = $aarg;
......@@ -51,7 +51,7 @@ function smarty_gettext_strarg($str)
$tr['%'.++$p] = $arg;
}
}
return strtr($str, $tr);
}
......@@ -60,7 +60,7 @@ function smarty_gettext_strarg($str)
*
* The block content is the text that should be translated.
*
* Any parameter that is sent to the function will be represented as %n in the translation text,
* Any parameter that is sent to the function will be represented as %n in the translation text,
* where n is 1 for the first parameter. The following parameters are reserved:
* - escape - sets escape mode:
* - 'html' for HTML escaping, this is the default.
......@@ -72,26 +72,29 @@ function smarty_gettext_strarg($str)
*/
function smarty_block_t($params, $text, &$smarty)
{
if($text === NULL) {
return;
}
$text = stripslashes($text);
// set escape mode
if (isset($params['escape'])) {
$escape = $params['escape'];
unset($params['escape']);
}
// set plural version
if (isset($params['plural'])) {
$plural = $params['plural'];
unset($params['plural']);
// set count
if (isset($params['count'])) {
$count = $params['count'];
unset($params['count']);
}
}
// use plural if required parameters are set
if (isset($count) && isset($plural)) {
$text = ngettext($text, $plural, $count);
......@@ -119,7 +122,7 @@ function smarty_block_t($params, $text, &$smarty)
break;
}
}
return $text;
}
......
  • bmortier @bmortier

    mentioned in issue #379

    By bmortier on 2017-09-02T14:45:10 (imported from GitLab)

    ·

    mentioned in issue #379

    By bmortier on 2017-09-02T14:45:10 (imported from GitLab)

    Toggle commit list
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment