public function lookup(string $key, string $lang = 'en-us', ...$params) : string
{
if (!\array_key_exists($lang, $this->phrases)) {
$this->phrases[$lang] = \Airship\loadJSON(ROOT . '/lang/' . $lang . '.json');
}
$split_key = \explode('.', $key);
$v = $this->phrases[$lang];
foreach ($split_key as $k) {
if (!\array_key_exists($k, $v)) {
throw new TranslationKeyNotFound($key);
}
$v = $v[$k];
}
$str = '';
while (empty($str)) {
/** @noinspection PhpUsageOfSilenceOperatorInspection */
$str = @\sprintf($v, ...$params);
\array_push($params, '');
}
return $str;
}