Now OptionPane Yes No are translated

This commit is contained in:
huangyuhui
2017-07-28 09:44:29 +08:00
parent caa77387df
commit 34d560b75e
36 changed files with 86 additions and 36 deletions

View File

@@ -30,7 +30,7 @@ import org.jackhuang.hmcl.core.service.IMinecraftAssetService;
import org.jackhuang.hmcl.core.service.IMinecraftService;
import org.jackhuang.hmcl.core.version.AssetIndexDownloadInfo;
import org.jackhuang.hmcl.core.version.MinecraftVersion;
import org.jackhuang.hmcl.util.MessageBox;
import org.jackhuang.hmcl.util.ui.MessageBox;
import org.jackhuang.hmcl.api.HMCLog;
import org.jackhuang.hmcl.core.version.LoggingInfo;
import org.jackhuang.hmcl.util.task.Task;

View File

@@ -23,13 +23,13 @@ import org.jackhuang.hmcl.api.auth.AuthenticationException;
import com.google.gson.GsonBuilder;
import java.net.Proxy;
import java.util.Map;
import javax.swing.JOptionPane;
import org.jackhuang.hmcl.util.C;
import org.jackhuang.hmcl.util.ArrayUtils;
import org.jackhuang.hmcl.core.auth.yggdrasil.GameProfile;
import org.jackhuang.hmcl.core.auth.yggdrasil.UUIDTypeAdapter;
import org.jackhuang.hmcl.core.auth.yggdrasil.PropertyMap;
import org.jackhuang.hmcl.core.auth.yggdrasil.YggdrasilAuthentication;
import org.jackhuang.hmcl.util.ui.MessageBox;
import org.jackhuang.hmcl.util.ui.SwingUtils;
/**
@@ -77,7 +77,7 @@ public final class YggdrasilAuthenticator extends AbstractAuthenticator {
selectedProfile = profiles[sel];
username = names[sel];
} else
username = JOptionPane.showInputDialog(C.i18n("login.no_charactor"));
username = MessageBox.showInputDialog(C.i18n("login.no_charactor"));
else
username = selectedProfile.name;
if (username == null)

View File

@@ -79,7 +79,7 @@ public class MojangDownloadProvider extends IDownloadProvider {
else if (str.contains("scala-swing") || str.contains("scala-xml") || str.contains("scala-parser-combinators"))
return str.replace("http://files.minecraftforge.net/maven", "http://ftb.cursecdn.com/FTB2/maven/");
else if (str.contains("typesafe") || str.contains("scala"))
if (SupportedLocales.NOW_LOCALE.self == Locale.CHINA)
if (SupportedLocales.getNowLocale().self == Locale.CHINA)
return str.replace("http://files.minecraftforge.net/maven", "http://maven.aliyun.com/nexus/content/groups/public");
else
return str.replace("http://files.minecraftforge.net/maven", "http://repo1.maven.org/maven2");

View File

@@ -29,7 +29,7 @@ import org.jackhuang.hmcl.core.service.IMinecraftService;
import org.jackhuang.hmcl.util.task.Task;
import org.jackhuang.hmcl.util.sys.FileUtils;
import org.jackhuang.hmcl.core.version.MinecraftLibrary;
import org.jackhuang.hmcl.util.MessageBox;
import org.jackhuang.hmcl.util.ui.MessageBox;
import org.jackhuang.hmcl.util.sys.IOUtils;
/**

View File

@@ -27,7 +27,7 @@ import org.jackhuang.hmcl.util.C;
import org.jackhuang.hmcl.api.HMCLog;
import org.jackhuang.hmcl.util.sys.JdkVersion;
import org.jackhuang.hmcl.util.MathUtils;
import org.jackhuang.hmcl.util.MessageBox;
import org.jackhuang.hmcl.util.ui.MessageBox;
import org.jackhuang.hmcl.util.sys.OS;
import org.jackhuang.hmcl.util.sys.Platform;
import org.jackhuang.hmcl.util.StrUtils;

View File

@@ -25,7 +25,7 @@ import org.jackhuang.hmcl.core.download.DownloadLibraryJob;
import org.jackhuang.hmcl.api.auth.LoginInfo;
import org.jackhuang.hmcl.core.service.IMinecraftService;
import org.jackhuang.hmcl.util.C;
import org.jackhuang.hmcl.util.MessageBox;
import org.jackhuang.hmcl.util.ui.MessageBox;
import org.jackhuang.hmcl.api.HMCLog;
import org.jackhuang.hmcl.util.sys.CompressingUtils;
import org.jackhuang.hmcl.util.task.ParallelTask;

View File

@@ -39,7 +39,7 @@ import org.jackhuang.hmcl.core.service.IMinecraftService;
import org.jackhuang.hmcl.util.sys.FileUtils;
import org.jackhuang.hmcl.core.MCUtils;
import org.jackhuang.hmcl.util.task.TaskWindow;
import org.jackhuang.hmcl.util.MessageBox;
import org.jackhuang.hmcl.util.ui.MessageBox;
import org.jackhuang.hmcl.util.StrUtils;
import org.jackhuang.hmcl.api.func.Consumer;
import org.jackhuang.hmcl.api.func.Predicate;

View File

@@ -42,7 +42,7 @@ public final class C {
}
public static String i18n(String a, Object... format) {
return SupportedLocales.NOW_LOCALE.translate(a, format);
return SupportedLocales.getNowLocale().translate(a, format);
}
}

View File

@@ -17,6 +17,7 @@
*/
package org.jackhuang.hmcl.util;
import org.jackhuang.hmcl.util.ui.MessageBox;
import org.jackhuang.hmcl.api.VersionNumber;
import org.jackhuang.hmcl.api.event.EventHandler;
import org.jackhuang.hmcl.util.net.NetUtils;

View File

@@ -53,7 +53,15 @@ public enum SupportedLocales {
return NOW_LOCALE.translate(customized);
}
public static SupportedLocales NOW_LOCALE = def;
private static SupportedLocales NOW_LOCALE = def;
public static SupportedLocales getNowLocale() {
return NOW_LOCALE;
}
public static void setNowLocale(SupportedLocales newLocale) {
NOW_LOCALE = newLocale;
}
public String translate(String key, Object... format) {
try {

View File

@@ -24,7 +24,7 @@ import javax.swing.SwingUtilities;
import javax.swing.table.TableColumn;
import org.jackhuang.hmcl.util.C;
import org.jackhuang.hmcl.api.HMCLog;
import org.jackhuang.hmcl.util.MessageBox;
import org.jackhuang.hmcl.util.ui.MessageBox;
import org.jackhuang.hmcl.util.StrUtils;
import org.jackhuang.hmcl.util.ui.SwingUtils;

View File

@@ -15,10 +15,11 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}.
*/
package org.jackhuang.hmcl.util;
package org.jackhuang.hmcl.util.ui;
import org.jackhuang.hmcl.util.ui.SwingUtils;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import org.jackhuang.hmcl.util.C;
/**
* @author huangyuhui
@@ -103,6 +104,18 @@ public class MessageBox {
}
return 0;
}
public static String showInputDialog(String msg) {
return showInputDialog(msg, UIManager.getString("OptionPane.inputDialogTitle"));
}
public static String showInputDialog(String msg, String title) {
return showInputDialog(msg, title, null);
}
public static String showInputDialog(String msg, String title, String init) {
return (String) JOptionPane.showInputDialog(null, msg, title, JOptionPane.QUESTION_MESSAGE, null, null, init);
}
/**
* Show MsgBox with options
@@ -130,4 +143,11 @@ public class MessageBox {
public static int showLocalized(String msg) {
return show(C.i18n(msg));
}
static {
UIManager.put("OptionPane.cancelButtonText", C.i18n("button.cancel"));
UIManager.put("OptionPane.noButtonText", C.i18n("button.no"));
UIManager.put("OptionPane.okButtonText", C.i18n("button.ok"));
UIManager.put("OptionPane.yesButtonText", C.i18n("button.yes"));
}
}

View File

@@ -46,7 +46,6 @@ import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel;
import org.jackhuang.hmcl.util.C;
import org.jackhuang.hmcl.api.HMCLog;
import org.jackhuang.hmcl.util.MessageBox;
import org.jackhuang.hmcl.util.StrUtils;
import org.jackhuang.hmcl.util.Utils;
import org.jackhuang.hmcl.api.func.NonFunction;

View File

@@ -160,6 +160,8 @@ ui.button.test=Test
ui.button.preview=Preview
button.cancel=Cancel
button.ok=OK
button.yes=Yes
button.no=No
ui.label.version=Version
ui.label.password=Password

View File

@@ -160,6 +160,8 @@ ui.button.test=Test
ui.button.preview=Preview
button.cancel=Cancel
button.ok=OK
button.yes=Yes
button.no=No
ui.label.version=Version
ui.label.password=Password

View File

@@ -160,6 +160,8 @@ ui.button.test=Тест
ui.button.preview=Показать
button.cancel=Отменить
button.ok=OK
button.yes=да
button.no=Неа
ui.label.version=Версия
ui.label.password=Пароль

View File

@@ -160,6 +160,8 @@ ui.button.test=\u0422\u0435\u0441\u0442
ui.button.preview=\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c
button.cancel=\u041e\u0442\u043c\u0435\u043d\u0438\u0442\u044c
button.ok=OK
button.yes=\u0434\u0430
button.no=\u041d\u0435\u0430
ui.label.version=\u0412\u0435\u0440\u0441\u0438\u044f
ui.label.password=\u041f\u0430\u0440\u043e\u043b\u044c

View File

@@ -158,6 +158,8 @@ ui.button.test=Test
ui.button.preview=Xem trước
button.cancel=Thoát
button.ok=OK
button.yes=Yes
button.no=No
ui.label.version=Phiên bản
ui.label.password=Mật khẩu

View File

@@ -158,6 +158,8 @@ ui.button.test=Test
ui.button.preview=Xem tr\u01b0\u1edbc
button.cancel=Tho\u00e1t
button.ok=OK
button.yes=Yes
button.no=No
ui.label.version=Phi\u00ean b\u1ea3n
ui.label.password=M\u1eadt kh\u1ea9u

View File

@@ -160,6 +160,8 @@ ui.button.test=測試
ui.button.preview=預覽
button.cancel=取消
button.ok=確定
button.yes=是
button.no=不
ui.label.version=版本
ui.label.password=密碼

View File

@@ -160,6 +160,8 @@ ui.button.test=\u6e2c\u8a66
ui.button.preview=\u9810\u89bd
button.cancel=\u53d6\u6d88
button.ok=\u78ba\u5b9a
button.yes=\u662f
button.no=\u4e0d
ui.label.version=\u7248\u672c
ui.label.password=\u5bc6\u78bc

View File

@@ -160,6 +160,8 @@ ui.button.test=测试
ui.button.preview=预览
button.cancel=取消
button.ok=确定
button.yes=是
button.no=不
ui.label.version=版本
ui.label.password=密码

View File

@@ -160,6 +160,8 @@ ui.button.test=\u6d4b\u8bd5
ui.button.preview=\u9884\u89c8
button.cancel=\u53d6\u6d88
button.ok=\u786e\u5b9a
button.yes=\u662f
button.no=\u4e0d
ui.label.version=\u7248\u672c
ui.label.password=\u5bc6\u7801