Updated language files and command descriptions

This commit is contained in:
Shoghi Cervantes 2015-04-12 00:59:12 +02:00
parent 8d468a1efb
commit e2bae92df8
No known key found for this signature in database
GPG Key ID: 78464DB0A7837F89
42 changed files with 91 additions and 74 deletions

View File

@ -2447,7 +2447,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$message = $message->getText();
}
$mes = explode("\n", $message);
$mes = explode("\n", $this->server->getLanguage()->translateString($message, [], "pocketmine."));
foreach($mes as $m){
if($m !== ""){
$pk = new TextPacket();
@ -2461,7 +2461,10 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
public function sendTranslation($message, array $parameters = []){
$pk = new TextPacket();
$pk->type = TextPacket::TYPE_TRANSLATION;
$pk->message = $message;
$pk->message = $this->server->getLanguage()->translateString($message, [], "pocketmine.");
foreach($parameters as $i => $p){
$parameters[$i] = $this->server->getLanguage()->translateString($p, [], "pocketmine.");
}
$pk->parameters = $parameters;
$this->dataPacket($pk);
}

View File

@ -105,6 +105,8 @@ class ConsoleCommandSender implements CommandSender{
public function sendMessage($message){
if($message instanceof TextContainer){
$message = $this->getServer()->getLanguage()->translate($message);
}else{
$message = $this->getServer()->getLanguage()->translateString($message);
}
foreach(explode("\n", trim($message)) as $line){

View File

@ -22,12 +22,20 @@
namespace pocketmine\command;
use pocketmine\event\TextContainer;
class RemoteConsoleCommandSender extends ConsoleCommandSender{
/** @var string */
private $messages = "";
public function sendMessage($message){
if($message instanceof TextContainer){
$message = $this->getServer()->getLanguage()->translate($message);
}else{
$message = $this->getServer()->getLanguage()->translateString($message);
}
$this->messages .= trim($message, "\r\n") . "\n";
}

View File

@ -32,7 +32,7 @@ class BanCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Prevents the specified player from using this server",
"%pocketmine.command.ban.player.description",
"%commands.ban.usage"
);
$this->setPermission("pocketmine.command.ban.player");

View File

@ -32,7 +32,7 @@ class BanIpCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Prevents the specified IP address from using this server",
"%pocketmine.command.ban.ip.description",
"%commands.banip.usage"
);
$this->setPermission("pocketmine.command.ban.ip");

View File

@ -30,7 +30,7 @@ class BanListCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"View all players banned from this server",
"%pocketmine.command.banlist.description",
"%commands.banlist.usage"
);
$this->setPermission("pocketmine.command.ban.list");

View File

@ -31,7 +31,7 @@ class DefaultGamemodeCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Set the default gamemode",
"%pocketmine.command.defaultgamemode.description",
"%commands.defaultgamemode.usage"
);
$this->setPermission("pocketmine.command.defaultgamemode");

View File

@ -32,7 +32,7 @@ class DeopCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Takes the specified player's operator status",
"%pocketmine.command.deop.description",
"%commands.deop.usage"
);
$this->setPermission("pocketmine.command.op.take");

View File

@ -33,7 +33,7 @@ class DifficultyCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Sets the game difficulty",
"%pocketmine.command.difficulty.description",
"%commands.difficulty.usage"
);
$this->setPermission("pocketmine.command.difficulty");

View File

@ -33,7 +33,7 @@ class EffectCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Adds/Removes effects on players",
"%pocketmine.command.effect.description",
"%commands.effect.usage"
);
$this->setPermission("pocketmine.command.effect");

View File

@ -33,7 +33,7 @@ class GamemodeCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Changes the player to a specific game mode",
"%pocketmine.command.gamemode.description",
"%commands.gamemode.usage"
);
$this->setPermission("pocketmine.command.gamemode");

View File

@ -33,8 +33,8 @@ class GiveCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Gives the specified player a certain amount of items",
"/give <player> <item[:damage]> [amount]" //No translation :(
"%pocketmine.command.give.description",
"%pocketmine.command.give.usage"
);
$this->setPermission("pocketmine.command.give");
}

View File

@ -32,7 +32,7 @@ class HelpCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Shows the help menu",
"%pocketmine.command.help.description",
"%commands.help.usage",
["?"]
);

View File

@ -32,7 +32,7 @@ class KickCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Removes the specified player from the server",
"%pocketmine.command.kick.description",
"%commands.kick.usage"
);
$this->setPermission("pocketmine.command.kick");

View File

@ -33,8 +33,8 @@ class KillCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Commits suicide, only usable as a player",
"/kill [player]",
"%pocketmine.command.kill.description",
"%pocketmine.command.kill.usage",
["suicide"]
);
$this->setPermission("pocketmine.command.kill.self;pocketmine.command.kill.other");

View File

@ -31,7 +31,7 @@ class ListCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Lists all online players",
"%pocketmine.command.list.description",
"%command.players.usage"
);
$this->setPermission("pocketmine.command.list");

View File

@ -31,7 +31,7 @@ class MeCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Performs the specified action in chat",
"%pocketmine.command.me.description",
"%commands.me.usage"
);
$this->setPermission("pocketmine.command.me");

View File

@ -32,7 +32,7 @@ class OpCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Gives the specified player operator status",
"%pocketmine.command.op.description",
"%commands.op.usage"
);
$this->setPermission("pocketmine.command.op.give");

View File

@ -31,7 +31,7 @@ class PardonCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Allows the specified player to use this server",
"%pocketmine.command.unban.player.description",
"%commands.unban.usage"
);
$this->setPermission("pocketmine.command.unban.player");

View File

@ -31,7 +31,7 @@ class PardonIpCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Allows the specified IP address to use this server",
"%pocketmine.command.unban.ip.description",
"%commands.unbanip.usage"
);
$this->setPermission("pocketmine.command.unban.ip");

View File

@ -55,8 +55,8 @@ class ParticleCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Adds particles to a world",
"/particle <name> <x> <y> <z> <xd> <yd> <zd> [count] [data]" //No translation, different!
"%pocketmine.command.particle.description",
"%pocketmine.command.particle.usage"
);
$this->setPermission("pocketmine.command.particle");
}

View File

@ -22,6 +22,7 @@
namespace pocketmine\command\defaults;
use pocketmine\command\CommandSender;
use pocketmine\event\TranslationContainer;
use pocketmine\utils\TextFormat;
class PluginsCommand extends VanillaCommand{
@ -29,8 +30,8 @@ class PluginsCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Gets a list of plugins running on the server",
"/plugins",
"%pocketmine.command.plugins.description",
"%pocketmine.command.plugins.usage",
["pl"]
);
$this->setPermission("pocketmine.command.plugins");
@ -40,13 +41,11 @@ class PluginsCommand extends VanillaCommand{
if(!$this->testPermission($sender)){
return true;
}
$sender->sendMessage("Plugins " . $this->getPluginList($sender));
$this->sendPluginList($sender);
return true;
}
private function getPluginList(CommandSender $sender){
private function sendPluginList(CommandSender $sender){
$list = "";
foreach(($plugins = $sender->getServer()->getPluginManager()->getPlugins()) as $plugin){
if(strlen($list) > 0){
@ -56,6 +55,6 @@ class PluginsCommand extends VanillaCommand{
$list .= $plugin->getDescription()->getFullName();
}
return "(" . count($plugins) . "): $list";
$sender->sendMessage(new TranslationContainer("pocketmine.command.plugins.success", [count($plugins), $list]));
}
}

View File

@ -23,6 +23,7 @@ namespace pocketmine\command\defaults;
use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\event\TranslationContainer;
use pocketmine\utils\TextFormat;
class ReloadCommand extends VanillaCommand{
@ -30,8 +31,8 @@ class ReloadCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Reloads the server configuration and plugins",
"/reload"
"%pocketmine.command.reload.description",
"%pocketmine.command.reload.usage"
);
$this->setPermission("pocketmine.command.reload");
}
@ -41,10 +42,10 @@ class ReloadCommand extends VanillaCommand{
return true;
}
Command::broadcastCommandMessage($sender, TextFormat::YELLOW . "Reloading server...");
Command::broadcastCommandMessage($sender, new TranslationContainer(TextFormat::YELLOW . "%pocketmine.command.reload.reloading"));
$sender->getServer()->reload();
Command::broadcastCommandMessage($sender, TextFormat::YELLOW . "Reload complete.");
Command::broadcastCommandMessage($sender, new TranslationContainer(TextFormat::YELLOW . "%pocketmine.command.reload.reloaded"));
return true;
}

View File

@ -31,7 +31,7 @@ class SaveCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Saves the server to disk",
"%pocketmine.command.save.description",
"%commands.save.usage"
);
$this->setPermission("pocketmine.command.save.perform");

View File

@ -31,7 +31,7 @@ class SaveOffCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Disables server autosaving",
"%pocketmine.command.saveoff.description",
"%commands.save-off.usage"
);
$this->setPermission("pocketmine.command.save.disable");

View File

@ -31,7 +31,7 @@ class SaveOnCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Enables server autosaving",
"%pocketmine.command.saveon.description",
"%commands.save-on.usage"
);
$this->setPermission("pocketmine.command.save.enable");

View File

@ -32,7 +32,7 @@ class SayCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Broadcasts the given message as the sender",
"%pocketmine.command.say.description",
"%commands.say.usage"
);
$this->setPermission("pocketmine.command.say");

View File

@ -31,7 +31,7 @@ class SeedCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Shows the world seed",
"%pocketmine.command.seed.description",
"%commands.seed.usage"
);
$this->setPermission("pocketmine.command.seed");

View File

@ -33,7 +33,7 @@ class SetWorldSpawnCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Sets a worlds's spawn point. If no coordinates are specified, the player's coordinates will be used.",
"%pocketmine.command.setworldspawn.description",
"%commands.setworldspawn.usage"
);
$this->setPermission("pocketmine.command.setworldspawn");

View File

@ -33,7 +33,7 @@ class SpawnpointCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Sets a player's spawn point",
"%pocketmine.command.spawnpoint.description",
"%commands.spawnpoint.usage"
);
$this->setPermission("pocketmine.command.spawnpoint");

View File

@ -29,8 +29,8 @@ class StatusCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Reads back the server's performance.",
"/status"
"%pocketmine.command.status.description",
"%pocketmine.command.status.usage"
);
$this->setPermission("pocketmine.command.status");
}

View File

@ -31,7 +31,7 @@ class StopCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Stops the server, with optional reason",
"%pocketmine.command.stop.description",
"%commands.stop.usage"
);
$this->setPermission("pocketmine.command.stop");

View File

@ -33,7 +33,7 @@ class TeleportCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Teleports the given player (or yourself) to another player or coordinates",
"%pocketmine.command.tp.description",
"%commands.tp.usage"
);
$this->setPermission("pocketmine.command.teleport");

View File

@ -31,7 +31,7 @@ class TellCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Sends a private message to the given player",
"%pocketmine.command.tell.description",
"%commands.message.usage",
["w", "msg"]
);

View File

@ -33,8 +33,8 @@ class TimeCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Changes the time on each world",
"/time <set|add> <value> OR /time <start|stop|query>" //No translation, different!
"%pocketmine.command.time.description",
"%pocketmine.command.time.usage"
);
$this->setPermission("pocketmine.command.time.add;pocketmine.command.time.set;pocketmine.command.time.start;pocketmine.command.time.stop");
}

View File

@ -33,8 +33,8 @@ class TimingsCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Records timings to see performance of the server.",
"/timings <reset|report|on|off|paste>"
"%pocketmine.command.timings.description",
"%pocketmine.command.timings.usage"
);
$this->setPermission("pocketmine.command.timings");
}
@ -55,17 +55,17 @@ class TimingsCommand extends VanillaCommand{
if($mode === "on"){
$sender->getServer()->getPluginManager()->setUseTimings(true);
TimingsHandler::reload();
$sender->sendMessage("Enabled Timings & Reset");
$sender->sendMessage(new TranslationContainer("pocketmine.command.timings.enable"));
return true;
}elseif($mode === "off"){
$sender->getServer()->getPluginManager()->setUseTimings(false);
$sender->sendMessage("Disabled Timings");
$sender->sendMessage(new TranslationContainer("pocketmine.command.timings.disable"));
return true;
}
if(!$sender->getServer()->getPluginManager()->useTimings()){
$sender->sendMessage("Please enable timings by typing /timings on");
$sender->sendMessage(new TranslationContainer("pocketmine.command.timings.timingsDisabled"));
return true;
}
@ -74,7 +74,7 @@ class TimingsCommand extends VanillaCommand{
if($mode === "reset"){
TimingsHandler::reload();
$sender->sendMessage("Timings reset");
$sender->sendMessage(new TranslationContainer("pocketmine.command.timings.reset"));
}elseif($mode === "merged" or $mode === "report" or $paste){
$sampleTime = microtime(true) - self::$timingStart;
@ -118,18 +118,18 @@ class TimingsCommand extends VanillaCommand{
$data = curl_exec($ch);
curl_close($ch);
if(preg_match('#^Location: http://paste\\.ubuntu\\.com/([0-9]{1,})/#m', $data, $matches) == 0){
$sender->sendMessage("An error happened while pasting the report");
$sender->sendMessage(new TranslationContainer("pocketmine.command.timings.pasteError"));
return true;
}
$sender->sendMessage("Timings uploaded to http://paste.ubuntu.com/" . $matches[1] . "/");
$sender->sendMessage("You can read the results at http://timings.aikar.co/?url=" . $matches[1]);
$sender->sendMessage(new TranslationContainer("pocketmine.command.timings.timingsUpload", ["http://paste.ubuntu.com/" . $matches[1] . "/"]));
$sender->sendMessage(new TranslationContainer("pocketmine.command.timings.timingsRead", ["http://timings.aikar.co/?url=" . $matches[1]]));
fclose($fileTimings);
}else{
fclose($fileTimings);
$sender->sendMessage("Timings written to " . $timings);
$sender->sendMessage(new TranslationContainer("pocketmine.command.timings.timingsWrite", [$timings]));
}
}

View File

@ -22,6 +22,7 @@
namespace pocketmine\command\defaults;
use pocketmine\command\CommandSender;
use pocketmine\event\TranslationContainer;
use pocketmine\network\protocol\Info;
use pocketmine\plugin\Plugin;
use pocketmine\utils\TextFormat;
@ -31,8 +32,8 @@ class VersionCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Gets the version of this server including any plugins in use",
"/version [plugin name]",
"%pocketmine.command.version.description",
"%pocketmine.command.version.usage",
["ver", "about"]
);
$this->setPermission("pocketmine.command.version");
@ -44,11 +45,14 @@ class VersionCommand extends VanillaCommand{
}
if(count($args) === 0){
$output = "This server is running " . $sender->getServer()->getName() . " version " . $sender->getServer()->getPocketMineVersion() . "" . $sender->getServer()->getCodename() . "」 (Implementing API version " . $sender->getServer()->getApiVersion() . " for Minecraft: PE " . $sender->getServer()->getVersion() . " protocol version " . Info::CURRENT_PROTOCOL . ")";
if(\pocketmine\GIT_COMMIT !== str_repeat("00", 20)){
$output .= " [git " . \pocketmine\GIT_COMMIT . "]";
}
$sender->sendMessage($output);
$sender->sendMessage(new TranslationContainer("pocketmine.server.info.extended", [
$sender->getServer()->getName(),
$sender->getServer()->getPocketMineVersion(),
$sender->getServer()->getCodename(),
$sender->getServer()->getApiVersion(),
$sender->getServer()->getVersion(),
Info::CURRENT_PROTOCOL
]));
}else{
$pluginName = implode(" ", $args);
$exactPlugin = $sender->getServer()->getPluginManager()->getPlugin($pluginName);
@ -69,7 +73,7 @@ class VersionCommand extends VanillaCommand{
}
if(!$found){
$sender->sendMessage("This server is not running any plugin by that name.\nUse /plugins to get a list of plugins.");
$sender->sendMessage(new TranslationContainer("pocketmine.command.version.noSuchPlugin"));
}
}

View File

@ -31,7 +31,7 @@ class WhitelistCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Manages the list of players allowed to use this server",
"%pocketmine.command.whitelist.description",
"%commands.whitelist.usage"
);
$this->setPermission("pocketmine.command.whitelist.reload;pocketmine.command.whitelist.enable;pocketmine.command.whitelist.disable;pocketmine.command.whitelist.list;pocketmine.command.whitelist.add;pocketmine.command.whitelist.remove");

View File

@ -84,12 +84,12 @@ class BaseLang{
*
* @return string
*/
public function translateString($str, array $params = []){
public function translateString($str, array $params = [], $onlyPrefix = null){
$baseText = $this->get($str);
$baseText = $this->parseTranslation( $baseText !== null ? $baseText : $str);
$baseText = $this->parseTranslation( $baseText !== null ? $baseText : $str, $onlyPrefix);
foreach($params as $i => $p){
$baseText = str_replace("{%$i}", $this->parseTranslation((string) $p), $baseText);
$baseText = str_replace("{%$i}", $this->parseTranslation((string) $p), $baseText, $onlyPrefix);
}
return $baseText;
@ -131,7 +131,7 @@ class BaseLang{
return $id;
}
protected function parseTranslation($text){
protected function parseTranslation($text, $onlyPrefix = null){
$newString = "";
$replaceString = null;
@ -143,7 +143,7 @@ class BaseLang{
if((ord($c) >= 0x30 and ord($c) <= 0x39) or (ord($c) >= 0x41 and ord($c) <= 0x5a) or (ord($c) >= 0x61 and ord($c) <= 0x7a) or $c === "."){
$replaceString .= $c;
}else{
if(($t = $this->internalGet(substr($replaceString, 1)))){
if(($t = $this->internalGet(substr($replaceString, 1))) !== null and ($onlyPrefix === null or strpos($replaceString, $onlyPrefix) === 1)){
$newString .= $t;
}else{
$newString .= $replaceString;

@ -1 +1 @@
Subproject commit 6327ab744e7951f596c6958f093e1afb84ab20cb
Subproject commit 6212b5a9458e66ff9273aa19013e2812c70ec00d

View File

@ -98,7 +98,6 @@ abstract class DefaultPermissions{
self::registerPermission(new Permission(self::ROOT . ".command.kill.other", "Allows the user to kill other players"), $kill);
$kill->recalculatePermissibles();
self::registerPermission(new Permission(self::ROOT . ".command.kill", "Allows the user to commit suicide", Permission::DEFAULT_TRUE), $commands);
self::registerPermission(new Permission(self::ROOT . ".command.me", "Allows the user to perform a chat action", Permission::DEFAULT_TRUE), $commands);
self::registerPermission(new Permission(self::ROOT . ".command.tell", "Allows the user to privately message another player", Permission::DEFAULT_TRUE), $commands);
self::registerPermission(new Permission(self::ROOT . ".command.say", "Allows the user to talk as the console", Permission::DEFAULT_OP), $commands);

View File

@ -5,6 +5,7 @@
settings:
#Three-letter language code for server-side localization
#Check your language code on https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes
language: "eng"
shutdown-message: "Server closed"
#Allow listing plugins via Query