Moving hard-coded text to en-US.properties file

This commit is contained in:
churrufli
2019-06-08 07:55:27 +02:00
parent f44c6ac1a5
commit 1059666444
4 changed files with 185 additions and 75 deletions

View File

@@ -44,6 +44,7 @@ import forge.quest.bazaar.QuestPetController;
import forge.quest.data.DeckConstructionRules;
import forge.quest.data.QuestAchievements;
import forge.quest.data.QuestAssets;
import forge.util.Localizer;
import forge.util.gui.SGuiChoose;
import forge.util.gui.SOptionPane;
@@ -182,7 +183,8 @@ public class QuestUtil {
}
public static void travelWorld() {
if (!checkActiveQuest("Travel between worlds.")) {
final Localizer localizer = Localizer.getInstance();
if (!checkActiveQuest(localizer.getMessage("lblTravelBetweenWorlds"))) {
return;
}
final List<QuestWorld> worlds = new ArrayList<>();
@@ -199,7 +201,7 @@ public class QuestUtil {
return;
}
final String setPrompt = "Where do you wish to travel?";
final String setPrompt = localizer.getMessage("lblWhereDoYouWishToTravel");
final QuestWorld newWorld = SGuiChoose.oneOrNone(setPrompt, worlds);
if (worlds.indexOf(newWorld) < 0) {
@@ -212,10 +214,8 @@ public class QuestUtil {
needRemove = true;
if (!SOptionPane.showConfirmDialog(
"You have uncompleted challenges in your current world. If you travel now, they will be LOST!"
+ "\nAre you sure you wish to travel anyway?\n"
+ "(Click \"No\" to go back and complete your current challenges first.)",
"WARNING: Uncompleted challenges")) {
localizer.getMessage("lblUncompleteChallengesDesc"),
localizer.getMessage("lblUncompleteChallengesWarning"))) {
return;
}
}
@@ -285,6 +285,7 @@ public class QuestUtil {
}
private static void updatePlantAndPetForView(final IVQuestStats view, final QuestController qCtrl) {
final Localizer localizer = Localizer.getInstance();
for (int iSlot = 0; iSlot < QuestController.MAX_PET_SLOTS; iSlot++) {
final List<QuestPetController> petList = qCtrl.getPetsStorage().getAvaliablePets(iSlot, qCtrl.getAssets());
final String currentPetName = qCtrl.getSelectedPet(iSlot);
@@ -304,10 +305,10 @@ public class QuestUtil {
// Pet list visibility
if (!petList.isEmpty()) {
view.getCbxPet().setVisible(true);
view.getCbxPet().addItem("Don't summon a pet");
view.getCbxPet().addItem(localizer.getMessage("lblDontSummonAPet"));
for (final QuestPetController pet : petList) {
final String name = "Summon " + pet.getName();
final String name = localizer.getMessage("lblSummon").replace("%n","\"" + pet.getName() + "\"");
view.getCbxPet().addItem(name);
if (pet.getName().equals(currentPetName)) {
view.getCbxPet().setSelectedItem(name);
@@ -322,14 +323,14 @@ public class QuestUtil {
view.getCbxMatchLength().removeAllItems();
boolean activeCharms = false;
StringBuilder matchLength = new StringBuilder();
matchLength.append("Match - Best of ").append(qCtrl.getMatchLength());
matchLength.append(localizer.getMessage("lblMatchBestof") + " ").append(qCtrl.getMatchLength());
if (qCtrl.getAssets().hasItem(QuestItemType.CHARM_VIM)) {
view.getCbxMatchLength().addItem("Match - Best of 1");
view.getCbxMatchLength().addItem(localizer.getMessage("lblMatchBestOf1"));
activeCharms = true;
}
view.getCbxMatchLength().addItem("Match - Best of 3");
view.getCbxMatchLength().addItem(localizer.getMessage("lblMatchBestOf3"));
if (qCtrl.getAssets().hasItem(QuestItemType.CHARM)) {
view.getCbxMatchLength().addItem("Match - Best of 5");
view.getCbxMatchLength().addItem(localizer.getMessage("lblMatchBestOf5"));
activeCharms = true;
}
view.getCbxMatchLength().setSelectedItem(matchLength.toString());
@@ -373,12 +374,14 @@ public class QuestUtil {
view0.getBtnBazaar().setVisible(true);
view0.getLblLife().setVisible(true);
final Localizer localizer = Localizer.getInstance();
// Stats panel
view0.getLblCredits().setText("Credits: " + QuestUtil.formatCredits(qS.getCredits()));
view0.getLblLife().setText("Life: " + qS.getLife(qCtrl.getMode()));
view0.getLblWins().setText("Wins: " + qA.getWin());
view0.getLblLosses().setText("Losses: " + qA.getLost());
view0.getLblWorld().setText("World: " + (qCtrl.getWorld() == null ? "(none)" : qCtrl.getWorld()));
view0.getLblCredits().setText(localizer.getMessage("lblCredits") + ": " + QuestUtil.formatCredits(qS.getCredits()));
view0.getLblLife().setText(localizer.getMessage("lblLife") + ": " + qS.getLife(qCtrl.getMode()));
view0.getLblWins().setText(localizer.getMessage("lblWins") + ": " + qA.getWin());
view0.getLblLosses().setText(localizer.getMessage("lblLosses") + ": " + qA.getLost());
view0.getLblWorld().setText(localizer.getMessage("lblWorld") +": "+ (qCtrl.getWorld() == null ? " (" + localizer.getMessage("lblNone") + ")" : qCtrl.getWorld()));
// Show or hide the set unlocking button
@@ -388,38 +391,37 @@ public class QuestUtil {
final int num = nextChallengeInWins();
final String str;
if (num == 0) {
str = "Your exploits have been noticed. An opponent has challenged you.";
str = localizer.getMessage("lblnextChallengeInWins0");
}
else if (num == 1) {
str = "A new challenge will be available after 1 more win.";
str = localizer.getMessage("lblnextChallengeInWins1");
}
else {
str = "A new challenge will be available in " + num + " wins.";
str =localizer.getMessage("lblnextChallengeInWins2").replace("%n","\"" + num + "\"");
}
view0.getLblNextChallengeInWins().setText(str);
if (view0.allowHtml()) {
view0.getLblWinStreak().setText(
"<html>Win streak: " + qA.getWinStreakCurrent()
+ "<br>&nbsp; (Best: " + qA.getWinStreakBest() + ")</html>");
"<html>" + localizer.getMessage("lblWinStreak") + ": " + qA.getWinStreakCurrent()
+ "<br>&nbsp; (" + localizer.getMessage("lblBest") + ": " + qA.getWinStreakBest() + ")</html>");
}
else {
view0.getLblWinStreak().setText(
"Win streak: " + qA.getWinStreakCurrent()
+ " (Best: " + qA.getWinStreakBest() + ")");
localizer.getMessage("lblWinStreak") +": " + qA.getWinStreakCurrent()
+ " (" + localizer.getMessage("lblBest") + ": " + qA.getWinStreakBest() + ")");
}
// Current deck message
final IButton lblCurrentDeck = view0.getLblCurrentDeck();
if (getCurrentDeck() == null) {
lblCurrentDeck.setTextColor(204, 0, 0);
lblCurrentDeck.setText("Build, then select a deck in the \"Quest Decks\" submenu.");
lblCurrentDeck.setText(localizer.getMessage("lblBuildAndSelectaDeck"));
}
else {
lblCurrentDeck.setImage(FSkinProp.CLR_TEXT);
lblCurrentDeck.setText("Your current deck is \""
+ getCurrentDeck().getName() + "\".");
lblCurrentDeck.setText(localizer.getMessage("lblCurrentDeck").replace("%n","\"" + getCurrentDeck().getName() + "\"."));
}
// Start panel: pet, plant, zep.
@@ -466,10 +468,12 @@ public class QuestUtil {
}
public static boolean checkActiveQuest(final String location) {
final Localizer localizer = Localizer.getInstance();
final QuestController qc = FModel.getQuest();
if (qc == null || qc.getAssets() == null) {
final String msg = "Please create a Quest before attempting to " + location;
SOptionPane.showErrorDialog(msg, "No Quest");
final String msg = localizer.getMessage("PleaseCreateAQuestBefore").replace("%n",location);
SOptionPane.showErrorDialog(msg, localizer.getMessage("lblNoQuest"));
System.out.println(msg);
return false;
}
@@ -478,7 +482,8 @@ public class QuestUtil {
/** */
public static void showSpellShop() {
if (!checkActiveQuest("Visit the Spell Shop.")) {
final Localizer localizer = Localizer.getInstance();
if (!checkActiveQuest(localizer.getMessage("lblVisitTheSpellShop"))) {
return;
}
GuiBase.getInterface().showSpellShop();
@@ -486,7 +491,8 @@ public class QuestUtil {
/** */
public static void showBazaar() {
if (!checkActiveQuest("Visit the Bazaar.")) {
final Localizer localizer = Localizer.getInstance();
if (!checkActiveQuest(localizer.getMessage("lblVisitTheBazaar"))) {
return;
}
GuiBase.getInterface().showBazaar();
@@ -494,7 +500,8 @@ public class QuestUtil {
/** */
public static void chooseAndUnlockEdition() {
if (!checkActiveQuest("Unlock Editions.")) {
final Localizer localizer = Localizer.getInstance();
if (!checkActiveQuest(localizer.getMessage("lblUnlockEditions"))) {
return;
}
final QuestController qData = FModel.getQuest();
@@ -505,8 +512,8 @@ public class QuestUtil {
final CardEdition unlocked = toUnlock.left;
qData.getAssets().subtractCredits(toUnlock.right);
SOptionPane.showMessageDialog("You have successfully unlocked " + unlocked.getName() + "!",
unlocked.getName() + " unlocked!", null);
SOptionPane.showMessageDialog(localizer.getMessage("lblUnlocked").replace("%n",unlocked.getName()),
localizer.getMessage("titleUnlocked").replace("%n",unlocked.getName()), null);
QuestUtilUnlockSets.doUnlock(qData, unlocked);
}
@@ -645,14 +652,15 @@ public class QuestUtil {
* @return True if a game can be started.
*/
public static boolean canStartGame() {
if (!checkActiveQuest("Start a duel.") || null == event) {
final Localizer localizer = Localizer.getInstance();
if (!checkActiveQuest(localizer.getMessage("lblStartADuel")) || null == event) {
return false;
}
final Deck deck = getDeckForNewGame();
if (deck == null) {
final String msg = "Please select a Quest Deck.";
SOptionPane.showErrorDialog(msg, "No Deck");
final String msg = localizer.getMessage("lblSelectAQuestDeck");
SOptionPane.showErrorDialog(msg, localizer.getMessage("lblNoDeck"));
System.out.println(msg);
return false;
}
@@ -660,7 +668,7 @@ public class QuestUtil {
if (FModel.getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY)) {
final String errorMessage = getDeckConformanceProblems(deck);
if (null != errorMessage) {
SOptionPane.showErrorDialog("Your deck " + errorMessage + " Please edit or choose a different deck.", "Invalid Deck");
SOptionPane.showErrorDialog(localizer.getMessage("lblInvalidDeckDesc").replace("%n",errorMessage), "Invalid Deck");
return false;
}
}