mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Translate format text
This commit is contained in:
@ -78,6 +78,23 @@ class BaseLang{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $str
|
||||
* @param string[] $params
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function translateString($str, array $params = []){
|
||||
$baseText = $this->get($str);
|
||||
$baseText = $this->parseTranslation( $baseText !== null ? $baseText : $str);
|
||||
|
||||
foreach($params as $i => $p){
|
||||
$baseText = str_replace("{%$i}", $this->parseTranslation($p), $baseText);
|
||||
}
|
||||
|
||||
return $baseText;
|
||||
}
|
||||
|
||||
public function translate(TextContainer $c){
|
||||
if($c instanceof TranslationContainer){
|
||||
$baseText = $this->get($c->getText());
|
||||
|
@ -8,6 +8,13 @@ language.name=English
|
||||
multiplayer.player.joined={%0} joined the game
|
||||
multiplayer.player.leave={%0} left the game
|
||||
|
||||
chat.type.text=<{%0}> {%1}
|
||||
chat.type.emote=* {%0} {%1}
|
||||
chat.type.announcement=[{%0}] {%1}
|
||||
chat.type.admin=[{%0}: {%1}]
|
||||
chat.type.achievement={%0} has just earned the achievement {%1}
|
||||
|
||||
|
||||
death.fell.accident.generic={%0} fell from a high place
|
||||
death.attack.inFire={%0} went up in flames
|
||||
death.attack.onFire={%0} burned to death
|
||||
|
Reference in New Issue
Block a user