Language: Attempt to treat parameters as translation keys, even if they don't have %prefixes

%prefixes should only be necessary for embedded translations where the key isn't at the start of the string.

Longer term we should just drop raw string translation entirely and just translate Translatables exclusively, but this is a stepping stone.
This commit is contained in:
Dylan K. Taylor
2021-08-15 20:00:58 +01:00
parent 1aa541aefe
commit 39cdf23bd5

View File

@ -137,7 +137,7 @@ class Language{
$baseText = $this->parseTranslation(($onlyPrefix === null or strpos($str, $onlyPrefix) === 0) ? $baseText : $str, $onlyPrefix);
foreach($params as $i => $p){
$replacement = $p instanceof Translatable ? $this->translate($p) : $this->parseTranslation((string) $p);
$replacement = $p instanceof Translatable ? $this->translate($p) : $this->internalGet((string) $p) ?? $this->parseTranslation((string) $p);
$baseText = str_replace("{%$i}", $replacement, $baseText);
}
@ -149,7 +149,7 @@ class Language{
$baseText = $this->parseTranslation($baseText ?? $c->getText());
foreach($c->getParameters() as $i => $p){
$replacement = $p instanceof Translatable ? $this->translate($p) : $this->parseTranslation($p);
$replacement = $p instanceof Translatable ? $this->translate($p) : $this->internalGet($p) ?? $this->parseTranslation($p);
$baseText = str_replace("{%$i}", $replacement, $baseText);
}