Rebase translation work for easier rebasing

This commit is contained in:
Matthew Miller
2019-10-13 21:47:26 +10:00
parent 77ef0ae417
commit 96e56bdd0c
80 changed files with 1155 additions and 359 deletions

View File

@ -32,9 +32,11 @@ import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.command.BlockCommandSender;
import java.util.Locale;
import java.util.UUID;
import javax.annotation.Nullable;
@ -91,7 +93,12 @@ public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements
@Override
public void print(Component component) {
TextAdapter.sendComponent(sender, WorldEditText.format(component));
TextAdapter.sendComponent(sender, WorldEditText.format(component, getLocale()));
}
@Override
public Locale getLocale() {
return Locale.US;
}
@Override

View File

@ -30,6 +30,7 @@ import org.enginehub.piston.inject.MapBackedValueStore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Locale;
import java.util.Optional;
import static com.google.common.base.Preconditions.checkNotNull;
@ -52,7 +53,7 @@ class BukkitCommandInspector implements CommandInspector {
public String getShortText(Command command) {
Optional<org.enginehub.piston.Command> mapping = dispatcher.getCommand(command.getName());
if (mapping.isPresent()) {
return reduceToText(mapping.get().getDescription());
return reduceToText(mapping.get().getDescription(), Locale.US);
} else {
logger.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'");
return "Help text not available";
@ -63,7 +64,7 @@ class BukkitCommandInspector implements CommandInspector {
public String getFullText(Command command) {
Optional<org.enginehub.piston.Command> mapping = dispatcher.getCommand(command.getName());
if (mapping.isPresent()) {
return reduceToText(mapping.get().getFullHelp());
return reduceToText(mapping.get().getFullHelp(), Locale.US);
} else {
logger.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'");
return "Help text not available";

View File

@ -31,6 +31,7 @@ import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Locale;
import java.util.UUID;
import javax.annotation.Nullable;
@ -94,7 +95,7 @@ public class BukkitCommandSender extends AbstractNonPlayerActor {
@Override
public void print(Component component) {
TextAdapter.sendComponent(sender, WorldEditText.format(component));
TextAdapter.sendComponent(sender, WorldEditText.format(component, getLocale()));
}
@Override
@ -111,6 +112,11 @@ public class BukkitCommandSender extends AbstractNonPlayerActor {
public void checkPermission(String permission) throws AuthorizationException {
}
@Override
public Locale getLocale() {
return Locale.US;
}
@Override
public SessionKey getSessionKey() {
return new SessionKey() {

View File

@ -20,6 +20,7 @@
package com.sk89q.worldedit.bukkit;
import com.sk89q.util.StringUtil;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
@ -33,13 +34,13 @@ import com.sk89q.worldedit.session.SessionKey;
import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.util.formatting.WorldEditText;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.gamemode.GameMode;
import com.sk89q.worldedit.world.gamemode.GameModes;
import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@ -130,7 +131,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
@Override
public void print(Component component) {
TextAdapter.sendComponent(player, WorldEditText.format(component));
TextAdapter.sendComponent(player, WorldEditText.format(component, getLocale()));
}
@Override
@ -216,6 +217,11 @@ public class BukkitPlayer extends AbstractPlayerActor {
return player.teleport(BukkitAdapter.adapt(location));
}
@Override
public Locale getLocale() {
return Locale.forLanguageTag(player.getLocale().replace('_', '-'));
}
@Nullable
@Override
public <T> T getFacet(Class<? extends T> cls) {

View File

@ -43,6 +43,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -168,8 +169,9 @@ public class BukkitServerInterface implements MultiUserPlatform {
Stream.of(command.getName()),
command.getAliases().stream()
).toArray(String[]::new);
return new CommandInfo(reduceToText(command.getUsage()),
reduceToText(command.getDescription()), aliases,
// TODO Handle localisation correctly
return new CommandInfo(reduceToText(command.getUsage(), Locale.US),
reduceToText(command.getDescription(), Locale.US), aliases,
inspector, permissionsArray);
}).collect(Collectors.toList()));
}