Do not rely on random translation keys prefixed with % getting translated

This commit is contained in:
Dylan K. Taylor 2021-08-15 19:05:05 +01:00
parent 715fbc9ee5
commit 752d1179a1
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
3 changed files with 7 additions and 6 deletions

View File

@ -246,7 +246,7 @@ class SimpleCommandMap implements CommandMap{
try{
$target->execute($sender, $sentCommandLabel, $args);
}catch(InvalidCommandSyntaxException $e){
$sender->sendMessage($sender->getLanguage()->translate(KnownTranslationFactory::commands_generic_usage($target->getUsage())));
$sender->sendMessage($sender->getLanguage()->translate(KnownTranslationFactory::commands_generic_usage($sender->getLanguage()->translateString($target->getUsage()))));
}finally{
$target->timings->stopTiming();
}

View File

@ -89,9 +89,10 @@ class HelpCommand extends VanillaCommand{
$pageNumber = 1;
}
$sender->sendMessage(KnownTranslationFactory::commands_help_header((string) $pageNumber, (string) count($commands)));
$lang = $sender->getLanguage();
if(isset($commands[$pageNumber - 1])){
foreach($commands[$pageNumber - 1] as $command){
$sender->sendMessage(TextFormat::DARK_GREEN . "/" . $command->getName() . ": " . TextFormat::WHITE . $command->getDescription());
$sender->sendMessage(TextFormat::DARK_GREEN . "/" . $command->getName() . ": " . TextFormat::WHITE . $lang->translateString($command->getDescription()));
}
}
@ -100,8 +101,8 @@ class HelpCommand extends VanillaCommand{
if(($cmd = $sender->getServer()->getCommandMap()->getCommand(strtolower($commandName))) instanceof Command){
if($cmd->testPermissionSilent($sender)){
$message = TextFormat::YELLOW . "--------- " . TextFormat::WHITE . " Help: /" . $cmd->getName() . TextFormat::YELLOW . " ---------\n";
$message .= TextFormat::GOLD . "Description: " . TextFormat::WHITE . $cmd->getDescription() . "\n";
$message .= TextFormat::GOLD . "Usage: " . TextFormat::WHITE . implode("\n" . TextFormat::WHITE, explode("\n", $cmd->getUsage())) . "\n";
$message .= TextFormat::GOLD . "Description: " . TextFormat::WHITE . $sender->getLanguage()->translateString($cmd->getDescription()) . "\n";
$message .= TextFormat::GOLD . "Usage: " . TextFormat::WHITE . implode("\n" . TextFormat::WHITE, explode("\n", $sender->getLanguage()->translateString($cmd->getUsage()))) . "\n";
$sender->sendMessage($message);
return true;

View File

@ -96,11 +96,11 @@ class WhitelistCommand extends VanillaCommand{
return true;
case "add":
$sender->sendMessage(KnownTranslationFactory::commands_generic_usage("%" . KnownTranslationKeys::COMMANDS_WHITELIST_ADD_USAGE));
$sender->sendMessage(KnownTranslationFactory::commands_generic_usage(KnownTranslationFactory::commands_whitelist_add_usage()));
return true;
case "remove":
$sender->sendMessage(KnownTranslationFactory::commands_generic_usage("%" . KnownTranslationKeys::COMMANDS_WHITELIST_REMOVE_USAGE));
$sender->sendMessage(KnownTranslationFactory::commands_generic_usage(KnownTranslationFactory::commands_whitelist_remove_usage()));
return true;
}
}elseif(count($args) === 2){