Spells/Localization

* use more GlobalStrings in spell context (as far as possible)
 * fixed rune cost order
 * fixes agains locale based time formater
This commit is contained in:
Sarjuuk
2023-05-06 04:26:18 +02:00
parent 8bf7b3ee06
commit ebc20be508
8 changed files with 252 additions and 103 deletions

View File

@@ -69,38 +69,41 @@ class Lang
self::$main['moreTitles']['privilege'] = self::$privileges['_privileges'];
}
public static function __callStatic(string $prop, array $args) : ?string
public static function __callStatic(string $prop, array $args) // : ?string|array
{
$vspfArgs = [];
foreach ($args as $i => $arg)
{
if (!is_array($arg))
continue;
$vspfArgs = $arg;
unset($args[$i]);
}
if ($x = self::exist($prop, ...$args))
return self::vspf($x, $vspfArgs);
$dbt = debug_backtrace()[0];
$file = explode(DIRECTORY_SEPARATOR, $dbt['file']);
trigger_error('Lang - undefined property Lang::$'.$prop.'[\''.implode('\'][\'', $args).'\'], called in '.array_pop($file).':'.$dbt['line'], E_USER_WARNING);
}
public static function exist(string $prop, ...$args)
{
if (!isset(self::$$prop))
{
$dbt = debug_backtrace()[0];
$file = explode(DIRECTORY_SEPARATOR, $dbt['file']);
trigger_error('Lang - tried to use undefined property Lang::$'.$prop.', called in '.array_pop($file).':'.$dbt['line'], E_USER_WARNING);
return null;
}
$vspfArgs = [];
$var = self::$$prop;
foreach ($args as $arg)
$ref = self::$$prop;
foreach ($args as $a)
{
if (is_array($arg))
{
$vspfArgs = $arg;
continue;
}
else if (!isset($var[$arg]))
{
$dbt = debug_backtrace()[0];
$file = explode(DIRECTORY_SEPARATOR, $dbt['file']);
trigger_error('Lang - undefined property Lang::$'.$prop.'[\''.implode('\'][\'', $args).'\'], called in '.array_pop($file).':'.$dbt['line'], E_USER_WARNING);
if (!isset($ref[$a]))
return null;
}
$var = $var[$arg];
$ref = $ref[$a];
}
return self::vspf($var, $vspfArgs);
return $ref;
}
public static function concat(array $args, bool $useAnd = true, ?callable $callback = null) : string
@@ -531,7 +534,9 @@ class Lang
if ($msec < 0)
$msec = 0;
[$ms, $s, $m, $h, $d] = Util::parseTime($msec);
$time = Util::parseTime($msec); // [$ms, $s, $m, $h, $d]
$mult = [0, 1000, 60, 60, 24];
$total = 0;
$ref = [];
$result = [];
@@ -543,19 +548,36 @@ class Lang
return '';
}
if ($d >= 1)
$result[] = self::vspf($ref[4], [$d + $h / 24]);
if ($h >= 1 && ($concat || !$result))
$result[] = self::vspf($ref[3], [$h + $m / 60]);
if ($m >= 1 && ($concat || !$result))
$result[] = self::vspf($ref[2], [$m + $s / 60]);
if ($s >= 1 && ($concat || !$result))
$result[] = self::vspf($ref[1], [$s]);
if (!$msec)
return self::vspf($ref[0], [0]);
if (!$result)
$result[] = self::vspf($ref[0]);
if ($concat)
{
for ($i = 4; $i > 0; $i--)
{
$total += $time[$i];
if (isset($ref[$i]) && ($total || ($i == 1 && !$result)))
{
$result[] = self::vspf($ref[$i], [$total]);
$total = 0;
}
else
$total *= $mult[$i];
}
return implode(', ', $result);
return implode(', ', $result);
}
for ($i = 4; $i > 0; $i--)
{
$total += $time[$i];
if (isset($ref[$i]) && ($total || $i == 1))
return self::vspf($ref[$i], [$total + ($time[$i-1] ?? 0) / $mult[$i]]);
else
$total *= $mult[$i];
}
return '';
}
private static function vspf(/* array|string */ $var, array $args = []) // : array|string

View File

@@ -1457,9 +1457,6 @@ $lang = array(
'procChance' => "Procchance",
'starter' => "Basiszauber",
'trainingCost' => "Trainingskosten",
'castIn' => "Wirken in %s Sek.",
'instantPhys' => "Sofort",
'instantMagic' => "Spontanzauber",
'channeled' => "Kanalisiert",
'range' => "%s Meter Reichweite",
'meleeRange' => "Nahkampfreichweite",
@@ -1473,6 +1470,19 @@ $lang = array(
'stackGroup' => "Stack Gruppierung",
'linkedWith' => "Verknüpft mit",
'_scaling' => "Skalierung",
'instantPhys' => "Sofort",
'castTime' => array(
"Spontanzauber",
"Wirken in %.3g Sek.",
"Wirken in %.3g Min."
),
'cooldown' => array(
"Keine Abklingzeit",
"%.3g Sek. Abklingzeit",
"%.3g Min. Abklingzeit",
// "%.3g |4Stunde:Stunden; Abklingzeit",
// "%.3g |4Tag:Tage; Abklingzeit"
),
'duration' => array(
"bis Abbruch",
"%.2G Sek.",
@@ -1487,10 +1497,16 @@ $lang = array(
"Noch %d |4Stunde:Stunden;",
"Noch %d |4Tag:Tage;"
),
'scaling' => array(
'directSP' => "+%.2f%% der Zaubermacht zum direkten Effekt", 'directAP' => "+%.2f%% der Angriffskraft zum direkten Effekt",
'dotSP' => "+%.2f%% der Zaubermacht pro Tick", 'dotAP' => "+%.2f%% der Angriffskraft pro Tick"
'powerCost' => array(
-2 => ["%d Gesundheit", '%1$d Gesundheit und %2$d pro Sek.'],
0 => ["%d Mana", '%1$d Mana und %2$d pro Sek.' ],
1 => ["%d Wut", '%1$d Wut und %2$d pro Sek.' ],
2 => ["%d Fokus", "%d Fokus und %d pro Sek." ],
3 => ["%d Energie", "%d Energie und %d pro Sek." ],
6 => ["%d Runenmacht", "%d Runenmacht, plus %d pro Sek." ],
),
'powerDisplayCost' => ["%d %s", "%d %s, plus %d pro Sek"],
'powerCostRunes'=> ["%d Blut", "%d Unheilig", "%d Frost"],
'powerRunes' => ["Blut", "Unheilig", "Frost", "Tod"],
'powerTypes' => array(
// conventional
@@ -1500,6 +1516,10 @@ $lang = array(
-1 => "Munition", -41 => "Pyrit", -61 => "Dampfdruck", -101 => "Hitze", -121 => "Schlamm", -141 => "Blutmacht",
-142 => "Wrath"
),
'scaling' => array(
'directSP' => "+%.2f%% der Zaubermacht zum direkten Effekt", 'directAP' => "+%.2f%% der Angriffskraft zum direkten Effekt",
'dotSP' => "+%.2f%% der Zaubermacht pro Tick", 'dotAP' => "+%.2f%% der Angriffskraft pro Tick"
),
'relItems' => array(
'base' => "<small>%s im Zusammenhang mit <b>%s</b> anzeigen</small>",
'link' => " oder ",

View File

@@ -1457,9 +1457,6 @@ $lang = array(
'procChance' => "Proc chance",
'starter' => "Starter spell",
'trainingCost' => "Training cost",
'castIn' => "%s sec cast", // SPELL_CAST_TIME_SEC
'instantPhys' => "Instant", // SPELL_CAST_TIME_INSTANT_NO_MANA
'instantMagic' => "Instant cast", // SPELL_CAST_TIME_INSTANT
'channeled' => "Channeled", // SPELL_CAST_CHANNELED
'range' => "%s yd range", // SPELL_RANGE / SPELL_RANGE_DUAL
'meleeRange' => "Melee Range", // MELEE_RANGE
@@ -1473,6 +1470,19 @@ $lang = array(
'stackGroup' => "Stack Group",
'linkedWith' => "Linked with",
'_scaling' => "Scaling",
'instantPhys' => "Instant", // SPELL_CAST_TIME_INSTANT_NO_MANA
'castTime' => array(
"Instant cast", // SPELL_CAST_TIME_INSTANT
"Wirken in %.3g Sek.", // SPELL_CAST_TIME_SEC
"Wirken in %.3g Min." // SPELL_CAST_TIME_MIN
),
'cooldown' => array(
"Instant cooldown", // SPELL_RECAST_TIME_INSTANT not used?
"%.3g sec cooldown", // SPELL_RECAST_TIME_SEC
"%.3g min cooldown", // SPELL_RECAST_TIME_MIN
// "%.3g hour cooldown", // SPELL_RECAST_TIME_HOURS not in 3.3.5
// "%.3g day cooldown" // SPELL_RECAST_TIME_DAYS not in 3.3.5
),
'duration' => array( // SPELL_DURATION_*
"until cancelled",
"%.2G sec",
@@ -1487,11 +1497,17 @@ $lang = array(
"%d |4hour:hours; remaining",
"%d |4day:days; remaining"
),
'scaling' => array(
'directSP' => "+%.2f%% of spell power to direct component", 'directAP' => "+%.2f%% of attack power to direct component",
'dotSP' => "+%.2f%% of spell power per tick", 'dotAP' => "+%.2f%% of attack power per tick"
'powerCost' => array(
-2 => ["%d Health", "%d Health, plus %d per sec" ], // HEALTH_COST HEALTH_COST_PER_TIME
0 => ["%d Mana", "%d Mana, plus %d per sec" ], // MANA_COST MANA_COST_PER_TIME
1 => ["%d Rage", "%d Rage, plus %d per sec" ], // RAGE_COST RAGE_COST_PER_TIME
2 => ["%d Focus", "%d Focus, plus %d per sec" ], // FOCUS_COST FOCUS_COST_PER_TIME
3 => ["%d Energy", "%d Energy, plus %d per sec" ], // ENERGY_COST ENERGY_COST_PER_TIME
6 => ["%d Runic Power", "%d Runic Power, plus %d per sec"], // RUNIC_POWER_COST RUNIC_POWER_COST_PER_TIME
),
'powerRunes' => ["Blood", "Unholy", "Frost", "Death"], // RUNE_COST_* / COMBAT_TEXT_RUNE_*
'powerDisplayCost' => ["%d %s", "%d %s, plus %d per sec"], // POWER_DISPLAY_COST POWER_DISPLAY_COST_PER_TIME
'powerCostRunes'=> ["%d Blood", "%d Unholy", "%d Frost"], // RUNE_COST_*
'powerRunes' => ["Blood", "Unholy", "Frost", "Death"], // COMBAT_TEXT_RUNE_*
'powerTypes' => array(
// conventional - HEALTH, MANA, RAGE, FOCUS, ENERGY, HAPPINESS, RUNES, RUNIC_POWER / *_COST / *COST_PER_TIME
-2 => "Health", 0 => "Mana", 1 => "Rage", 2 => "Focus", 3 => "Energy", 4 => "Happiness",
@@ -1500,6 +1516,10 @@ $lang = array(
-1 => "Ammo", -41 => "Pyrite", -61 => "Steam Pressure", -101 => "Heat", -121 => "Ooze", -141 => "Blood Power",
-142 => "Wrath"
),
'scaling' => array(
'directSP' => "+%.2f%% of spell power to direct component", 'directAP' => "+%.2f%% of attack power to direct component",
'dotSP' => "+%.2f%% of spell power per tick", 'dotAP' => "+%.2f%% of attack power per tick"
),
'relItems' => array(
'base' => "<small>Show %s related to <b>%s</b></small>",
'link' => " or ",

View File

@@ -1457,9 +1457,6 @@ $lang = array(
'procChance' => "Probabilidad de que accione",
'starter' => "Hechizo inicial",
'trainingCost' => "Costo de enseñanza",
'castIn' => "Hechizo de %s seg",
'instantPhys' => "Instante",
'instantMagic' => "Hechizo instantáneo",
'channeled' => "Canalizado",
'range' => "Alcance de %s m",
'meleeRange' => "Alcance de ataques cuerpo a cuerpo",
@@ -1473,6 +1470,19 @@ $lang = array(
'stackGroup' => "Grupo de aplilamiento",
'linkedWith' => "Asociado con",
'_scaling' => "Escala",
'instantPhys' => "Instantáneo",
'castTime' => array(
"Hechizo instantáneo",
"%.3g s para lanzar",
"Hechizo de %.3g min"
),
'cooldown' => array(
"Reutilización instantánea",
"Reutilización: %.3g s",
"Reutilización: %.3g min",
// "Reutilización: %.3g h",
// "Reutilización: %.3g días"
),
'duration' => array(
"hasta cancelación",
"%.2G s",
@@ -1487,10 +1497,16 @@ $lang = array(
"%d |4hora restante:horas restantes;",
"%d |4día restante:días restantes;"
),
'scaling' => array(
'directSP' => "+%.2f%% del poder de hechizo al componente directo", 'directAP' => "+%.2f%% del poder de ataque al componente directo",
'dotSP' => "+%.2f%% del poder de hechizo por tick", 'dotAP' => "+%.2f%% del poder de ataque por tick"
'powerCost' => array(
-2 => ["Salud %d", "%d p. de salud, más %d p. por segundo"],
0 => ["%d p. de maná", "%d p. de maná, más %d por s"],
1 => ["%d p. de ira", "%d Ira, más %d por s"],
2 => ["%d p. de enfoque", "%d enfoque, más %d por s"],
3 => ["%d p. de energía", "%d energía, más %d por s"],
6 => ["%d Poder rúnico", "%d poder rúnico, más %d por segundo"]
),
'powerDisplayCost' => ["%d %s", "%d %s, más %d por seg."],
'powerCostRunes'=> ["%d sangre", "%d Profano", "%d Escarcha"],
'powerRunes' => ["Sangre", "Profano", "Escarcha", "Muerte"],
'powerTypes' => array(
// conventional
@@ -1500,6 +1516,10 @@ $lang = array(
-1 => "Munición", -41 => "Pirita", -61 => "Presión de vapor", -101 => "Calor", -121 => "Moco", -141 => "Poder de sangre",
-142 => "Cólera"
),
'scaling' => array(
'directSP' => "+%.2f%% del poder de hechizo al componente directo", 'directAP' => "+%.2f%% del poder de ataque al componente directo",
'dotSP' => "+%.2f%% del poder de hechizo por tick", 'dotAP' => "+%.2f%% del poder de ataque por tick"
),
'relItems' => array(
'base' => "<small>Muestra %s relacionados con <b>%s</b></small>",
'link' => " u ",

View File

@@ -1457,9 +1457,6 @@ $lang = array(
'procChance' => "Chance",
'starter' => "Sortilège initiaux",
'trainingCost' => "Coût d'entraînement",
'castIn' => "%s s d'incantation",
'instantPhys' => "Incantation immédiate",
'instantMagic' => "Instantanée",
'channeled' => "Canalisée",
'range' => "%s m de portée",
'meleeRange' => "Allonge",
@@ -1473,6 +1470,19 @@ $lang = array(
'stackGroup' => "[Stack Group]",
'linkedWith' => "[Linked with]",
'_scaling' => "[Scaling]",
'instantPhys' => "Instantané",
'castTime' => array(
"Incantation immédiate",
"%.3g sec. d'incantation",
"%.3g min d'incantation"
),
'cooldown' => array(
"Recharge instantanée",
"%.3g sec. de recharge", // "Recharge en cours : %d |4seconde:secondes;";
"%.3g min de recharge", // "Recharge en cours : %d |4minute:minutes;";
// "Recharge en cours : %d |4heure:heures;",
// "Recharge en cours : %d |4jour:jours;"
),
'duration' => array(
"jusquà annulation",
"%.2G sec.",
@@ -1487,10 +1497,16 @@ $lang = array(
"%d |4heure restante:heures restantes;",
"%d |4jour restant:jours restants;"
),
'scaling' => array(
'directSP' => "+%.2f%% de la puissance des sorts directe", 'directAP' => "+%.2f%% de la puissance d'attaque directe",
'dotSP' => "+%.2f%% de la puissance des sorts par tick", 'dotAP' => "+%.2f%% de la puissance d'attaque par tick"
'powerCost' => array(
-2 => ["%d points de vie", "Points de vie %d, plus %d par sec." ],
0 => ["Mana : %d", "%d mana, plus %d par sec." ],
1 => ["Rage : %d", "Rage %d, plus %d par sec." ],
2 => ["Focalisation : %d", "Focalisation %d, plus %d par sec." ],
3 => ["Énergie : %d", "Énergie %d, plus %d par sec." ],
6 => ["%d puissance runique", "%d puissance runique, plus %d par sec." ],
),
'powerDisplayCost' => ["%d %s", "%d %s, plus %d par seconde"],
'powerCostRunes'=> ["%d sang", "%d impie", "%d givre"],
'powerRunes' => ["Sang", "Impie", "Givre", "Mort"],
'powerTypes' => array(
// conventional
@@ -1500,6 +1516,10 @@ $lang = array(
-1 => "Munitions", -41 => "Pyrite", -61 => "Pression vapeur", -101 => "Chaleur", -121 => "Limon", -141 => "Puissance de sang",
-142 => "Courroux"
),
'scaling' => array(
'directSP' => "+%.2f%% de la puissance des sorts directe", 'directAP' => "+%.2f%% de la puissance d'attaque directe",
'dotSP' => "+%.2f%% de la puissance des sorts par tick", 'dotAP' => "+%.2f%% de la puissance d'attaque par tick"
),
'relItems' => array(
'base' => "<small>Montre %s reliés à <b>%s</b></small>",
'link' => " ou ",

View File

@@ -1457,9 +1457,6 @@ $lang = array(
'procChance' => "Шанс срабатывания",
'starter' => "Начальное заклинание",
'trainingCost' => "Цена обучения",
'castIn' => "Применение: %s сек.",
'instantPhys' => "Мгновенное действие",
'instantMagic' => "Мгновенное действие",
'channeled' => "Направляемое",
'range' => "Радиус действия: %s м",
'meleeRange' => "Дистанция ближнего боя",
@@ -1473,6 +1470,19 @@ $lang = array(
'stackGroup' => "[Stack Group]",
'linkedWith' => "[Linked with]",
'_scaling' => "[Scaling]",
'instantPhys' => "Мгновенное действие",
'castTime' => array(
"Мгновенное действие",
"Применение: %.3g сек.",
"применение заклинания: %.3g мин."
),
'cooldown' => array(
"Мгновенное восстановление",
"Восстановление: %.3g сек.",
"Восстановление: %.3g мин.",
// "Восстановление: %.3g ч.",
// "Восстановление: %.3g д."
),
'duration' => array(
"до отмены",
"%.2G сек",
@@ -1487,10 +1497,16 @@ $lang = array(
"Осталось: %d |4час:часа:часов;",
"Осталось: %d |4день:дня:дней;"
),
'scaling' => array(
'directSP' => "[+%.2f%% of spell power to direct component]", 'directAP' => "[+%.2f%% of attack power to direct component]",
'dotSP' => "[+%.2f%% of spell power per tick]", 'dotAP' => "[+%.2f%% of attack power per tick]"
),
'powerCost' => array(
-2 => ["Здоровье: %d", "Здоровье: %d плюс %d/сек."],
0 => ["Мана: %d", "Мана: %d плюс %d/сек" ],
1 => ["Ярость: %d", "Ярость: %d плюс %d/сек" ],
2 => ["Тонус: %d", "Тонус: %d плюс %d/сек." ],
3 => ["Энергия: %d", "Энергия: %d плюс %d/сек." ],
6 => ["Требуется %d |4единица:единицы:единиц; силы рун", "Cила рун: %d плюс %d/сек" ],
),
'powerDisplayCost' => ['%2$s: %1$d', "%d %s и %d в сек. дополнительно"],
'powerCostRunes'=> ["%d |4руна:руны:рун; крови", "%d |4руна:руны:рун; нечестивости", "%d |4руна:руны:рун; льда"],
'powerRunes' => ["Руна крови", "Руна льда", "Лед", "Смерти"],
'powerTypes' => array(
// conventional
@@ -1500,6 +1516,10 @@ $lang = array(
-1 => "Боеприпасы", -41 => "Колчедан", -61 => "Давление пара", -101 => "Жар", -121 => "Слизнюк", -141 => "Сила крови",
-142 => "Гнев"
),
'scaling' => array(
'directSP' => "[+%.2f%% of spell power to direct component]", 'directAP' => "[+%.2f%% of attack power to direct component]",
'dotSP' => "[+%.2f%% of spell power per tick]", 'dotAP' => "[+%.2f%% of attack power per tick]"
),
'relItems' => array(
'base' => "<small>Показать %s, относящиеся к профессии <b>%s</b></small>",
'link' => " или ",

View File

@@ -1456,9 +1456,6 @@ $lang = array(
'procChance' => "触发几率",
'starter' => "Starter spell",
'trainingCost' => "训练成本",
'castIn' => "%s秒施法时间",
'instantPhys' => "瞬发",
'instantMagic' => "瞬发",
'channeled' => "需引导",
'range' => "%s码范围",
'meleeRange' => "近战范围",
@@ -1472,6 +1469,19 @@ $lang = array(
'stackGroup' => "Stack Group",
'linkedWith' => "Linked with",
'_scaling' => "缩放比例",
'instantPhys' => "瞬发",
'castTime' => array(
"瞬发法术",
"%.3g秒施法时间",
"%.3g分钟施法时间"
),
'cooldown' => array(
"即时冷却",
"%.3g秒冷却时间",
"%.3g分钟冷却时间",
// "%.3g小时冷却时间",
// "%.3g天冷却时间"
),
'duration' => array(
"直到主动取消",
"%.2G秒",
@@ -1486,10 +1496,16 @@ $lang = array(
"剩余%d小时",
"剩余%d天"
),
'scaling' => array(
'directSP' => "+%.2f%% of spell power to direct component", 'directAP' => "+%.2f%% of attack power to direct component",
'dotSP' => "+%.2f%% of spell power per tick", 'dotAP' => "+%.2f%% of attack power per tick"
'powerCost' => array(
-2 => ["%d生命值", "%d生命值每秒增加%d" ],
0 => ["%d法力值", "%d点法力值外加每秒%d点" ],
1 => ["%d怒气", "%d怒气外加每秒%d" ],
2 => ["%d集中", "%d集中外加每秒%d" ],
3 => ["%d能量", "%d能量外加每秒%d" ],
6 => ["%d符文能量", "%d点符文能量外加每秒%d点"],
),
'powerDisplayCost' => ["%d %s", "%d %s再加上每秒%d"],
'powerCostRunes'=> ["%d鲜血", "%d邪恶", "%d冰霜"],
'powerRunes' => ["鲜血", "邪恶", "冰霜", "死亡"],
'powerTypes' => array(
// conventional
@@ -1499,6 +1515,10 @@ $lang = array(
-1 => "Ammo", -41 => "蓝铁", -61 => "蒸汽动力", -101 => "Heat", -121 => "Ooze", -141 => "Blood Power",
-142 => "Wrath"
),
'scaling' => array(
'directSP' => "+%.2f%% of spell power to direct component", 'directAP' => "+%.2f%% of attack power to direct component",
'dotSP' => "+%.2f%% of spell power per tick", 'dotAP' => "+%.2f%% of attack power per tick"
),
'relItems' => array(
'base' => "<small>Show %s related to <b>%s</b></small>",
'link' => "",