Localization/UIEscapes

* fixed expanding |2 placeholder in general and when the referenced word itself was a placeholder ($N => <nom>)
 * fixed expanding |3 placeholder for caseIds > 9
This commit is contained in:
Sarjuuk
2025-10-13 20:32:19 +02:00
parent 04f3aa7a82
commit 92c58cc5d1

View File

@@ -746,28 +746,28 @@ class Lang
}, $var); }, $var);
// |2 - frFR preposition: de |2 <word> // |2 - frFR preposition: de |2 <word>
$var = preg_replace_callback('/\|2\s?(\w)/i', function ($m) $var = preg_replace_callback('/\|2\s?(.)/i', function ($m)
{ {
[$_, $word] = $m; [$_, $char] = $m;
switch (strtolower($word[1])) switch (strtolower($char))
{ {
case 'h': case 'h':
if (self::$locale != Locale::FR) if (self::$locale != Locale::FR)
return 'de ' . $word; return 'de ' . $char;
case 'a': case 'a':
case 'e': case 'e':
case 'i': case 'i':
case 'o': case 'o':
case 'u': case 'u':
return "d'" . $word; return "d'" . $char;
default: default:
return 'de ' . $word; return 'de ' . $char;
} }
}, $var); }, $var);
// |3 - ruRU declinations |3-<caseIdx>(<word>) // |3 - ruRU declinations |3-<caseIdx>(<word>)
$var = preg_replace_callback('/\|3-(\d)\(([^\)]+)\)/iu', function ($m) $var = preg_replace_callback('/\|3-(\d+)\(([^\)]+)\)/iu', function ($m)
{ {
[$_, $caseIdx, $word] = $m; [$_, $caseIdx, $word] = $m;
@@ -777,7 +777,7 @@ class Lang
if (preg_match('/\P{Cyrillic}/iu', $word)) // not in cyrillic script if (preg_match('/\P{Cyrillic}/iu', $word)) // not in cyrillic script
return $word; return $word;
if ($declWord = DB::Aowow()->selectCell('SELECT dwc.word FROM ?_declinedwordcases dwc JOIN ?_declinedword dc ON dwc.wordId = dc.id WHERE dwc.caseIdx = ?d AND dc.word = ?', $caseIdx, $word)) if ($declWord = DB::Aowow()->selectCell('SELECT dwc.`word` FROM ?_declinedwordcases dwc JOIN ?_declinedword dc ON dwc.`wordId` = dc.`id` WHERE dwc.`caseIdx` = ?d AND dc.`word` = ?', $caseIdx, $word))
return $declWord; return $declWord;
return $word; return $word;