mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
Merge remote-tracking branch 'upstream/feature/translatable-text' into i18n-merge
This commit is contained in:
@ -54,17 +54,17 @@ public abstract class CommandAdapter implements CommandCallable {
|
||||
@Override
|
||||
public Optional<Text> getShortDescription(CommandSource source) {
|
||||
return Optional.of(command.getDescription())
|
||||
.map(SpongeTextAdapter::convert);
|
||||
.map(desc -> SpongeTextAdapter.convert(desc, source.getLocale()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Text> getHelp(CommandSource source) {
|
||||
return Optional.of(command.getFullHelp())
|
||||
.map(SpongeTextAdapter::convert);
|
||||
.map(help -> SpongeTextAdapter.convert(help, source.getLocale()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Text getUsage(CommandSource source) {
|
||||
return convert(command.getUsage());
|
||||
return convert(command.getUsage(), source.getLocale());
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ package com.sk89q.worldedit.sponge;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
import com.sk89q.worldedit.session.SessionKey;
|
||||
@ -37,6 +38,7 @@ import org.spongepowered.api.text.format.TextColors;
|
||||
import org.spongepowered.api.text.serializer.TextSerializers;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -94,7 +96,7 @@ public class SpongeCommandSender implements Actor {
|
||||
|
||||
@Override
|
||||
public void print(Component component) {
|
||||
TextAdapter.sendComponent(sender, WorldEditText.format(component));
|
||||
TextAdapter.sendComponent(sender, WorldEditText.format(component, getLocale()));
|
||||
}
|
||||
|
||||
private void sendColorized(String msg, TextColor formatting) {
|
||||
@ -141,6 +143,11 @@ public class SpongeCommandSender implements Actor {
|
||||
public void dispatchCUIEvent(CUIEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return WorldEdit.getInstance().getConfiguration().defaultLocale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionKey getSessionKey() {
|
||||
return new SessionKey() {
|
||||
|
@ -51,6 +51,7 @@ import org.spongepowered.api.text.serializer.TextSerializers;
|
||||
import org.spongepowered.api.world.World;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -154,7 +155,7 @@ public class SpongePlayer extends AbstractPlayerActor {
|
||||
|
||||
@Override
|
||||
public void print(Component component) {
|
||||
TextAdapter.sendComponent(player, WorldEditText.format(component));
|
||||
TextAdapter.sendComponent(player, WorldEditText.format(component, getLocale()));
|
||||
}
|
||||
|
||||
private void sendColorized(String msg, TextColor formatting) {
|
||||
@ -231,6 +232,11 @@ public class SpongePlayer extends AbstractPlayerActor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return player.getLocale();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionKey getSessionKey() {
|
||||
return new SessionKeyImpl(player.getUniqueId(), player.getName());
|
||||
|
@ -25,10 +25,12 @@ import com.sk89q.worldedit.util.formatting.text.serializer.gson.GsonComponentSer
|
||||
import org.spongepowered.api.text.Text;
|
||||
import org.spongepowered.api.text.serializer.TextSerializers;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class SpongeTextAdapter {
|
||||
|
||||
public static Text convert(Component component) {
|
||||
component = WorldEditText.format(component);
|
||||
public static Text convert(Component component, Locale locale) {
|
||||
component = WorldEditText.format(component, locale);
|
||||
return TextSerializers.JSON.deserialize(GsonComponentSerializer.INSTANCE.serialize(component));
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@ import org.slf4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
|
||||
public class ConfigurateConfiguration extends LocalConfiguration {
|
||||
|
||||
@ -130,5 +131,11 @@ public class ConfigurateConfiguration extends LocalConfiguration {
|
||||
shellSaveType = type.equals("") ? null : type;
|
||||
|
||||
extendedYLimit = node.getNode("compat", "extended-y-limit").getBoolean(false);
|
||||
defaultLocaleName = node.getNode("default-locale").getString(defaultLocaleName);
|
||||
if (defaultLocaleName.equals("default")) {
|
||||
defaultLocale = Locale.getDefault();
|
||||
} else {
|
||||
defaultLocale = Locale.forLanguageTag(defaultLocaleName.replace('_', '-'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user