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