Translate format text

This commit is contained in:
Shoghi Cervantes
2015-04-11 02:15:46 +02:00
parent 0c041ebca3
commit c29ae333a2
8 changed files with 42 additions and 32 deletions

View File

@ -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());

View File

@ -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