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