Language\L10n method name fixes, update Smarty block.t.php

__pn for context plural has now correct name __np

Update smarty plugin block.t.php to use __* named gettext methods for
all calls, for __n/__np/__/__p calls we fallback to check internal set
class on l10n object variable.

This will be removed in future calls
This commit is contained in:
Clemens Schwaighofer
2022-04-15 16:53:02 +09:00
parent ffdd45e32a
commit 805c695d68
8 changed files with 81 additions and 46 deletions
+1 -1
View File
@@ -601,7 +601,7 @@ class L10n
* @param int $number number value
* @return string
*/
public function __pn(string $context, string $single, string $plural, int $number): string
public function __np(string $context, string $single, string $plural, int $number): string
{
if ($this->l10n === null) {
return $number > 1 ? $plural : $single;
+7 -2
View File
@@ -164,8 +164,6 @@ class SmartyExtend extends \Smarty
parent::__construct();
// iinit lang
$this->l10n = $l10n;
// opt load functions so we can use legacy init for smarty run perhaps
$this->l10n->loadFunctions();
// parse and read, legacy stuff
$this->encoding = $locale['encoding'];
$this->lang = $locale['lang'];
@@ -174,6 +172,13 @@ class SmartyExtend extends \Smarty
$this->domain = $this->l10n->getDomain();
$this->lang_dir = $this->l10n->getBaseLocalePath();
// opt load functions so we can use legacy init for smarty run perhaps
$this->l10n->loadFunctions();
__setlocale(LC_MESSAGES, $locale['locale']);
__textdomain($this->domain);
__bindtextdomain($this->domain, $this->lang_dir);
__bind_textdomain_codeset($this->domain, $this->encoding);
// register smarty variable
$this->registerPlugin('modifier', 'getvar', [&$this, 'getTemplateVars']);