Added KnownTranslationFactory and use it in as many places as possible

this makes translation usage much more statically analysable.
The only places this isn't used are:
- places that prefix translations with colours (those are still a problem)
- places where server/client translations don't match (e.g. gameMode.changed accepts different parameters in vanilla than in PM)
This commit is contained in:
Dylan K. Taylor
2021-08-10 14:50:40 +01:00
parent d39080c45a
commit 2293bd948d
52 changed files with 2185 additions and 372 deletions

View File

@ -26,8 +26,8 @@ namespace pocketmine\command\defaults;
use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\command\utils\InvalidCommandSyntaxException;
use pocketmine\lang\KnownTranslationFactory;
use pocketmine\lang\KnownTranslationKeys;
use pocketmine\lang\TranslationContainer;
use pocketmine\permission\DefaultPermissionNames;
use pocketmine\player\Player;
use pocketmine\world\World;
@ -86,7 +86,7 @@ class TimeCommand extends VanillaCommand{
}else{
$world = $sender->getServer()->getWorldManager()->getDefaultWorld();
}
$sender->sendMessage($sender->getLanguage()->translateString(KnownTranslationKeys::COMMANDS_TIME_QUERY, [$world->getTime()]));
$sender->sendMessage($sender->getLanguage()->translate(KnownTranslationFactory::commands_time_query((string) $world->getTime())));
return true;
}
@ -126,7 +126,7 @@ class TimeCommand extends VanillaCommand{
foreach($sender->getServer()->getWorldManager()->getWorlds() as $world){
$world->setTime($value);
}
Command::broadcastCommandMessage($sender, new TranslationContainer(KnownTranslationKeys::COMMANDS_TIME_SET, [$value]));
Command::broadcastCommandMessage($sender, KnownTranslationFactory::commands_time_set((string) $value));
}elseif($args[0] === "add"){
if(!$this->testPermission($sender, DefaultPermissionNames::COMMAND_TIME_ADD)){
return true;
@ -136,7 +136,7 @@ class TimeCommand extends VanillaCommand{
foreach($sender->getServer()->getWorldManager()->getWorlds() as $world){
$world->setTime($world->getTime() + $value);
}
Command::broadcastCommandMessage($sender, new TranslationContainer(KnownTranslationKeys::COMMANDS_TIME_ADDED, [$value]));
Command::broadcastCommandMessage($sender, KnownTranslationFactory::commands_time_added((string) $value));
}else{
throw new InvalidCommandSyntaxException();
}