Merge remote-tracking branch 'upstream/feature/translatable-text' into i18n-merge

This commit is contained in:
Jesse Boyd
2019-11-21 13:50:05 +00:00
102 changed files with 1606 additions and 584 deletions

View File

@ -25,6 +25,7 @@ import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.extension.platform.AbstractPlayerActor;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.fabric.mixin.AccessorServerPlayerEntity;
import com.sk89q.worldedit.fabric.net.handler.WECUIPacketHandler;
import com.sk89q.worldedit.internal.cui.CUIEvent;
import com.sk89q.worldedit.math.BlockVector3;
@ -56,6 +57,7 @@ import net.minecraft.util.math.BlockPos;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.Locale;
import java.util.UUID;
public class FabricPlayer extends AbstractPlayerActor {
@ -128,6 +130,11 @@ public class FabricPlayer extends AbstractPlayerActor {
this.player.networkHandler.sendPacket(packet);
}
@Override
public Locale getLocale() {
return Locale.forLanguageTag(((AccessorServerPlayerEntity) this.player).getClientLanguage().replace("_", "-"));
}
@Override
public void printRaw(String msg) {
for (String part : msg.split("\n")) {
@ -152,7 +159,7 @@ public class FabricPlayer extends AbstractPlayerActor {
@Override
public void print(Component component) {
this.player.sendMessage(Text.Serializer.fromJson(GsonComponentSerializer.INSTANCE.serialize(WorldEditText.format(component))));
this.player.sendMessage(Text.Serializer.fromJson(GsonComponentSerializer.INSTANCE.serialize(WorldEditText.format(component, getLocale()))));
}
private void sendColorized(String msg, Formatting formatting) {

View File

@ -0,0 +1,31 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.fabric.mixin;
import net.minecraft.server.network.ServerPlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(ServerPlayerEntity.class)
public interface AccessorServerPlayerEntity {
@Accessor
String getClientLanguage();
}

View File

@ -4,7 +4,8 @@
"compatibilityLevel": "JAVA_8",
"mixins": [
"MixinServerPlayerEntity",
"MixinMinecraftServer"
"MixinMinecraftServer",
"AccessorServerPlayerEntity"
],
"server": [
],