Test plugins as loaded modifier, block t update
Update old block t data to match new block t class type Test if we can load plugin parts, this is a side test for if we want to not add them to the main Smarty load class Remove old test source code, no longer needed
This commit is contained in:
@@ -47,6 +47,17 @@ function smarty_gettext_strarg($str/*, $varargs... */)
|
||||
return strtr($str, $tr);
|
||||
}
|
||||
|
||||
/**
|
||||
* raise a notice for missing callable, indicates L10n functions where not loaded
|
||||
*
|
||||
* @param string $function
|
||||
* @return void
|
||||
*/
|
||||
function reportL10nNotInitialized(string $function): void
|
||||
{
|
||||
trigger_error("Missing " . $function . ", L10n::loadFunctions() called?", E_NOTICE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty block function, provides gettext support for smarty.
|
||||
*
|
||||
@@ -64,10 +75,10 @@ function smarty_gettext_strarg($str/*, $varargs... */)
|
||||
* - domain - Textdomain to be used, default if skipped (dgettext() instead of gettext())
|
||||
* - context - gettext context. reserved for future use.
|
||||
*
|
||||
* @param array<string,int|string> $params
|
||||
* @param string $text
|
||||
* @return string
|
||||
*/
|
||||
|
||||
// cs modified: __ calls instead of direct gettext calls
|
||||
|
||||
function smarty_block_t($params, $text)
|
||||
{
|
||||
if (!isset($text)) {
|
||||
@@ -110,52 +121,52 @@ function smarty_block_t($params, $text)
|
||||
if (isset($domain) && isset($context)) {
|
||||
if (is_callable('_dnpgettext')) {
|
||||
$text = _dnpgettext($domain, $context, $text, $plural, $count);
|
||||
}/* elseif (is_callable('dnpgettext')) {
|
||||
$text = dnpgettext($domain, $context, $text, $plural, $count);
|
||||
} */
|
||||
} else {
|
||||
reportL10nNotInitialized('_dnpgettext');
|
||||
}
|
||||
} elseif (isset($domain)) {
|
||||
if (is_callable('_dngettext')) {
|
||||
$text = _dngettext($domain, $text, $plural, $count);
|
||||
} elseif (is_callable('dngettext')) {
|
||||
$text = dngettext($domain, $text, $plural, $count);
|
||||
} else {
|
||||
reportL10nNotInitialized('_dngettext');
|
||||
}
|
||||
} elseif (isset($context)) {
|
||||
if (is_callable('_npgettext')) {
|
||||
$text = _npgettext($context, $text, $plural, $count);
|
||||
}/* elseif (is_callable('npgettext')) {
|
||||
$text = npgettext($context, $text, $plural, $count);
|
||||
} */
|
||||
} else {
|
||||
reportL10nNotInitialized('_npgettext');
|
||||
}
|
||||
} else {
|
||||
if (is_callable('_ngettext')) {
|
||||
$text = _ngettext($text, $plural, $count);
|
||||
} elseif (is_callable('ngettext')) {
|
||||
$text = ngettext($text, $plural, $count);
|
||||
} else {
|
||||
reportL10nNotInitialized('_ngettext');
|
||||
}
|
||||
}
|
||||
} else { // use normal
|
||||
if (isset($domain) && isset($context)) {
|
||||
if (is_callable('_dpgettext')) {
|
||||
$text = _dpgettext($domain, $context, $text);
|
||||
}/* elseif (is_callable('dpgettext')) {
|
||||
$text = dpgettext($domain, $context, $text);
|
||||
} */
|
||||
} else {
|
||||
reportL10nNotInitialized('_dpgettext');
|
||||
}
|
||||
} elseif (isset($domain)) {
|
||||
if (is_callable('_dgettext')) {
|
||||
$text = _dgettext($domain, $text);
|
||||
} elseif (is_callable('dpgettext')) {
|
||||
$text = dgettext($domain, $text);
|
||||
} else {
|
||||
reportL10nNotInitialized('_dgettext');
|
||||
}
|
||||
} elseif (isset($context)) {
|
||||
if (is_callable('_pgettext')) {
|
||||
$text = _pgettext($context, $text);
|
||||
}/* elseif (is_callable('pgettext')) {
|
||||
$text = pgettext($context, $text);
|
||||
} */
|
||||
} else {
|
||||
reportL10nNotInitialized('_pgettext');
|
||||
}
|
||||
} else {
|
||||
if (is_callable('_gettext')) {
|
||||
$text = _gettext($text);
|
||||
} elseif (is_callable('gettext')) {
|
||||
$text = gettext($text);
|
||||
} else {
|
||||
reportL10nNotInitialized('_gettext');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user