Francisco Diéguez
unread,Jan 18, 2012, 10:01:58 AM1/18/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Smarty Developers
Hi all,
I have a weird issue with the block {t}{/t} in Smarty 3.1.7. This
block was working with Smarty 3.0.
For every single message that handles the block, smarty always
prepends the po file header:
Project-Id-Version: onmadmin 0.8
Report-Msgid-Bugs-To:
POT-Creation-Date: 2012-01-18 15:31+0100
PO-Revision-Date: 2012-01-03 13:34+0100
Last-Translator: #######
Language-Team: ####
Language: gl_ES
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Plural-Forms: nplurals=2; plural=(n!=1);
If I put my application in english (no translations) all works like a
charm.
Here is the code for from block.t.php (I have stripped php coments for
making this message shorter)
<?php
function smarty_gettext_strarg($str)
{
$tr = array();
$p = 0;
for ($i=1; $i < func_num_args(); $i++) {
$arg = func_get_arg($i);
if (is_array($arg)) {
foreach ($arg as $aarg) {
$tr['%'.++$p] = $aarg;
}
} else {
$tr['%'.++$p] = $arg;
}
}
return strtr($str, $tr);
}
function smarty_block_t($params, $text, &$smarty)
{
$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);
} else { // use normal
$text = gettext($text);
}
// run strarg if there are parameters
if (count($params)) {
$text = smarty_gettext_strarg($text, $params);
}
if (!isset($escape) || $escape == 'html') { // html escape,
default
$text = nl2br(htmlspecialchars($text));
} elseif (isset($escape)) {
switch ($escape) {
case 'javascript':
case 'js':
// javascript escape
$text = str_replace('\'', '\\\'',
stripslashes($text));
break;
case 'url':
// url escape
$text = urlencode($text);
break;
}
}
return $text;
}