Added a tonne more translations

This commit is contained in:
Matthew Miller
2019-11-01 22:33:31 +10:00
parent 4ba54c4337
commit fc0fee39cb
11 changed files with 81 additions and 42 deletions

View File

@@ -49,6 +49,8 @@ import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.concurrency.EvenMoreExecutors;
import com.sk89q.worldedit.util.eventbus.EventBus;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.util.io.file.FileSelectionAbortedException;
import com.sk89q.worldedit.util.io.file.FilenameException;
import com.sk89q.worldedit.util.io.file.FilenameResolutionException;
@@ -634,7 +636,7 @@ public final class WorldEdit {
* @param player the player
* @param f the script file to execute
* @param args arguments for the script
* @throws WorldEditException
* @throws WorldEditException if something goes wrong
*/
public void runScript(Player player, File f, String[] args) throws WorldEditException {
String filename = f.getPath();
@@ -642,7 +644,7 @@ public final class WorldEdit {
String ext = filename.substring(index + 1);
if (!ext.equalsIgnoreCase("js")) {
player.printError("Only .js scripts are currently supported");
player.printError(TranslatableComponent.of("worldedit.script.unsupported"));
return;
}
@@ -655,7 +657,7 @@ public final class WorldEdit {
file = WorldEdit.class.getResourceAsStream("craftscripts/" + filename);
if (file == null) {
player.printError("Script does not exist: " + filename);
player.printError(TranslatableComponent.of("worldedit.script.file-not-found", TextComponent.of(filename)));
return;
}
} else {
@@ -668,7 +670,7 @@ public final class WorldEdit {
in.close();
script = new String(data, 0, data.length, StandardCharsets.UTF_8);
} catch (IOException e) {
player.printError("Script read error: " + e.getMessage());
player.printError(TranslatableComponent.of("worldedit.script.read-error", TextComponent.of(e.getMessage())));
return;
}
@@ -681,8 +683,7 @@ public final class WorldEdit {
try {
engine = new RhinoCraftScriptEngine();
} catch (NoClassDefFoundError ignored) {
player.printError("Failed to find an installed script engine.");
player.printError("Please see https://worldedit.enginehub.org/en/latest/usage/other/craftscripts/");
player.printError(TranslatableComponent.of("worldedit.script.no-script-engine"));
return;
}
@@ -696,14 +697,13 @@ public final class WorldEdit {
try {
engine.evaluate(script, filename, vars);
} catch (ScriptException e) {
player.printError("Failed to execute:");
player.print(TextComponent.of(e.getMessage()));
player.printError(TranslatableComponent.of("worldedit.script.failed", TextComponent.of(e.getMessage(), TextColor.WHITE)));
logger.warn("Failed to execute script", e);
} catch (NumberFormatException | WorldEditException e) {
throw e;
} catch (Throwable e) {
player.printError("Failed to execute (see console):");
player.print(TextComponent.of(e.getClass().getCanonicalName()));
player.printError(TranslatableComponent.of("worldedit.script.failed-console", TextComponent.of(e.getClass().getCanonicalName(),
TextColor.WHITE)));
logger.warn("Failed to execute script", e);
} finally {
for (EditSession editSession : scriptContext.getEditSessions()) {