translate online game message

This commit is contained in:
CCTV-1
2020-02-25 21:14:04 +08:00
parent 58df46261e
commit 5a133686ec
7 changed files with 36 additions and 31 deletions

View File

@@ -32,6 +32,7 @@ import forge.toolbox.FTextField;
import forge.toolbox.SmartScroller; import forge.toolbox.SmartScroller;
import forge.view.FDialog; import forge.view.FDialog;
import forge.view.FFrame; import forge.view.FFrame;
import forge.util.Localizer;
public enum FNetOverlay implements IOnlineChatInterface { public enum FNetOverlay implements IOnlineChatInterface {
@@ -73,7 +74,7 @@ public enum FNetOverlay implements IOnlineChatInterface {
private final FTextArea txtLog = new FTextArea(); private final FTextArea txtLog = new FTextArea();
private final FTextField txtInput = new FTextField.Builder().maxLength(255).build(); private final FTextField txtInput = new FTextField.Builder().maxLength(255).build();
private final FLabel cmdSend = new FLabel.ButtonBuilder().text("Send").build(); private final FLabel cmdSend = new FLabel.ButtonBuilder().text(Localizer.getInstance().getMessage("lblSend")).build();
//private boolean minimized = false; //private boolean minimized = false;
private int height = 140; private int height = 140;
@@ -106,7 +107,7 @@ public enum FNetOverlay implements IOnlineChatInterface {
* Semi-transparent overlay panel. Should be used with layered panes. * Semi-transparent overlay panel. Should be used with layered panes.
*/ */
FNetOverlay() { FNetOverlay() {
window.setTitle("Chat"); window.setTitle(Localizer.getInstance().getMessage("lblChat"));
window.setVisible(false); window.setVisible(false);
window.setBackground(FSkin.getColor(FSkin.Colors.CLR_ZEBRA)); window.setBackground(FSkin.getColor(FSkin.Colors.CLR_ZEBRA));
window.setBorder(new FSkin.LineSkinBorder(FSkin.getColor(FSkin.Colors.CLR_BORDERS))); window.setBorder(new FSkin.LineSkinBorder(FSkin.getColor(FSkin.Colors.CLR_BORDERS)));

View File

@@ -12,6 +12,7 @@ import forge.toolbox.FSkin.Colors;
import forge.toolbox.FSkin.SkinColor; import forge.toolbox.FSkin.SkinColor;
import forge.toolbox.FSkin.SkinnedCheckBox; import forge.toolbox.FSkin.SkinnedCheckBox;
import forge.toolbox.FSkin.SkinnedPanel; import forge.toolbox.FSkin.SkinnedPanel;
import forge.util.Localizer;
import javax.swing.*; import javax.swing.*;
@@ -190,7 +191,7 @@ public abstract class ItemFilter<T extends InventoryItem> {
private boolean pressed, hovered; private boolean pressed, hovered;
private RemoveButton() { private RemoveButton() {
setToolTipText("Remove filter"); setToolTipText(Localizer.getInstance().getMessage("lblRemoveFilter"));
addMouseListener(new MouseAdapter() { addMouseListener(new MouseAdapter() {
@Override @Override
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {

View File

@@ -22,6 +22,7 @@ import forge.screens.home.CLobby;
import forge.screens.home.VLobby; import forge.screens.home.VLobby;
import forge.screens.home.sanctioned.ConstructedGameMenu; import forge.screens.home.sanctioned.ConstructedGameMenu;
import forge.util.gui.SOptionPane; import forge.util.gui.SOptionPane;
import forge.util.Localizer;
public enum CSubmenuOnlineLobby implements ICDoc, IMenuProvider { public enum CSubmenuOnlineLobby implements ICDoc, IMenuProvider {
SINGLETON_INSTANCE; SINGLETON_INSTANCE;
@@ -49,7 +50,7 @@ public enum CSubmenuOnlineLobby implements ICDoc, IMenuProvider {
} catch (Exception ex) { } catch (Exception ex) {
// IntelliJ swears that BindException isn't thrown in this try block, but it is! // IntelliJ swears that BindException isn't thrown in this try block, but it is!
if (ex.getClass() == BindException.class) { if (ex.getClass() == BindException.class) {
SOptionPane.showErrorDialog("Unable to start server, port already in use!"); SOptionPane.showErrorDialog(Localizer.getInstance().getMessage("lblUnableStartServerPortAlreadyUse"));
SOverlayUtils.hideOverlay(); SOverlayUtils.hideOverlay();
} else { } else {
BugReporter.reportException(ex); BugReporter.reportException(ex);
@@ -64,7 +65,7 @@ public enum CSubmenuOnlineLobby implements ICDoc, IMenuProvider {
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override
public void run() { public void run() {
SOverlayUtils.startGameOverlay("Starting server..."); SOverlayUtils.startGameOverlay(Localizer.getInstance().getMessage("lblStartingServer"));
SOverlayUtils.showOverlay(); SOverlayUtils.showOverlay();
} }
}); });
@@ -88,7 +89,7 @@ public enum CSubmenuOnlineLobby implements ICDoc, IMenuProvider {
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override
public void run() { public void run() {
SOverlayUtils.startGameOverlay("Connecting to server..."); SOverlayUtils.startGameOverlay(Localizer.getInstance().getMessage("lblConnectingToServer"));
SOverlayUtils.showOverlay(); SOverlayUtils.showOverlay();
} }
}); });

View File

@@ -84,7 +84,7 @@ public enum VSubmenuOnlineLobby implements IVSubmenu<CSubmenuOnlineLobby>, IOnli
container.setLayout(new MigLayout("insets 0, gap 0, wrap 1, ax right")); container.setLayout(new MigLayout("insets 0, gap 0, wrap 1, ax right"));
lobby.getLblTitle().setText("Online Multiplayer: Lobby"); lobby.getLblTitle().setText(Localizer.getInstance().getMessage("lblOnlineLobbyTitle"));
pnlTitle.removeAll(); pnlTitle.removeAll();
pnlTitle.setOpaque(false); pnlTitle.setOpaque(false);
pnlTitle.add(lobby.getLblTitle(), "w 95%, h 40px!, gap 0 0 15px 15px, span 2"); pnlTitle.add(lobby.getLblTitle(), "w 95%, h 40px!, gap 0 0 15px 15px, span 2");

View File

@@ -11,11 +11,12 @@ import forge.properties.ForgePreferences.FPref;
import forge.screens.FScreen; import forge.screens.FScreen;
import forge.toolbox.FEvent; import forge.toolbox.FEvent;
import forge.toolbox.FEvent.FEventHandler; import forge.toolbox.FEvent.FEventHandler;
import forge.util.Localizer;
public class OnlineMenu extends FPopupMenu { public class OnlineMenu extends FPopupMenu {
public enum OnlineScreen { public enum OnlineScreen {
Lobby("Lobby", FSkinImage.FAVICON, OnlineLobbyScreen.class), Lobby("lblLobby", FSkinImage.FAVICON, OnlineLobbyScreen.class),
Chat("Chat", FSkinImage.QUEST_NOTES, OnlineChatScreen.class); Chat("lblChat", FSkinImage.QUEST_NOTES, OnlineChatScreen.class);
private final FMenuItem item; private final FMenuItem item;
private final Class<? extends FScreen> screenClass; private final Class<? extends FScreen> screenClass;
@@ -23,7 +24,7 @@ public class OnlineMenu extends FPopupMenu {
OnlineScreen(final String caption0, final FImage icon0, final Class<? extends FScreen> screenClass0) { OnlineScreen(final String caption0, final FImage icon0, final Class<? extends FScreen> screenClass0) {
screenClass = screenClass0; screenClass = screenClass0;
item = new FMenuItem(caption0, icon0, new FEventHandler() { item = new FMenuItem(Localizer.getInstance().getMessage(caption0), icon0, new FEventHandler() {
@Override @Override
public void handleEvent(FEvent e) { public void handleEvent(FEvent e) {
Forge.back(); //remove current screen from chain Forge.back(); //remove current screen from chain
@@ -37,7 +38,7 @@ public class OnlineMenu extends FPopupMenu {
if (screen == null) { //don't initialize screen until it's opened the first time if (screen == null) { //don't initialize screen until it's opened the first time
try { try {
screen = screenClass.newInstance(); screen = screenClass.newInstance();
screen.setHeaderCaption("Play Online - " + item.getText()); screen.setHeaderCaption(Localizer.getInstance().getMessage("lblPlayOnline") + " - " + item.getText());
} }
catch (Exception e) { catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

View File

@@ -37,6 +37,7 @@ import forge.model.FModel;
import forge.net.event.UpdateLobbyPlayerEvent; import forge.net.event.UpdateLobbyPlayerEvent;
import forge.player.GamePlayerUtil; import forge.player.GamePlayerUtil;
import forge.properties.ForgePreferences.FPref; import forge.properties.ForgePreferences.FPref;
import forge.util.Localizer;
import forge.util.NameGenerator; import forge.util.NameGenerator;
import forge.util.gui.SOptionPane; import forge.util.gui.SOptionPane;
@@ -353,27 +354,27 @@ public abstract class GameLobby implements IHasGameType {
} }
if (activeSlots.size() < 2) { if (activeSlots.size() < 2) {
SOptionPane.showMessageDialog("At least two players are required to start a game."); SOptionPane.showMessageDialog(Localizer.getInstance().getMessage("lblRequiredLeastTwoPlayerStartGame"));
return null; return null;
} }
if (!isEnoughTeams()) { if (!isEnoughTeams()) {
SOptionPane.showMessageDialog("There are not enough teams! Please adjust team allocations."); SOptionPane.showMessageDialog(Localizer.getInstance().getMessage("lblNotEnoughTeams"));
return null; return null;
} }
for (final LobbySlot slot : activeSlots) { for (final LobbySlot slot : activeSlots) {
if (!slot.isReady() && slot.getType() != LobbySlotType.OPEN) { if (!slot.isReady() && slot.getType() != LobbySlotType.OPEN) {
SOptionPane.showMessageDialog(TextUtil.concatNoSpace("Player ", slot.getName(), " is not ready")); SOptionPane.showMessageDialog(Localizer.getInstance().getMessage("lblPlayerIsNotReady", slot.getName()));
return null; return null;
} }
if (slot.getDeck() == null) { if (slot.getDeck() == null) {
SOptionPane.showMessageDialog(TextUtil.concatNoSpace("Please specify a deck for ", slot.getName())); SOptionPane.showMessageDialog(Localizer.getInstance().getMessage("lblPleaseSpecifyPlayerDeck", slot.getName()));
return null; return null;
} }
if (hasVariant(GameType.Commander) || hasVariant(GameType.Oathbreaker) || hasVariant(GameType.TinyLeaders) || hasVariant(GameType.Brawl)) { if (hasVariant(GameType.Commander) || hasVariant(GameType.Oathbreaker) || hasVariant(GameType.TinyLeaders) || hasVariant(GameType.Brawl)) {
if (!slot.getDeck().has(DeckSection.Commander)) { if (!slot.getDeck().has(DeckSection.Commander)) {
SOptionPane.showMessageDialog(TextUtil.concatNoSpace(slot.getName(), " doesn't have a commander")); SOptionPane.showMessageDialog(Localizer.getInstance().getMessage("lblPlayerDoesntHaveCommander", slot.getName()));
return null; return null;
} }
} }
@@ -410,7 +411,7 @@ public abstract class GameLobby implements IHasGameType {
final String name = slot.getName(); final String name = slot.getName();
final String errMsg = GameType.Constructed.getDeckFormat().getDeckConformanceProblem(slot.getDeck()); final String errMsg = GameType.Constructed.getDeckFormat().getDeckConformanceProblem(slot.getDeck());
if (null != errMsg) { if (null != errMsg) {
SOptionPane.showErrorDialog(name + "'s deck " + errMsg, "Invalid Deck"); SOptionPane.showErrorDialog(Localizer.getInstance().getMessage("lblPlayerDeckError", name, errMsg), Localizer.getInstance().getMessage("lblInvalidDeck"));
return null; return null;
} }
} }
@@ -460,7 +461,7 @@ public abstract class GameLobby implements IHasGameType {
if (checkLegality) { if (checkLegality) {
final String errMsg = commanderGameType.getDeckFormat().getDeckConformanceProblem(deck); final String errMsg = commanderGameType.getDeckFormat().getDeckConformanceProblem(deck);
if (errMsg != null) { if (errMsg != null) {
SOptionPane.showErrorDialog(name + "'s deck " + errMsg, "Invalid " + commanderGameType + " Deck"); SOptionPane.showErrorDialog(Localizer.getInstance().getMessage("lblPlayerDeckError", name, errMsg), Localizer.getInstance().getMessage("lblInvalidCommanderGameTypeDeck", commanderGameType));
return null; return null;
} }
} }
@@ -491,7 +492,7 @@ public abstract class GameLobby implements IHasGameType {
if (checkLegality) { if (checkLegality) {
final String errMsg = DeckFormat.getSchemeSectionConformanceProblem(schemePool); final String errMsg = DeckFormat.getSchemeSectionConformanceProblem(schemePool);
if (null != errMsg) { if (null != errMsg) {
SOptionPane.showErrorDialog(name + "'s deck " + errMsg, "Invalid Scheme Deck"); SOptionPane.showErrorDialog(Localizer.getInstance().getMessage("lblPlayerDeckError", name, errMsg), Localizer.getInstance().getMessage("lblInvalidSchemeDeck"));
return null; return null;
} }
} }
@@ -504,7 +505,7 @@ public abstract class GameLobby implements IHasGameType {
if (checkLegality) { if (checkLegality) {
final String errMsg = DeckFormat.getPlaneSectionConformanceProblem(planePool); final String errMsg = DeckFormat.getPlaneSectionConformanceProblem(planePool);
if (null != errMsg) { if (null != errMsg) {
SOptionPane.showErrorDialog(name + "'s deck " + errMsg, "Invalid Planar Deck"); SOptionPane.showErrorDialog(Localizer.getInstance().getMessage("lblPlayerDeckError", name, errMsg), Localizer.getInstance().getMessage("lblInvalidPlanarDeck"));
return null; return null;
} }
} }
@@ -514,8 +515,7 @@ public abstract class GameLobby implements IHasGameType {
//Vanguard //Vanguard
if (variantTypes.contains(GameType.Vanguard)) { if (variantTypes.contains(GameType.Vanguard)) {
if (avatarPool == null || avatarPool.countAll() == 0) { //ERROR! null if avatar deselected on list if (avatarPool == null || avatarPool.countAll() == 0) { //ERROR! null if avatar deselected on list
SOptionPane.showMessageDialog("No Vanguard avatar selected for " + name SOptionPane.showMessageDialog(Localizer.getInstance().getMessage("lblNoSelectedVanguardAvatarForPlayer", name));
+ ". Please choose one or disable the Vanguard variant");
return null; return null;
} }
} }

View File

@@ -24,12 +24,13 @@ import forge.player.GamePlayerUtil;
import forge.properties.ForgeProfileProperties; import forge.properties.ForgeProfileProperties;
import forge.properties.ForgePreferences.FPref; import forge.properties.ForgePreferences.FPref;
import forge.util.gui.SOptionPane; import forge.util.gui.SOptionPane;
import forge.util.Localizer;
public class NetConnectUtil { public class NetConnectUtil {
private NetConnectUtil() { } private NetConnectUtil() { }
public static String getServerUrl() { public static String getServerUrl() {
final String url = SOptionPane.showInputDialog("This feature is under active development.\nYou are likely to find bugs.\n\n - = * H E R E B E E L D R A Z I * = -\n\nEnter the URL of the server to join.\nLeave blank to host your own server.", "Connect to Server"); final String url = SOptionPane.showInputDialog(Localizer.getInstance().getMessage("lblOnlineMultiplayerDest"), Localizer.getInstance().getMessage("lblConnectToServer"));
if (url == null) { return null; } if (url == null) { return null; }
//prompt user for player one name if needed //prompt user for player one name if needed
@@ -101,7 +102,7 @@ public class NetConnectUtil {
view.update(true); view.update(true);
return new ChatMessage(null, String.format("Hosting on port %d.", port)); return new ChatMessage(null, Localizer.getInstance().getMessage("lblHostingPortOnN", String.valueOf(port)));
} }
public static void copyHostedServerUrl() { public static void copyHostedServerUrl() {
@@ -116,13 +117,13 @@ public class NetConnectUtil {
GuiBase.getInterface().copyToClipboard(internalAddress); GuiBase.getInterface().copyToClipboard(internalAddress);
} }
String message = "Share the following URL with anyone who wishes to join your server. It has been copied to your clipboard for convenience.\n\n"; String message = "";
if (externalUrl != null) { if (externalUrl != null) {
message += externalUrl + "\n\nFor internal games, use the following URL: " + internalUrl; message = Localizer.getInstance().getMessage("lblShareURLToMakePlayerJoinServer", externalUrl, internalUrl);
} else { } else {
message = "Forge was unable to determine your external IP!\n\n" + message + internalUrl; message = Localizer.getInstance().getMessage("lblForgeUnableDetermineYourExternalIP", message + internalUrl);
} }
SOptionPane.showMessageDialog(message, "Server URL", SOptionPane.INFORMATION_ICON); SOptionPane.showMessageDialog(message, Localizer.getInstance().getMessage("lblServerURL"), SOptionPane.INFORMATION_ICON);
} }
public static ChatMessage join(final String url, final IOnlineLobby onlineLobby, final IOnlineChatInterface chatInterface) { public static ChatMessage join(final String url, final IOnlineLobby onlineLobby, final IOnlineChatInterface chatInterface) {
@@ -145,7 +146,7 @@ public class NetConnectUtil {
} }
@Override @Override
public final void close() { public final void close() {
SOptionPane.showMessageDialog("Your connection to the host (" + url + ") was interrupted.", "Error", FSkinProp.ICO_WARNING); SOptionPane.showMessageDialog(Localizer.getInstance().getMessage("lblYourConnectionToHostWasInterrupted", url), Localizer.getInstance().getMessage("lblError"), FSkinProp.ICO_WARNING);
onlineLobby.setClient(null); onlineLobby.setClient(null);
} }
@Override @Override
@@ -181,6 +182,6 @@ public class NetConnectUtil {
return null; return null;
} }
return new ChatMessage(null, String.format("Connected to %s:%d", hostname, port)); return new ChatMessage(null, Localizer.getInstance().getMessage("lblConnectedIPPort", hostname, String.valueOf(port)));
} }
} }