diff --git a/launcher/src/main/java/com/skcraft/launcher/AssetsRoot.java b/launcher/src/main/java/com/skcraft/launcher/AssetsRoot.java index 11b94a1..4127172 100644 --- a/launcher/src/main/java/com/skcraft/launcher/AssetsRoot.java +++ b/launcher/src/main/java/com/skcraft/launcher/AssetsRoot.java @@ -21,7 +21,7 @@ import java.io.IOException; import java.util.Map; import java.util.logging.Level; -import static com.skcraft.launcher.util.SharedLocale._; +import static com.skcraft.launcher.util.SharedLocale.tr; /** * Represents a directory that stores assets for Minecraft. The class has @@ -79,7 +79,7 @@ public class AssetsRoot { File path = getIndexPath(versionManifest); AssetsIndex index = Persistence.read(path, AssetsIndex.class, true); if (index == null || index.getObjects() == null) { - throw new LauncherException("Missing index at " + path, _("assets.missingIndex", path.getAbsolutePath())); + throw new LauncherException("Missing index at " + path, tr("assets.missingIndex", path.getAbsolutePath())); } File treeDir = new File(dir, "virtual/" + indexId); treeDir.mkdirs(); @@ -110,7 +110,7 @@ public class AssetsRoot { objectPath.getAbsolutePath(), virtualPath.getAbsolutePath()}); if (!objectPath.exists()) { - String message = _("assets.missingObject", objectPath.getAbsolutePath()); + String message = tr("assets.missingObject", objectPath.getAbsolutePath()); throw new LauncherException("Missing object " + objectPath.getAbsolutePath(), message); } @@ -134,9 +134,9 @@ public class AssetsRoot { @Override public String getStatus() { if (count == 0) { - return _("assets.expanding1", count, count - processed); + return tr("assets.expanding1", count, count - processed); } else { - return _("assets.expandingN", count, count - processed); + return tr("assets.expandingN", count, count - processed); } } } diff --git a/launcher/src/main/java/com/skcraft/launcher/InstanceList.java b/launcher/src/main/java/com/skcraft/launcher/InstanceList.java index 69d53df..8134b99 100644 --- a/launcher/src/main/java/com/skcraft/launcher/InstanceList.java +++ b/launcher/src/main/java/com/skcraft/launcher/InstanceList.java @@ -12,6 +12,7 @@ import com.skcraft.launcher.model.modpack.ManifestInfo; import com.skcraft.launcher.model.modpack.PackageList; import com.skcraft.launcher.persistence.Persistence; import com.skcraft.launcher.util.HttpRequest; +import com.skcraft.launcher.util.SharedLocale; import lombok.Getter; import lombok.NonNull; import lombok.extern.java.Log; @@ -27,7 +28,6 @@ import java.util.List; import java.util.concurrent.Callable; import static com.skcraft.launcher.LauncherUtils.concat; -import static com.skcraft.launcher.util.SharedLocale._; /** * Stores the list of instances. @@ -108,7 +108,7 @@ public class InstanceList { @Override public InstanceList call() throws Exception { log.info("Enumerating instance list..."); - progress = new DefaultProgress(0, _("instanceLoader.loadingLocal")); + progress = new DefaultProgress(0, SharedLocale.tr("instanceLoader.loadingLocal")); List local = new ArrayList(); List remote = new ArrayList(); @@ -128,7 +128,7 @@ public class InstanceList { } } - progress = new DefaultProgress(0.3, _("instanceLoader.checkingRemote")); + progress = new DefaultProgress(0.3, SharedLocale.tr("instanceLoader.checkingRemote")); try { URL packagesURL = launcher.getPackagesURL(); @@ -141,7 +141,7 @@ public class InstanceList { .asJson(PackageList.class); if (packages.getMinimumVersion() > Launcher.PROTOCOL_VERSION) { - throw new LauncherException("Update required", _("errors.updateRequiredError")); + throw new LauncherException("Update required", SharedLocale.tr("errors.updateRequiredError")); } for (ManifestInfo manifest : packages.getPackages()) { diff --git a/launcher/src/main/java/com/skcraft/launcher/dialog/ConfigurationDialog.java b/launcher/src/main/java/com/skcraft/launcher/dialog/ConfigurationDialog.java index a08b05e..7d0db34 100644 --- a/launcher/src/main/java/com/skcraft/launcher/dialog/ConfigurationDialog.java +++ b/launcher/src/main/java/com/skcraft/launcher/dialog/ConfigurationDialog.java @@ -10,6 +10,7 @@ import com.skcraft.launcher.Configuration; import com.skcraft.launcher.Launcher; import com.skcraft.launcher.swing.*; import com.skcraft.launcher.persistence.Persistence; +import com.skcraft.launcher.util.SharedLocale; import lombok.NonNull; import javax.swing.*; @@ -17,8 +18,6 @@ import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import static com.skcraft.launcher.util.SharedLocale._; - /** * A dialog to modify configuration options. */ @@ -39,7 +38,7 @@ public class ConfigurationDialog extends JDialog { private final JSpinner widthSpinner = new JSpinner(); private final JSpinner heightSpinner = new JSpinner(); private final FormPanel proxySettingsPanel = new FormPanel(); - private final JCheckBox useProxyCheck = new JCheckBox(_("options.useProxyCheck")); + private final JCheckBox useProxyCheck = new JCheckBox(SharedLocale.tr("options.useProxyCheck")); private final JTextField proxyHostText = new JTextField(); private final JSpinner proxyPortText = new JSpinner(); private final JTextField proxyUsernameText = new JTextField(); @@ -47,9 +46,9 @@ public class ConfigurationDialog extends JDialog { private final FormPanel advancedPanel = new FormPanel(); private final JTextField gameKeyText = new JTextField(); private final LinedBoxPanel buttonsPanel = new LinedBoxPanel(true); - private final JButton okButton = new JButton(_("button.ok")); - private final JButton cancelButton = new JButton(_("button.cancel")); - private final JButton logButton = new JButton(_("options.launcherConsole")); + private final JButton okButton = new JButton(SharedLocale.tr("button.ok")); + private final JButton cancelButton = new JButton(SharedLocale.tr("button.cancel")); + private final JButton logButton = new JButton(SharedLocale.tr("options.launcherConsole")); /** * Create a new configuration dialog. @@ -63,7 +62,7 @@ public class ConfigurationDialog extends JDialog { this.config = launcher.getConfig(); mapper = new ObjectSwingMapper(config); - setTitle(_("options.title")); + setTitle(SharedLocale.tr("options.title")); initComponents(); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setSize(new Dimension(400, 500)); @@ -88,32 +87,32 @@ public class ConfigurationDialog extends JDialog { } private void initComponents() { - javaSettingsPanel.addRow(new JLabel(_("options.jvmPath")), jvmPathText); - javaSettingsPanel.addRow(new JLabel(_("options.jvmArguments")), jvmArgsText); + javaSettingsPanel.addRow(new JLabel(SharedLocale.tr("options.jvmPath")), jvmPathText); + javaSettingsPanel.addRow(new JLabel(SharedLocale.tr("options.jvmArguments")), jvmArgsText); javaSettingsPanel.addRow(Box.createVerticalStrut(15)); - javaSettingsPanel.addRow(new JLabel(_("options.64BitJavaWarning"))); - javaSettingsPanel.addRow(new JLabel(_("options.minMemory")), minMemorySpinner); - javaSettingsPanel.addRow(new JLabel(_("options.maxMemory")), maxMemorySpinner); - javaSettingsPanel.addRow(new JLabel(_("options.permGen")), permGenSpinner); + javaSettingsPanel.addRow(new JLabel(SharedLocale.tr("options.64BitJavaWarning"))); + javaSettingsPanel.addRow(new JLabel(SharedLocale.tr("options.minMemory")), minMemorySpinner); + javaSettingsPanel.addRow(new JLabel(SharedLocale.tr("options.maxMemory")), maxMemorySpinner); + javaSettingsPanel.addRow(new JLabel(SharedLocale.tr("options.permGen")), permGenSpinner); SwingHelper.removeOpaqueness(javaSettingsPanel); - tabbedPane.addTab(_("options.javaTab"), SwingHelper.alignTabbedPane(javaSettingsPanel)); + tabbedPane.addTab(SharedLocale.tr("options.javaTab"), SwingHelper.alignTabbedPane(javaSettingsPanel)); - gameSettingsPanel.addRow(new JLabel(_("options.windowWidth")), widthSpinner); - gameSettingsPanel.addRow(new JLabel(_("options.windowHeight")), heightSpinner); + gameSettingsPanel.addRow(new JLabel(SharedLocale.tr("options.windowWidth")), widthSpinner); + gameSettingsPanel.addRow(new JLabel(SharedLocale.tr("options.windowHeight")), heightSpinner); SwingHelper.removeOpaqueness(gameSettingsPanel); - tabbedPane.addTab(_("options.minecraftTab"), SwingHelper.alignTabbedPane(gameSettingsPanel)); + tabbedPane.addTab(SharedLocale.tr("options.minecraftTab"), SwingHelper.alignTabbedPane(gameSettingsPanel)); proxySettingsPanel.addRow(useProxyCheck); - proxySettingsPanel.addRow(new JLabel(_("options.proxyHost")), proxyHostText); - proxySettingsPanel.addRow(new JLabel(_("options.proxyPort")), proxyPortText); - proxySettingsPanel.addRow(new JLabel(_("options.proxyUsername")), proxyUsernameText); - proxySettingsPanel.addRow(new JLabel(_("options.proxyPassword")), proxyPasswordText); + proxySettingsPanel.addRow(new JLabel(SharedLocale.tr("options.proxyHost")), proxyHostText); + proxySettingsPanel.addRow(new JLabel(SharedLocale.tr("options.proxyPort")), proxyPortText); + proxySettingsPanel.addRow(new JLabel(SharedLocale.tr("options.proxyUsername")), proxyUsernameText); + proxySettingsPanel.addRow(new JLabel(SharedLocale.tr("options.proxyPassword")), proxyPasswordText); SwingHelper.removeOpaqueness(proxySettingsPanel); - tabbedPane.addTab(_("options.proxyTab"), SwingHelper.alignTabbedPane(proxySettingsPanel)); + tabbedPane.addTab(SharedLocale.tr("options.proxyTab"), SwingHelper.alignTabbedPane(proxySettingsPanel)); - advancedPanel.addRow(new JLabel(_("options.gameKey")), gameKeyText); + advancedPanel.addRow(new JLabel(SharedLocale.tr("options.gameKey")), gameKeyText); SwingHelper.removeOpaqueness(advancedPanel); - tabbedPane.addTab(_("options.advancedTab"), SwingHelper.alignTabbedPane(advancedPanel)); + tabbedPane.addTab(SharedLocale.tr("options.advancedTab"), SwingHelper.alignTabbedPane(advancedPanel)); buttonsPanel.addElement(logButton); buttonsPanel.addGlue(); diff --git a/launcher/src/main/java/com/skcraft/launcher/dialog/ConsoleFrame.java b/launcher/src/main/java/com/skcraft/launcher/dialog/ConsoleFrame.java index eb3125c..bf27129 100644 --- a/launcher/src/main/java/com/skcraft/launcher/dialog/ConsoleFrame.java +++ b/launcher/src/main/java/com/skcraft/launcher/dialog/ConsoleFrame.java @@ -11,6 +11,7 @@ import com.skcraft.launcher.swing.LinedBoxPanel; import com.skcraft.launcher.swing.MessageLog; import com.skcraft.launcher.swing.SwingHelper; import com.skcraft.launcher.util.PastebinPoster; +import com.skcraft.launcher.util.SharedLocale; import lombok.Getter; import lombok.NonNull; @@ -21,7 +22,7 @@ import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; -import static com.skcraft.launcher.util.SharedLocale._; +import static com.skcraft.launcher.util.SharedLocale.tr; /** * A frame capable of showing messages. @@ -45,7 +46,7 @@ public class ConsoleFrame extends JFrame { * @param colorEnabled true to enable a colored console */ public ConsoleFrame(int numLines, boolean colorEnabled) { - this(_("console.title"), numLines, colorEnabled); + this(SharedLocale.tr("console.title"), numLines, colorEnabled); } /** @@ -79,7 +80,7 @@ public class ConsoleFrame extends JFrame { * Add components to the frame. */ private void initComponents() { - JButton pastebinButton = new JButton(_("console.uploadLog")); + JButton pastebinButton = new JButton(SharedLocale.tr("console.uploadLog")); buttonsPanel = new LinedBoxPanel(true); buttonsPanel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); @@ -122,18 +123,18 @@ public class ConsoleFrame extends JFrame { private void pastebinLog() { String text = messageLog.getPastableText(); // Not really bytes! - messageLog.log(_("console.pasteUploading", text.length()), messageLog.asHighlighted()); + messageLog.log(tr("console.pasteUploading", text.length()), messageLog.asHighlighted()); PastebinPoster.paste(text, new PastebinPoster.PasteCallback() { @Override public void handleSuccess(String url) { - messageLog.log(_("console.pasteUploaded", url), messageLog.asHighlighted()); + messageLog.log(tr("console.pasteUploaded", url), messageLog.asHighlighted()); SwingHelper.openURL(url, messageLog); } @Override public void handleError(String err) { - messageLog.log(_("console.pasteFailed", err), messageLog.asError()); + messageLog.log(tr("console.pasteFailed", err), messageLog.asError()); } }); } @@ -143,7 +144,7 @@ public class ConsoleFrame extends JFrame { if (frame == null) { frame = new ConsoleFrame(10000, false); globalFrame = frame; - frame.setTitle(_("console.launcherConsoleTitle")); + frame.setTitle(SharedLocale.tr("console.launcherConsoleTitle")); frame.registerLoggerHandler(); frame.setVisible(true); } else { diff --git a/launcher/src/main/java/com/skcraft/launcher/dialog/FeatureSelectionDialog.java b/launcher/src/main/java/com/skcraft/launcher/dialog/FeatureSelectionDialog.java index 57b0150..1c5301c 100644 --- a/launcher/src/main/java/com/skcraft/launcher/dialog/FeatureSelectionDialog.java +++ b/launcher/src/main/java/com/skcraft/launcher/dialog/FeatureSelectionDialog.java @@ -8,6 +8,7 @@ package com.skcraft.launcher.dialog; import com.skcraft.launcher.model.modpack.Feature; import com.skcraft.launcher.swing.*; +import com.skcraft.launcher.util.SharedLocale; import lombok.NonNull; import javax.swing.*; @@ -16,27 +17,26 @@ import javax.swing.event.ListSelectionListener; import java.awt.*; import java.util.List; -import static com.skcraft.launcher.util.SharedLocale._; import static javax.swing.BorderFactory.createEmptyBorder; public class FeatureSelectionDialog extends JDialog { private final List features; private final JPanel container = new JPanel(new BorderLayout()); - private final JTextArea descText = new JTextArea(_("features.selectForInfo")); + private final JTextArea descText = new JTextArea(SharedLocale.tr("features.selectForInfo")); private final JScrollPane descScroll = new JScrollPane(descText); private final CheckboxTable componentsTable = new CheckboxTable(); private final JScrollPane componentsScroll = new JScrollPane(componentsTable); private final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, componentsScroll, descScroll); private final LinedBoxPanel buttonsPanel = new LinedBoxPanel(true); - private final JButton installButton = new JButton(_("features.install")); + private final JButton installButton = new JButton(SharedLocale.tr("features.install")); public FeatureSelectionDialog(Window owner, @NonNull List features) { super(owner, ModalityType.DOCUMENT_MODAL); this.features = features; - setTitle(_("features.title")); + setTitle(SharedLocale.tr("features.title")); initComponents(); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setSize(new Dimension(500, 400)); @@ -66,10 +66,10 @@ public class FeatureSelectionDialog extends JDialog { buttonsPanel.addGlue(); buttonsPanel.addElement(installButton); - JLabel descLabel = new JLabel(_("features.intro")); + JLabel descLabel = new JLabel(SharedLocale.tr("features.intro")); descLabel.setBorder(createEmptyBorder(12, 12, 4, 12)); - SwingHelper.equalWidth(installButton, new JButton(_("button.cancel"))); + SwingHelper.equalWidth(installButton, new JButton(SharedLocale.tr("button.cancel"))); add(descLabel, BorderLayout.NORTH); add(container, BorderLayout.CENTER); @@ -90,7 +90,7 @@ public class FeatureSelectionDialog extends JDialog { if (feature != null) { descText.setText(feature.getDescription()); } else { - descText.setText(_("features.selectForInfo")); + descText.setText(SharedLocale.tr("features.selectForInfo")); } } diff --git a/launcher/src/main/java/com/skcraft/launcher/dialog/LauncherFrame.java b/launcher/src/main/java/com/skcraft/launcher/dialog/LauncherFrame.java index f40b40c..fa87511 100644 --- a/launcher/src/main/java/com/skcraft/launcher/dialog/LauncherFrame.java +++ b/launcher/src/main/java/com/skcraft/launcher/dialog/LauncherFrame.java @@ -23,6 +23,7 @@ import com.skcraft.launcher.swing.*; import com.skcraft.launcher.update.HardResetter; import com.skcraft.launcher.update.Remover; import com.skcraft.launcher.update.Updater; +import com.skcraft.launcher.util.SharedLocale; import com.skcraft.launcher.util.SwingExecutor; import lombok.NonNull; import lombok.extern.java.Log; @@ -42,7 +43,7 @@ import java.util.Date; import java.util.logging.Level; import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor; -import static com.skcraft.launcher.util.SharedLocale._; +import static com.skcraft.launcher.util.SharedLocale.tr; /** * The main launcher frame. @@ -60,11 +61,11 @@ public class LauncherFrame extends JFrame { private JSplitPane splitPane; private final JPanel container = new JPanel(); private final LinedBoxPanel buttonsPanel = new LinedBoxPanel(true).fullyPadded(); - private final JButton launchButton = new JButton(_("launcher.launch")); - private final JButton refreshButton = new JButton(_("launcher.checkForUpdates")); - private final JButton optionsButton = new JButton(_("launcher.options")); - private final JButton selfUpdateButton = new JButton(_("launcher.updateLauncher")); - private final JCheckBox updateCheck = new JCheckBox(_("launcher.downloadUpdates")); + private final JButton launchButton = new JButton(SharedLocale.tr("launcher.launch")); + private final JButton refreshButton = new JButton(SharedLocale.tr("launcher.checkForUpdates")); + private final JButton optionsButton = new JButton(SharedLocale.tr("launcher.options")); + private final JButton selfUpdateButton = new JButton(SharedLocale.tr("launcher.updateLauncher")); + private final JCheckBox updateCheck = new JCheckBox(SharedLocale.tr("launcher.downloadUpdates")); private URL updateUrl; /** @@ -73,7 +74,7 @@ public class LauncherFrame extends JFrame { * @param launcher the launcher */ public LauncherFrame(@NonNull Launcher launcher) { - super(_("launcher.title", launcher.getVersion())); + super(tr("launcher.title", launcher.getVersion())); this.launcher = launcher; instancesModel = new InstanceTableModel(launcher.getInstances()); @@ -202,8 +203,8 @@ public class LauncherFrame extends JFrame { selfUpdateButton.setVisible(false); SwingHelper.showMessageDialog( LauncherFrame.this, - _("launcher.selfUpdateComplete"), - _("launcher.selfUpdateCompleteTitle"), + SharedLocale.tr("launcher.selfUpdateComplete"), + SharedLocale.tr("launcher.selfUpdateCompleteTitle"), null, JOptionPane.INFORMATION_MESSAGE); } @@ -213,7 +214,7 @@ public class LauncherFrame extends JFrame { } }, SwingExecutor.INSTANCE); - ProgressDialog.showProgress(this, future, _("launcher.selfUpdatingTitle"), _("launcher.selfUpdatingStatus")); + ProgressDialog.showProgress(this, future, SharedLocale.tr("launcher.selfUpdatingTitle"), SharedLocale.tr("launcher.selfUpdatingStatus")); SwingHelper.addErrorDialogCallback(this, future); } else { selfUpdateButton.setVisible(false); @@ -250,27 +251,27 @@ public class LauncherFrame extends JFrame { if (selected.isLocal()) { popup.addSeparator(); - menuItem = new JMenuItem(_("instance.openFolder")); + menuItem = new JMenuItem(SharedLocale.tr("instance.openFolder")); menuItem.addActionListener(ActionListeners.browseDir( LauncherFrame.this, selected.getContentDir(), true)); popup.add(menuItem); - menuItem = new JMenuItem(_("instance.openSaves")); + menuItem = new JMenuItem(SharedLocale.tr("instance.openSaves")); menuItem.addActionListener(ActionListeners.browseDir( LauncherFrame.this, new File(selected.getContentDir(), "saves"), true)); popup.add(menuItem); - menuItem = new JMenuItem(_("instance.openResourcePacks")); + menuItem = new JMenuItem(SharedLocale.tr("instance.openResourcePacks")); menuItem.addActionListener(ActionListeners.browseDir( LauncherFrame.this, new File(selected.getContentDir(), "resourcepacks"), true)); popup.add(menuItem); - menuItem = new JMenuItem(_("instance.openScreenshots")); + menuItem = new JMenuItem(SharedLocale.tr("instance.openScreenshots")); menuItem.addActionListener(ActionListeners.browseDir( LauncherFrame.this, new File(selected.getContentDir(), "screenshots"), true)); popup.add(menuItem); - menuItem = new JMenuItem(_("instance.copyAsPath")); + menuItem = new JMenuItem(SharedLocale.tr("instance.copyAsPath")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -284,7 +285,7 @@ public class LauncherFrame extends JFrame { popup.addSeparator(); if (!selected.isUpdatePending()) { - menuItem = new JMenuItem(_("instance.forceUpdate")); + menuItem = new JMenuItem(SharedLocale.tr("instance.forceUpdate")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -296,7 +297,7 @@ public class LauncherFrame extends JFrame { popup.add(menuItem); } - menuItem = new JMenuItem(_("instance.hardForceUpdate")); + menuItem = new JMenuItem(SharedLocale.tr("instance.hardForceUpdate")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -305,7 +306,7 @@ public class LauncherFrame extends JFrame { }); popup.add(menuItem); - menuItem = new JMenuItem(_("instance.deleteFiles")); + menuItem = new JMenuItem(SharedLocale.tr("instance.deleteFiles")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -318,7 +319,7 @@ public class LauncherFrame extends JFrame { popup.addSeparator(); } - menuItem = new JMenuItem(_("launcher.refreshList")); + menuItem = new JMenuItem(SharedLocale.tr("launcher.refreshList")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -333,7 +334,7 @@ public class LauncherFrame extends JFrame { private void confirmDelete(Instance instance) { if (!SwingHelper.confirmDialog(this, - _("instance.confirmDelete", instance.getTitle()), _("confirmTitle"))) { + tr("instance.confirmDelete", instance.getTitle()), SharedLocale.tr("confirmTitle"))) { return; } @@ -344,7 +345,7 @@ public class LauncherFrame extends JFrame { // Show progress ProgressDialog.showProgress( - this, future, _("instance.deletingTitle"), _("instance.deletingStatus", instance.getTitle())); + this, future, SharedLocale.tr("instance.deletingTitle"), tr("instance.deletingStatus", instance.getTitle())); SwingHelper.addErrorDialogCallback(this, future); // Update the list of instances after updating @@ -357,7 +358,7 @@ public class LauncherFrame extends JFrame { } private void confirmHardUpdate(Instance instance) { - if (!SwingHelper.confirmDialog(this, _("instance.confirmHardUpdate"), _("confirmTitle"))) { + if (!SwingHelper.confirmDialog(this, SharedLocale.tr("instance.confirmHardUpdate"), SharedLocale.tr("confirmTitle"))) { return; } @@ -367,8 +368,8 @@ public class LauncherFrame extends JFrame { launcher.getExecutor().submit(resetter), resetter); // Show progress - ProgressDialog.showProgress( this, future, _("instance.resettingTitle"), - _("instance.resettingStatus", instance.getTitle())); + ProgressDialog.showProgress( this, future, SharedLocale.tr("instance.resettingTitle"), + tr("instance.resettingStatus", instance.getTitle())); SwingHelper.addErrorDialogCallback(this, future); // Update the list of instances after updating @@ -397,7 +398,7 @@ public class LauncherFrame extends JFrame { } }, SwingExecutor.INSTANCE); - ProgressDialog.showProgress(this, future, _("launcher.checkingTitle"), _("launcher.checkingStatus")); + ProgressDialog.showProgress(this, future, SharedLocale.tr("launcher.checkingTitle"), SharedLocale.tr("launcher.checkingStatus")); SwingHelper.addErrorDialogCallback(this, future); } @@ -436,7 +437,7 @@ public class LauncherFrame extends JFrame { // Show progress ProgressDialog.showProgress( - this, future, _("launcher.updatingTitle"), _("launcher.updatingStatus", instance.getTitle())); + this, future, SharedLocale.tr("launcher.updatingTitle"), tr("launcher.updatingStatus", instance.getTitle())); SwingHelper.addErrorDialogCallback(this, future); // Update the list of instances after updating @@ -462,7 +463,7 @@ public class LauncherFrame extends JFrame { launch(instance, session); } } catch (ArrayIndexOutOfBoundsException e) { - SwingHelper.showErrorDialog(this, _("launcher.noInstanceError"), _("launcher.noInstanceTitle")); + SwingHelper.showErrorDialog(this, SharedLocale.tr("launcher.noInstanceError"), SharedLocale.tr("launcher.noInstanceTitle")); } } @@ -476,7 +477,7 @@ public class LauncherFrame extends JFrame { // Show process for the process retrieval ProgressDialog.showProgress( - this, processFuture, _("launcher.launchingTItle"), _("launcher.launchingStatus", instance.getTitle())); + this, processFuture, SharedLocale.tr("launcher.launchingTItle"), tr("launcher.launchingStatus", instance.getTitle())); // If the process is started, get rid of this window Futures.addCallback(processFuture, new FutureCallback() { diff --git a/launcher/src/main/java/com/skcraft/launcher/dialog/LoginDialog.java b/launcher/src/main/java/com/skcraft/launcher/dialog/LoginDialog.java index 1d206fa..e2e5435 100644 --- a/launcher/src/main/java/com/skcraft/launcher/dialog/LoginDialog.java +++ b/launcher/src/main/java/com/skcraft/launcher/dialog/LoginDialog.java @@ -16,6 +16,7 @@ import com.skcraft.launcher.Launcher; import com.skcraft.launcher.auth.*; import com.skcraft.launcher.swing.*; import com.skcraft.launcher.persistence.Persistence; +import com.skcraft.launcher.util.SharedLocale; import com.skcraft.launcher.util.SwingExecutor; import lombok.Getter; import lombok.NonNull; @@ -28,8 +29,6 @@ import java.util.Date; import java.util.List; import java.util.concurrent.Callable; -import static com.skcraft.launcher.util.SharedLocale._; - /** * The login dialog. */ @@ -41,12 +40,12 @@ public class LoginDialog extends JDialog { private final JComboBox idCombo = new JComboBox(); private final JPasswordField passwordText = new JPasswordField(); - private final JCheckBox rememberIdCheck = new JCheckBox(_("login.rememberId")); - private final JCheckBox rememberPassCheck = new JCheckBox(_("login.rememberPassword")); - private final JButton loginButton = new JButton(_("login.login")); - private final LinkButton recoverButton = new LinkButton(_("login.recoverAccount")); - private final JButton offlineButton = new JButton(_("login.playOffline")); - private final JButton cancelButton = new JButton(_("button.cancel")); + private final JCheckBox rememberIdCheck = new JCheckBox(SharedLocale.tr("login.rememberId")); + private final JCheckBox rememberPassCheck = new JCheckBox(SharedLocale.tr("login.rememberPassword")); + private final JButton loginButton = new JButton(SharedLocale.tr("login.login")); + private final LinkButton recoverButton = new LinkButton(SharedLocale.tr("login.recoverAccount")); + private final JButton offlineButton = new JButton(SharedLocale.tr("login.playOffline")); + private final JButton cancelButton = new JButton(SharedLocale.tr("button.cancel")); private final FormPanel formPanel = new FormPanel(); private final LinedBoxPanel buttonsPanel = new LinedBoxPanel(true); @@ -62,7 +61,7 @@ public class LoginDialog extends JDialog { this.launcher = launcher; this.accounts = launcher.getAccounts(); - setTitle(_("login.title")); + setTitle(SharedLocale.tr("login.title")); initComponents(); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setMinimumSize(new Dimension(420, 0)); @@ -95,8 +94,8 @@ public class LoginDialog extends JDialog { loginButton.setFont(loginButton.getFont().deriveFont(Font.BOLD)); - formPanel.addRow(new JLabel(_("login.idEmail")), idCombo); - formPanel.addRow(new JLabel(_("login.password")), passwordText); + formPanel.addRow(new JLabel(SharedLocale.tr("login.idEmail")), idCombo); + formPanel.addRow(new JLabel(SharedLocale.tr("login.password")), passwordText); formPanel.addRow(new JLabel(), rememberIdCheck); formPanel.addRow(new JLabel(), rememberPassCheck); buttonsPanel.setBorder(BorderFactory.createEmptyBorder(26, 13, 13, 13)); @@ -185,7 +184,7 @@ public class LoginDialog extends JDialog { if (selected != null && selected instanceof Account) { final Account account = (Account) selected; - menuItem = new JMenuItem(_("login.forgetUser")); + menuItem = new JMenuItem(SharedLocale.tr("login.forgetUser")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -196,7 +195,7 @@ public class LoginDialog extends JDialog { popup.add(menuItem); if (!Strings.isNullOrEmpty(account.getPassword())) { - menuItem = new JMenuItem(_("login.forgetPassword")); + menuItem = new JMenuItem(SharedLocale.tr("login.forgetPassword")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -208,13 +207,13 @@ public class LoginDialog extends JDialog { } } - menuItem = new JMenuItem(_("login.forgetAllPasswords")); + menuItem = new JMenuItem(SharedLocale.tr("login.forgetAllPasswords")); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (SwingHelper.confirmDialog(LoginDialog.this, - _("login.confirmForgetAllPasswords"), - _("login.forgetAllPasswordsTitle"))) { + SharedLocale.tr("login.confirmForgetAllPasswords"), + SharedLocale.tr("login.forgetAllPasswordsTitle"))) { accounts.forgetPasswords(); Persistence.commitAndForget(accounts); } @@ -255,7 +254,7 @@ public class LoginDialog extends JDialog { String password = passwordText.getText(); if (password == null || password.isEmpty()) { - SwingHelper.showErrorDialog(this, _("login.noPasswordError"), _("login.noPasswordTitle")); + SwingHelper.showErrorDialog(this, SharedLocale.tr("login.noPasswordError"), SharedLocale.tr("login.noPasswordTitle")); } else { if (rememberPassCheck.isSelected()) { account.setPassword(password); @@ -276,7 +275,7 @@ public class LoginDialog extends JDialog { attemptLogin(account, password); } } else { - SwingHelper.showErrorDialog(this, _("login.noLoginError"), _("login.noLoginTitle")); + SwingHelper.showErrorDialog(this, SharedLocale.tr("login.noLoginError"), SharedLocale.tr("login.noLoginTitle")); } } @@ -296,7 +295,7 @@ public class LoginDialog extends JDialog { } }, SwingExecutor.INSTANCE); - ProgressDialog.showProgress(this, future, _("login.loggingInTitle"), _("login.loggingInStatus")); + ProgressDialog.showProgress(this, future, SharedLocale.tr("login.loggingInTitle"), SharedLocale.tr("login.loggingInStatus")); SwingHelper.addErrorDialogCallback(this, future); } @@ -339,7 +338,7 @@ public class LoginDialog extends JDialog { Persistence.commitAndForget(getAccounts()); return identities.get(0); } else { - throw new AuthenticationException("Minecraft not owned", _("login.minecraftNotOwnedError")); + throw new AuthenticationException("Minecraft not owned", SharedLocale.tr("login.minecraftNotOwnedError")); } } @@ -350,7 +349,7 @@ public class LoginDialog extends JDialog { @Override public String getStatus() { - return _("login.loggingInStatus"); + return SharedLocale.tr("login.loggingInStatus"); } } diff --git a/launcher/src/main/java/com/skcraft/launcher/dialog/ProcessConsoleFrame.java b/launcher/src/main/java/com/skcraft/launcher/dialog/ProcessConsoleFrame.java index 7f7ab6d..2ed3356 100644 --- a/launcher/src/main/java/com/skcraft/launcher/dialog/ProcessConsoleFrame.java +++ b/launcher/src/main/java/com/skcraft/launcher/dialog/ProcessConsoleFrame.java @@ -8,6 +8,7 @@ package com.skcraft.launcher.dialog; import com.skcraft.launcher.swing.LinedBoxPanel; import com.skcraft.launcher.swing.SwingHelper; +import com.skcraft.launcher.util.SharedLocale; import lombok.Getter; import lombok.Setter; @@ -17,7 +18,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.PrintWriter; -import static com.skcraft.launcher.util.SharedLocale._; +import static com.skcraft.launcher.util.SharedLocale.tr; /** * A version of the console window that can manage a process. @@ -40,7 +41,7 @@ public class ProcessConsoleFrame extends ConsoleFrame { * @param colorEnabled whether color is enabled in the log */ public ProcessConsoleFrame(int numLines, boolean colorEnabled) { - super(_("console.title"), numLines, colorEnabled); + super(SharedLocale.tr("console.title"), numLines, colorEnabled); processOut = new PrintWriter( getMessageLog().getOutputStream(new Color(0, 0, 255)), true); initComponents(); @@ -56,13 +57,13 @@ public class ProcessConsoleFrame extends ConsoleFrame { try { Process lastProcess = this.process; if (lastProcess != null) { - processOut.println(_("console.processEndCode", lastProcess.exitValue())); + processOut.println(tr("console.processEndCode", lastProcess.exitValue())); } } catch (IllegalThreadStateException e) { } if (process != null) { - processOut.println(_("console.attachedToProcess")); + processOut.println(SharedLocale.tr("console.attachedToProcess")); } this.process = process; @@ -109,7 +110,7 @@ public class ProcessConsoleFrame extends ConsoleFrame { } protected void initComponents() { - killButton = new JButton(_("console.forceClose")); + killButton = new JButton(SharedLocale.tr("console.forceClose")); minimizeButton = new JButton(); // Text set later LinedBoxPanel buttonsPanel = getButtonsPanel(); @@ -143,7 +144,7 @@ public class ProcessConsoleFrame extends ConsoleFrame { trayIcon = new TrayIcon(getTrayRunningIcon()); trayIcon.setImageAutoSize(true); - trayIcon.setToolTip(_("console.trayTooltip")); + trayIcon.setToolTip(SharedLocale.tr("console.trayTooltip")); trayIcon.addActionListener(new ActionListener() { @Override @@ -155,10 +156,10 @@ public class ProcessConsoleFrame extends ConsoleFrame { PopupMenu popup = new PopupMenu(); MenuItem item; - popup.add(item = new MenuItem(_("console.trayTitle"))); + popup.add(item = new MenuItem(SharedLocale.tr("console.trayTitle"))); item.setEnabled(false); - popup.add(item = new MenuItem(_("console.tray.showWindow"))); + popup.add(item = new MenuItem(SharedLocale.tr("console.tray.showWindow"))); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -166,7 +167,7 @@ public class ProcessConsoleFrame extends ConsoleFrame { } }); - popup.add(item = new MenuItem(_("console.tray.forceClose"))); + popup.add(item = new MenuItem(SharedLocale.tr("console.tray.forceClose"))); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -192,9 +193,9 @@ public class ProcessConsoleFrame extends ConsoleFrame { killButton.setEnabled(hasProcess()); if (!hasProcess() || trayIcon == null) { - minimizeButton.setText(_("console.closeWindow")); + minimizeButton.setText(SharedLocale.tr("console.closeWindow")); } else { - minimizeButton.setText(_("console.hideWindow")); + minimizeButton.setText(SharedLocale.tr("console.hideWindow")); } if (trayIcon != null) { @@ -215,7 +216,7 @@ public class ProcessConsoleFrame extends ConsoleFrame { } private boolean confirmKill() { - return SwingHelper.confirmDialog(this, _("console.confirmKill"), _("console.confirmKillTitle")); + return SwingHelper.confirmDialog(this, SharedLocale.tr("console.confirmKill"), SharedLocale.tr("console.confirmKillTitle")); } private void minimize() { diff --git a/launcher/src/main/java/com/skcraft/launcher/dialog/ProgressDialog.java b/launcher/src/main/java/com/skcraft/launcher/dialog/ProgressDialog.java index 4cb0320..ad8f467 100644 --- a/launcher/src/main/java/com/skcraft/launcher/dialog/ProgressDialog.java +++ b/launcher/src/main/java/com/skcraft/launcher/dialog/ProgressDialog.java @@ -12,6 +12,7 @@ import com.skcraft.concurrency.ObservableFuture; import com.skcraft.concurrency.ProgressObservable; import com.skcraft.launcher.swing.LinedBoxPanel; import com.skcraft.launcher.swing.SwingHelper; +import com.skcraft.launcher.util.SharedLocale; import com.skcraft.launcher.util.SwingExecutor; import lombok.extern.java.Log; @@ -25,7 +26,7 @@ import java.lang.ref.WeakReference; import java.util.Timer; import java.util.TimerTask; -import static com.skcraft.launcher.util.SharedLocale._; +import static com.skcraft.launcher.util.SharedLocale.tr; @Log public class ProgressDialog extends JDialog { @@ -42,8 +43,8 @@ public class ProgressDialog extends JDialog { private final JTextArea logText = new JTextArea(); private final JScrollPane logScroll = new JScrollPane(logText); private final JButton detailsButton = new JButton(); - private final JButton logButton = new JButton(_("progress.viewLog")); - private final JButton cancelButton = new JButton(_("button.cancel")); + private final JButton logButton = new JButton(SharedLocale.tr("progress.viewLog")); + private final JButton cancelButton = new JButton(SharedLocale.tr("button.cancel")); public ProgressDialog(Window owner, String title, String message) { super(owner, title, ModalityType.DOCUMENT_MODAL); @@ -69,14 +70,14 @@ public class ProgressDialog extends JDialog { } private void setCompactSize() { - detailsButton.setText(_("progress.details")); + detailsButton.setText(SharedLocale.tr("progress.details")); logButton.setVisible(false); setMinimumSize(new Dimension(400, 100)); pack(); } private void setDetailsSize() { - detailsButton.setText(_("progress.less")); + detailsButton.setText(SharedLocale.tr("progress.less")); logButton.setVisible(true); setSize(400, 350); } @@ -137,7 +138,7 @@ public class ProgressDialog extends JDialog { } private boolean confirmCancel() { - return SwingHelper.confirmDialog(this, _("progress.confirmCancel"), _("progress.confirmCancelTitle")); + return SwingHelper.confirmDialog(this, SharedLocale.tr("progress.confirmCancel"), SharedLocale.tr("progress.confirmCancelTitle")); } protected void cancel() { @@ -213,7 +214,7 @@ public class ProgressDialog extends JDialog { double progress = observable.getProgress(); if (progress >= 0) { - dialog.setTitle(_("progress.percentTitle", + dialog.setTitle(tr("progress.percentTitle", Math.round(progress * 100 * 100) / 100.0, dialog.defaultTitle)); progressBar.setValue((int) (progress * 1000)); progressBar.setIndeterminate(false); @@ -224,7 +225,7 @@ public class ProgressDialog extends JDialog { String status = observable.getStatus(); if (status == null) { - status = _("progress.defaultStatus"); + status = SharedLocale.tr("progress.defaultStatus"); label.setText(dialog.defaultMessage); } else { int index = status.indexOf('\n'); diff --git a/launcher/src/main/java/com/skcraft/launcher/install/FileCopy.java b/launcher/src/main/java/com/skcraft/launcher/install/FileCopy.java index 34064df..eec2be6 100644 --- a/launcher/src/main/java/com/skcraft/launcher/install/FileCopy.java +++ b/launcher/src/main/java/com/skcraft/launcher/install/FileCopy.java @@ -14,7 +14,7 @@ import java.io.File; import java.io.IOException; import java.util.logging.Level; -import static com.skcraft.launcher.util.SharedLocale._; +import static com.skcraft.launcher.util.SharedLocale.tr; @Log public class FileCopy implements InstallTask { @@ -41,7 +41,7 @@ public class FileCopy implements InstallTask { @Override public String getStatus() { - return _("installer.copyingFile", from, to); + return tr("installer.copyingFile", from, to); } } diff --git a/launcher/src/main/java/com/skcraft/launcher/install/FileMover.java b/launcher/src/main/java/com/skcraft/launcher/install/FileMover.java index 3293eb6..c1331b8 100644 --- a/launcher/src/main/java/com/skcraft/launcher/install/FileMover.java +++ b/launcher/src/main/java/com/skcraft/launcher/install/FileMover.java @@ -13,7 +13,7 @@ import java.io.File; import java.io.IOException; import java.util.logging.Level; -import static com.skcraft.launcher.util.SharedLocale._; +import static com.skcraft.launcher.util.SharedLocale.tr; @Log public class FileMover implements InstallTask { @@ -41,7 +41,7 @@ public class FileMover implements InstallTask { @Override public String getStatus() { - return _("installer.movingFile", from, to); + return tr("installer.movingFile", from, to); } } diff --git a/launcher/src/main/java/com/skcraft/launcher/install/HttpDownloader.java b/launcher/src/main/java/com/skcraft/launcher/install/HttpDownloader.java index 840ede4..32ba558 100644 --- a/launcher/src/main/java/com/skcraft/launcher/install/HttpDownloader.java +++ b/launcher/src/main/java/com/skcraft/launcher/install/HttpDownloader.java @@ -16,6 +16,7 @@ import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; import com.skcraft.concurrency.ProgressObservable; import com.skcraft.launcher.util.HttpRequest; +import com.skcraft.launcher.util.SharedLocale; import lombok.Getter; import lombok.NonNull; import lombok.Setter; @@ -29,7 +30,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Executors; import java.util.logging.Level; -import static com.skcraft.launcher.util.SharedLocale._; +import static com.skcraft.launcher.util.SharedLocale.tr; @Log public class HttpDownloader implements Downloader { @@ -158,9 +159,9 @@ public class HttpDownloader implements Downloader { @Override public synchronized String getStatus() { - String failMessage = _("downloader.failedCount", failed.size()); + String failMessage = tr("downloader.failedCount", failed.size()); if (running.size() == 1) { - return _("downloader.downloadingItem", running.get(0).getName()) + + return tr("downloader.downloadingItem", running.get(0).getName()) + "\n" + running.get(0).getStatus() + "\n" + failMessage; } else if (running.size() > 0) { @@ -169,11 +170,11 @@ public class HttpDownloader implements Downloader { builder.append("\n"); builder.append(job.getStatus()); } - return _("downloader.downloadingList", queue.size(), left, failed.size()) + + return tr("downloader.downloadingList", queue.size(), left, failed.size()) + builder.toString() + "\n" + failMessage; } else { - return _("downloader.noDownloads"); + return SharedLocale.tr("downloader.noDownloads"); } } @@ -270,9 +271,9 @@ public class HttpDownloader implements Downloader { public String getStatus() { double progress = getProgress(); if (progress >= 0) { - return _("downloader.jobProgress", name, Math.round(progress * 100 * 100) / 100.0); + return tr("downloader.jobProgress", name, Math.round(progress * 100 * 100) / 100.0); } else { - return _("downloader.jobPending", name); + return tr("downloader.jobPending", name); } } } diff --git a/launcher/src/main/java/com/skcraft/launcher/install/InstallLogFileMover.java b/launcher/src/main/java/com/skcraft/launcher/install/InstallLogFileMover.java index a34c093..e26e858 100644 --- a/launcher/src/main/java/com/skcraft/launcher/install/InstallLogFileMover.java +++ b/launcher/src/main/java/com/skcraft/launcher/install/InstallLogFileMover.java @@ -13,7 +13,7 @@ import java.io.File; import java.io.IOException; import java.util.logging.Level; -import static com.skcraft.launcher.util.SharedLocale._; +import static com.skcraft.launcher.util.SharedLocale.tr; @Log public class InstallLogFileMover implements InstallTask { @@ -44,7 +44,7 @@ public class InstallLogFileMover implements InstallTask { @Override public String getStatus() { - return _("installer.movingFile", from, to); + return tr("installer.movingFile", from, to); } } diff --git a/launcher/src/main/java/com/skcraft/launcher/install/Installer.java b/launcher/src/main/java/com/skcraft/launcher/install/Installer.java index 0ab03d2..ccfa522 100644 --- a/launcher/src/main/java/com/skcraft/launcher/install/Installer.java +++ b/launcher/src/main/java/com/skcraft/launcher/install/Installer.java @@ -7,6 +7,7 @@ package com.skcraft.launcher.install; import com.skcraft.concurrency.ProgressObservable; +import com.skcraft.launcher.util.SharedLocale; import lombok.Getter; import lombok.NonNull; import lombok.extern.java.Log; @@ -18,7 +19,7 @@ import java.util.Collections; import java.util.List; import static com.skcraft.launcher.LauncherUtils.checkInterrupted; -import static com.skcraft.launcher.util.SharedLocale._; +import static com.skcraft.launcher.util.SharedLocale.tr; @Log public class Installer implements ProgressObservable { @@ -77,9 +78,9 @@ public class Installer implements ProgressObservable { if (status == null) { status = running.toString(); } - return _("installer.executing", count - finished) + "\n" + status; + return tr("installer.executing", count - finished) + "\n" + status; } else { - return _("installer.installing"); + return SharedLocale.tr("installer.installing"); } } } diff --git a/launcher/src/main/java/com/skcraft/launcher/launch/Runner.java b/launcher/src/main/java/com/skcraft/launcher/launch/Runner.java index 7f5d426..d6c2ea5 100644 --- a/launcher/src/main/java/com/skcraft/launcher/launch/Runner.java +++ b/launcher/src/main/java/com/skcraft/launcher/launch/Runner.java @@ -21,6 +21,7 @@ import com.skcraft.launcher.model.minecraft.VersionManifest; import com.skcraft.launcher.persistence.Persistence; import com.skcraft.launcher.util.Environment; import com.skcraft.launcher.util.Platform; +import com.skcraft.launcher.util.SharedLocale; import lombok.Getter; import lombok.NonNull; import lombok.Setter; @@ -36,7 +37,7 @@ import java.util.Map; import java.util.concurrent.Callable; import static com.skcraft.launcher.LauncherUtils.checkInterrupted; -import static com.skcraft.launcher.util.SharedLocale._; +import static com.skcraft.launcher.util.SharedLocale.tr; /** * Handles the launching of an instance. @@ -44,7 +45,7 @@ import static com.skcraft.launcher.util.SharedLocale._; @Log public class Runner implements Callable, ProgressObservable { - private ProgressObservable progress = new DefaultProgress(0, _("runner.preparing")); + private ProgressObservable progress = new DefaultProgress(0, SharedLocale.tr("runner.preparing")); private final ObjectMapper mapper = new ObjectMapper(); private final Launcher launcher; @@ -92,7 +93,7 @@ public class Runner implements Callable, ProgressObservable { @Override public Process call() throws Exception { if (!instance.isInstalled()) { - throw new LauncherException("Update required", _("runner.updateRequired")); + throw new LauncherException("Update required", SharedLocale.tr("runner.updateRequired")); } config = launcher.getConfig(); @@ -110,12 +111,12 @@ public class Runner implements Callable, ProgressObservable { instance.setInstalled(false); Persistence.commitAndForget(instance); throw new LauncherException("Missing assets index " + assetsFile.getAbsolutePath(), - _("runner.missingAssetsIndex", instance.getTitle(), assetsFile.getAbsolutePath())); + tr("runner.missingAssetsIndex", instance.getTitle(), assetsFile.getAbsolutePath())); } catch (IOException e) { instance.setInstalled(false); Persistence.commitAndForget(instance); throw new LauncherException("Corrupt assets index " + assetsFile.getAbsolutePath(), - _("runner.corruptAssetsIndex", instance.getTitle(), assetsFile.getAbsolutePath())); + tr("runner.corruptAssetsIndex", instance.getTitle(), assetsFile.getAbsolutePath())); } // Copy over assets to the tree @@ -129,7 +130,7 @@ public class Runner implements Callable, ProgressObservable { throw e; } - progress = new DefaultProgress(0.9, _("runner.collectingArgs")); + progress = new DefaultProgress(0.9, SharedLocale.tr("runner.collectingArgs")); addJvmArgs(); addLibraries(); @@ -148,7 +149,7 @@ public class Runner implements Callable, ProgressObservable { Runner.log.info("Launching: " + builder); checkInterrupted(); - progress = new DefaultProgress(1, _("runner.startingJava")); + progress = new DefaultProgress(1, SharedLocale.tr("runner.startingJava")); return processBuilder.start(); } @@ -204,7 +205,7 @@ public class Runner implements Callable, ProgressObservable { instance.setInstalled(false); Persistence.commitAndForget(instance); throw new LauncherException("Missing library " + library.getName(), - _("runner.missingLibrary", instance.getTitle(), library.getName())); + tr("runner.missingLibrary", instance.getTitle(), library.getName())); } } diff --git a/launcher/src/main/java/com/skcraft/launcher/selfupdate/SelfUpdater.java b/launcher/src/main/java/com/skcraft/launcher/selfupdate/SelfUpdater.java index 92af33c..edb59d8 100644 --- a/launcher/src/main/java/com/skcraft/launcher/selfupdate/SelfUpdater.java +++ b/launcher/src/main/java/com/skcraft/launcher/selfupdate/SelfUpdater.java @@ -11,6 +11,7 @@ import com.skcraft.concurrency.ProgressObservable; import com.skcraft.launcher.Launcher; import com.skcraft.launcher.install.FileMover; import com.skcraft.launcher.install.Installer; +import com.skcraft.launcher.util.SharedLocale; import lombok.NonNull; import java.io.File; @@ -19,8 +20,6 @@ import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import static com.skcraft.launcher.util.SharedLocale._; - public class SelfUpdater implements Callable, ProgressObservable { public static boolean updatedAlready = false; @@ -28,7 +27,7 @@ public class SelfUpdater implements Callable, ProgressObservable { private final Launcher launcher; private final URL url; private final Installer installer; - private ProgressObservable progress = new DefaultProgress(0, _("updater.updating")); + private ProgressObservable progress = new DefaultProgress(0, SharedLocale.tr("updater.updating")); public SelfUpdater(@NonNull Launcher launcher, @NonNull URL url) { this.launcher = launcher; diff --git a/launcher/src/main/java/com/skcraft/launcher/selfupdate/UpdateChecker.java b/launcher/src/main/java/com/skcraft/launcher/selfupdate/UpdateChecker.java index f0e8517..8373916 100644 --- a/launcher/src/main/java/com/skcraft/launcher/selfupdate/UpdateChecker.java +++ b/launcher/src/main/java/com/skcraft/launcher/selfupdate/UpdateChecker.java @@ -9,14 +9,13 @@ package com.skcraft.launcher.selfupdate; import com.skcraft.launcher.Launcher; import com.skcraft.launcher.LauncherException; import com.skcraft.launcher.util.HttpRequest; +import com.skcraft.launcher.util.SharedLocale; import lombok.NonNull; import lombok.extern.java.Log; import java.net.URL; import java.util.concurrent.Callable; -import static com.skcraft.launcher.util.SharedLocale._; - /** * A worker that checks for an update to the launcher. A URL is returned * if there is an update to be downloaded. @@ -56,7 +55,7 @@ public class UpdateChecker implements Callable { return null; } } catch (Exception e) { - throw new LauncherException(e, _("errors.selfUpdateCheckError")); + throw new LauncherException(e, SharedLocale.tr("errors.selfUpdateCheckError")); } } diff --git a/launcher/src/main/java/com/skcraft/launcher/swing/FeatureTableModel.java b/launcher/src/main/java/com/skcraft/launcher/swing/FeatureTableModel.java index 8e4b873..3c44bd1 100644 --- a/launcher/src/main/java/com/skcraft/launcher/swing/FeatureTableModel.java +++ b/launcher/src/main/java/com/skcraft/launcher/swing/FeatureTableModel.java @@ -7,12 +7,11 @@ package com.skcraft.launcher.swing; import com.skcraft.launcher.model.modpack.Feature; +import com.skcraft.launcher.util.SharedLocale; import javax.swing.table.AbstractTableModel; import java.util.List; -import static com.skcraft.launcher.util.SharedLocale._; - public class FeatureTableModel extends AbstractTableModel { private final List features; @@ -25,7 +24,7 @@ public class FeatureTableModel extends AbstractTableModel { public String getColumnName(int columnIndex) { switch (columnIndex) { case 1: - return _("features.nameColumn"); + return SharedLocale.tr("features.nameColumn"); default: return null; } @@ -96,9 +95,9 @@ public class FeatureTableModel extends AbstractTableModel { } switch (feature.getRecommendation()) { case STARRED: - return " " + _("features.starred") + ""; + return " " + SharedLocale.tr("features.starred") + ""; case AVOID: - return " " + _("features.avoid") + ""; + return " " + SharedLocale.tr("features.avoid") + ""; default: return ""; } diff --git a/launcher/src/main/java/com/skcraft/launcher/swing/InstanceTableModel.java b/launcher/src/main/java/com/skcraft/launcher/swing/InstanceTableModel.java index 03887bf..b360e24 100644 --- a/launcher/src/main/java/com/skcraft/launcher/swing/InstanceTableModel.java +++ b/launcher/src/main/java/com/skcraft/launcher/swing/InstanceTableModel.java @@ -9,13 +9,12 @@ package com.skcraft.launcher.swing; import com.skcraft.launcher.Instance; import com.skcraft.launcher.InstanceList; import com.skcraft.launcher.Launcher; +import com.skcraft.launcher.util.SharedLocale; import javax.swing.*; import javax.swing.table.AbstractTableModel; import java.awt.*; -import static com.skcraft.launcher.util.SharedLocale._; - public class InstanceTableModel extends AbstractTableModel { private final InstanceList instances; @@ -44,7 +43,7 @@ public class InstanceTableModel extends AbstractTableModel { case 0: return ""; case 1: - return _("launcher.modpackColumn"); + return SharedLocale.tr("launcher.modpackColumn"); default: return null; } @@ -119,11 +118,11 @@ public class InstanceTableModel extends AbstractTableModel { private String getAddendum(Instance instance) { if (!instance.isLocal()) { - return " " + _("launcher.notInstalledHint") + ""; + return " " + SharedLocale.tr("launcher.notInstalledHint") + ""; } else if (!instance.isInstalled()) { - return " " + _("launcher.requiresUpdateHint") + ""; + return " " + SharedLocale.tr("launcher.requiresUpdateHint") + ""; } else if (instance.isUpdatePending()) { - return " " + _("launcher.updatePendingHint") + ""; + return " " + SharedLocale.tr("launcher.updatePendingHint") + ""; } else { return ""; } diff --git a/launcher/src/main/java/com/skcraft/launcher/swing/SwingHelper.java b/launcher/src/main/java/com/skcraft/launcher/swing/SwingHelper.java index 7779d62..ba49fdb 100644 --- a/launcher/src/main/java/com/skcraft/launcher/swing/SwingHelper.java +++ b/launcher/src/main/java/com/skcraft/launcher/swing/SwingHelper.java @@ -10,6 +10,7 @@ import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.skcraft.launcher.LauncherException; +import com.skcraft.launcher.util.SharedLocale; import com.skcraft.launcher.util.SwingExecutor; import lombok.NonNull; import lombok.extern.java.Log; @@ -35,7 +36,7 @@ import java.util.concurrent.CancellationException; import java.util.concurrent.atomic.AtomicBoolean; import java.util.logging.Level; -import static com.skcraft.launcher.util.SharedLocale._; +import static com.skcraft.launcher.util.SharedLocale.tr; import static org.apache.commons.io.IOUtils.closeQuietly; /** @@ -69,8 +70,8 @@ public final class SwingHelper { try { Desktop.getDesktop().open(file); } catch (IOException e) { - JOptionPane.showMessageDialog(component, _("errors.openDirError", file.getAbsolutePath()), - _("errorTitle"), JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(component, tr("errors.openDirError", file.getAbsolutePath()), + SharedLocale.tr("errorTitle"), JOptionPane.ERROR_MESSAGE); } } @@ -97,7 +98,7 @@ public final class SwingHelper { try { Desktop.getDesktop().browse(url.toURI()); } catch (IOException e) { - showErrorDialog(parentComponent, _("errors.openUrlError", url.toString()), _("errorTitle")); + showErrorDialog(parentComponent, tr("errors.openUrlError", url.toString()), SharedLocale.tr("errorTitle")); } catch (URISyntaxException e) { } } @@ -177,7 +178,7 @@ public final class SwingHelper { // Add the extra details if (detailsText != null) { - JTextArea textArea = new JTextArea(_("errors.reportErrorPreface") + detailsText); + JTextArea textArea = new JTextArea(SharedLocale.tr("errors.reportErrorPreface") + detailsText); JLabel tempLabel = new JLabel(); textArea.setFont(tempLabel.getFont()); textArea.setBackground(tempLabel.getBackground()); @@ -358,11 +359,11 @@ public final class SwingHelper { } else { message = t.getLocalizedMessage(); if (message == null) { - message = _("errors.genericError"); + message = SharedLocale.tr("errors.genericError"); } } log.log(Level.WARNING, "Task failed", t); - SwingHelper.showErrorDialog(owner, message, _("errorTitle"), t); + SwingHelper.showErrorDialog(owner, message, SharedLocale.tr("errorTitle"), t); } }, SwingExecutor.INSTANCE); } diff --git a/launcher/src/main/java/com/skcraft/launcher/swing/TextFieldPopupMenu.java b/launcher/src/main/java/com/skcraft/launcher/swing/TextFieldPopupMenu.java index 07f6257..4db5027 100644 --- a/launcher/src/main/java/com/skcraft/launcher/swing/TextFieldPopupMenu.java +++ b/launcher/src/main/java/com/skcraft/launcher/swing/TextFieldPopupMenu.java @@ -6,14 +6,14 @@ package com.skcraft.launcher.swing; +import com.skcraft.launcher.util.SharedLocale; + import javax.swing.*; import javax.swing.text.JTextComponent; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import static com.skcraft.launcher.util.SharedLocale._; - public class TextFieldPopupMenu extends JPopupMenu implements ActionListener { public static final TextFieldPopupMenu INSTANCE = new TextFieldPopupMenu(); @@ -25,12 +25,12 @@ public class TextFieldPopupMenu extends JPopupMenu implements ActionListener { private final JMenuItem selectAllItem; private TextFieldPopupMenu() { - cutItem = addMenuItem(new JMenuItem(_("context.cut"), 'T')); - copyItem = addMenuItem(new JMenuItem(_("context.copy"), 'C')); - pasteItem = addMenuItem(new JMenuItem(_("context.paste"), 'P')); - deleteItem = addMenuItem(new JMenuItem(_("context.delete"), 'D')); + cutItem = addMenuItem(new JMenuItem(SharedLocale.tr("context.cut"), 'T')); + copyItem = addMenuItem(new JMenuItem(SharedLocale.tr("context.copy"), 'C')); + pasteItem = addMenuItem(new JMenuItem(SharedLocale.tr("context.paste"), 'P')); + deleteItem = addMenuItem(new JMenuItem(SharedLocale.tr("context.delete"), 'D')); addSeparator(); - selectAllItem = addMenuItem(new JMenuItem(_("context.selectAll"), 'A')); + selectAllItem = addMenuItem(new JMenuItem(SharedLocale.tr("context.selectAll"), 'A')); } private JMenuItem addMenuItem(JMenuItem item) { diff --git a/launcher/src/main/java/com/skcraft/launcher/update/BaseUpdater.java b/launcher/src/main/java/com/skcraft/launcher/update/BaseUpdater.java index 9fa52a8..61f3dd1 100644 --- a/launcher/src/main/java/com/skcraft/launcher/update/BaseUpdater.java +++ b/launcher/src/main/java/com/skcraft/launcher/update/BaseUpdater.java @@ -24,6 +24,7 @@ import com.skcraft.launcher.model.modpack.ManifestEntry; import com.skcraft.launcher.persistence.Persistence; import com.skcraft.launcher.util.Environment; import com.skcraft.launcher.util.HttpRequest; +import com.skcraft.launcher.util.SharedLocale; import lombok.NonNull; import lombok.extern.java.Log; @@ -37,7 +38,6 @@ import java.util.logging.Level; import static com.skcraft.launcher.LauncherUtils.checkInterrupted; import static com.skcraft.launcher.LauncherUtils.concat; -import static com.skcraft.launcher.util.SharedLocale._; /** * The base implementation of the various routines involved in downloading @@ -90,7 +90,7 @@ public abstract class BaseUpdater { .asJson(Manifest.class); if (manifest.getMinimumVersion() > Launcher.PROTOCOL_VERSION) { - throw new LauncherException("Update required", _("errors.updateRequiredError")); + throw new LauncherException("Update required", SharedLocale.tr("errors.updateRequiredError")); } if (manifest.getBaseUrl() == null) { diff --git a/launcher/src/main/java/com/skcraft/launcher/update/HardResetter.java b/launcher/src/main/java/com/skcraft/launcher/update/HardResetter.java index cd9100a..5ec9b91 100644 --- a/launcher/src/main/java/com/skcraft/launcher/update/HardResetter.java +++ b/launcher/src/main/java/com/skcraft/launcher/update/HardResetter.java @@ -17,7 +17,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.concurrent.Callable; -import static com.skcraft.launcher.util.SharedLocale._; +import static com.skcraft.launcher.util.SharedLocale.tr; public class HardResetter implements Callable, ProgressObservable { @@ -35,7 +35,7 @@ public class HardResetter implements Callable, ProgressObservable { @Override public String getStatus() { - return _("instanceResetter.resetting", instance.getTitle()); + return tr("instanceResetter.resetting", instance.getTitle()); } @Override diff --git a/launcher/src/main/java/com/skcraft/launcher/update/Remover.java b/launcher/src/main/java/com/skcraft/launcher/update/Remover.java index 12f406f..985a84a 100644 --- a/launcher/src/main/java/com/skcraft/launcher/update/Remover.java +++ b/launcher/src/main/java/com/skcraft/launcher/update/Remover.java @@ -20,7 +20,7 @@ import java.util.List; import java.util.concurrent.Callable; import static com.skcraft.launcher.LauncherUtils.checkInterrupted; -import static com.skcraft.launcher.util.SharedLocale._; +import static com.skcraft.launcher.util.SharedLocale.tr; public class Remover implements Callable, ProgressObservable { @@ -37,7 +37,7 @@ public class Remover implements Callable, ProgressObservable { @Override public String getStatus() { - return _("instanceDeleter.deleting", instance.getDir()); + return tr("instanceDeleter.deleting", instance.getDir()); } @Override @@ -61,7 +61,7 @@ public class Remover implements Callable, ProgressObservable { if (failures.size() > 0) { throw new LauncherException(failures.size() + " failed to delete", - _("instanceDeleter.failures", failures.size())); + tr("instanceDeleter.failures", failures.size())); } return instance; diff --git a/launcher/src/main/java/com/skcraft/launcher/update/Updater.java b/launcher/src/main/java/com/skcraft/launcher/update/Updater.java index 9cc0fdd..e1a1905 100644 --- a/launcher/src/main/java/com/skcraft/launcher/update/Updater.java +++ b/launcher/src/main/java/com/skcraft/launcher/update/Updater.java @@ -18,6 +18,7 @@ import com.skcraft.launcher.model.minecraft.VersionManifest; import com.skcraft.launcher.model.modpack.Manifest; import com.skcraft.launcher.persistence.Persistence; import com.skcraft.launcher.util.HttpRequest; +import com.skcraft.launcher.util.SharedLocale; import lombok.Getter; import lombok.NonNull; import lombok.Setter; @@ -33,7 +34,6 @@ import java.util.concurrent.ExecutionException; import java.util.logging.Level; import static com.skcraft.launcher.util.HttpRequest.url; -import static com.skcraft.launcher.util.SharedLocale._; @Log public class Updater extends BaseUpdater implements Callable, ProgressObservable { @@ -49,7 +49,7 @@ public class Updater extends BaseUpdater implements Callable, Progress private List librarySources = new ArrayList(); private List assetsSources = new ArrayList(); - private ProgressObservable progress = new DefaultProgress(-1, _("instanceUpdater.preparingUpdate")); + private ProgressObservable progress = new DefaultProgress(-1, SharedLocale.tr("instanceUpdater.preparingUpdate")); public Updater(@NonNull Launcher launcher, @NonNull Instance instance) { super(launcher); @@ -72,14 +72,14 @@ public class Updater extends BaseUpdater implements Callable, Progress if (!online && updateRequired) { log.info("Can't update " + instance.getTitle() + " because offline"); - String message = _("updater.updateRequiredButOffline"); + String message = SharedLocale.tr("updater.updateRequiredButOffline"); throw new LauncherException("Update required but currently offline", message); } if (updateDesired && !updateCapable) { if (updateRequired) { log.info("Update required for " + instance.getTitle() + " but there is no manifest"); - String message = _("updater.updateRequiredButNoManifest"); + String message = SharedLocale.tr("updater.updateRequiredButNoManifest"); throw new LauncherException("Update required but no manifest", message); } else { log.info("Can't update " + instance.getTitle() + ", but update is not required"); @@ -134,7 +134,7 @@ public class Updater extends BaseUpdater implements Callable, Progress // Read manifest log.info("Reading package manifest..."); - progress = new DefaultProgress(-1, _("instanceUpdater.readingManifest")); + progress = new DefaultProgress(-1, SharedLocale.tr("instanceUpdater.readingManifest")); Manifest manifest = installPackage(installer, instance); // Update instance from manifest @@ -142,10 +142,10 @@ public class Updater extends BaseUpdater implements Callable, Progress // Read version manifest log.info("Reading version manifest..."); - progress = new DefaultProgress(-1, _("instanceUpdater.readingVersion")); + progress = new DefaultProgress(-1, SharedLocale.tr("instanceUpdater.readingVersion")); VersionManifest version = readVersionManifest(manifest); - progress = new DefaultProgress(-1, _("instanceUpdater.buildingDownloadList")); + progress = new DefaultProgress(-1, SharedLocale.tr("instanceUpdater.buildingDownloadList")); // Install the .jar File jarPath = launcher.getJarPath(version); @@ -162,12 +162,12 @@ public class Updater extends BaseUpdater implements Callable, Progress librarySources.add(url); } - progress = new DefaultProgress(-1, _("instanceUpdater.collectingLibraries")); + progress = new DefaultProgress(-1, SharedLocale.tr("instanceUpdater.collectingLibraries")); installLibraries(installer, version, launcher.getLibrariesDir(), librarySources); // Download assets log.info("Enumerating assets to download..."); - progress = new DefaultProgress(-1, _("instanceUpdater.collectingAssets")); + progress = new DefaultProgress(-1, SharedLocale.tr("instanceUpdater.collectingAssets")); installAssets(installer, version, launcher.propUrl("assetsIndexUrl", version.getAssetsIndex()), assetsSources); log.info("Executing download phase..."); diff --git a/launcher/src/main/java/com/skcraft/launcher/util/SharedLocale.java b/launcher/src/main/java/com/skcraft/launcher/util/SharedLocale.java index 93df77a..425a24e 100644 --- a/launcher/src/main/java/com/skcraft/launcher/util/SharedLocale.java +++ b/launcher/src/main/java/com/skcraft/launcher/util/SharedLocale.java @@ -50,7 +50,7 @@ public class SharedLocale { * @param key the key * @return the translated string */ - public static String _(String key) { + public static String tr(String key) { if (bundle != null) { try { return bundle.getString(key); @@ -71,10 +71,10 @@ public class SharedLocale { * @param args arguments * @return a translated string */ - public static String _(String key, Object... args) { + public static String tr(String key, Object... args) { if (bundle != null) { try { - MessageFormat formatter = new MessageFormat(_(key)); + MessageFormat formatter = new MessageFormat(tr(key)); formatter.setLocale(getLocale()); return formatter.format(args); } catch (MissingResourceException e) {