mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-20 15:41:33 +00:00
Scrap TextContainer, make TranslationContainer immutable
TextContainer provided zero real value as a base of TranslationContainer, given that it required its own logic to be handled wherever accepted. As such, it's no better than a simple string. Removing it also allows fixing an ambiguity when embedding translations inside other translations, allowing it to be made immutable.
This commit is contained in:
@@ -142,16 +142,12 @@ class Language{
|
||||
return $baseText;
|
||||
}
|
||||
|
||||
public function translate(TextContainer $c) : string{
|
||||
if($c instanceof TranslationContainer){
|
||||
$baseText = $this->internalGet($c->getText());
|
||||
$baseText = $this->parseTranslation($baseText ?? $c->getText());
|
||||
public function translate(TranslationContainer $c) : string{
|
||||
$baseText = $this->internalGet($c->getText());
|
||||
$baseText = $this->parseTranslation($baseText ?? $c->getText());
|
||||
|
||||
foreach($c->getParameters() as $i => $p){
|
||||
$baseText = str_replace("{%$i}", $this->parseTranslation($p), $baseText);
|
||||
}
|
||||
}else{
|
||||
$baseText = $this->parseTranslation($c->getText());
|
||||
foreach($c->getParameters() as $i => $p){
|
||||
$baseText = str_replace("{%$i}", $this->parseTranslation($p), $baseText);
|
||||
}
|
||||
|
||||
return $baseText;
|
||||
|
Reference in New Issue
Block a user