mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
TranslationContainer: Add support for named translation parameters
this also fixes use cases like: [1] = something; [0] = match(...) It made no sense whatsoever to discard the keys anyway. Language::translateString() already supported named parameters since forever anyway.
This commit is contained in:
parent
de61417bb6
commit
d39080c45a
@ -36,11 +36,8 @@ final class TranslationContainer{
|
||||
public function __construct(string $text, array $params = []){
|
||||
$this->text = $text;
|
||||
|
||||
$i = 0;
|
||||
foreach($params as $str){
|
||||
$this->params[$i] = (string) $str;
|
||||
|
||||
++$i;
|
||||
foreach($params as $k => $str){
|
||||
$this->params[$k] = (string) $str;
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,7 +52,7 @@ final class TranslationContainer{
|
||||
return $this->params;
|
||||
}
|
||||
|
||||
public function getParameter(int $i) : ?string{
|
||||
public function getParameter(int|string $i) : ?string{
|
||||
return $this->params[$i] ?? null;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user