Added options for localization
This commit is contained in:
@@ -30,20 +30,6 @@ public final class C {
|
||||
|
||||
public static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
|
||||
public static final ResourceBundle I18N;
|
||||
|
||||
static {
|
||||
ResourceBundle rb = null;
|
||||
try {
|
||||
rb = ResourceBundle.getBundle("org/jackhuang/hellominecraft/launcher/I18N");
|
||||
} catch (Throwable t) {
|
||||
rb = null;
|
||||
System.out.println("Did you delete I18N.properties?");
|
||||
t.printStackTrace();
|
||||
}
|
||||
I18N = rb;
|
||||
}
|
||||
|
||||
//http://repo1.maven.org/maven2
|
||||
public static final String URL_PUBLISH = "http://www.mcbbs.net/thread-142335-1-1.html";
|
||||
public static final String URL_TIEBA = "http://tieba.baidu.com/f?kw=hellominecraftlauncher";
|
||||
@@ -61,12 +47,7 @@ public final class C {
|
||||
}
|
||||
|
||||
public static String i18n(String a, Object... format) {
|
||||
try {
|
||||
return String.format(C.I18N.getString(a), format);
|
||||
} catch (Exception e) {
|
||||
HMCLog.warn("Failed to read localization key: " + a, e);
|
||||
return a;
|
||||
}
|
||||
return SupportedLocales.NOW_LOCALE.translate(a, format);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Hello Minecraft! Launcher.
|
||||
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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.hellominecraft.util;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public enum SupportedLocales {
|
||||
def(Locale.getDefault(), "lang.default"), en(Locale.ENGLISH, null), zh_TW(Locale.TRADITIONAL_CHINESE, null), zh_CN(Locale.SIMPLIFIED_CHINESE, null);
|
||||
|
||||
public Locale self;
|
||||
private String showString, customized;
|
||||
private ResourceBundle bundle;
|
||||
|
||||
private SupportedLocales(Locale self, String customized) {
|
||||
this.self = self;
|
||||
|
||||
try {
|
||||
bundle = ResourceBundle.getBundle("org/jackhuang/hellominecraft/lang/I18N", self);
|
||||
showString = bundle.getString("lang");
|
||||
this.customized = customized;
|
||||
} catch (Throwable t) {
|
||||
showString = self.toString();
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String showString() {
|
||||
if (customized == null)
|
||||
return showString;
|
||||
else
|
||||
return NOW_LOCALE.translate(customized);
|
||||
}
|
||||
|
||||
public static SupportedLocales NOW_LOCALE = def;
|
||||
|
||||
public String translate(String key, Object... format) {
|
||||
try {
|
||||
return bundle.getString(key);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -192,7 +192,7 @@ public class IOUtils {
|
||||
return path + "java";
|
||||
}
|
||||
|
||||
public static byte[] readFully(InputStream stream) throws IOException {
|
||||
public static ByteArrayOutputStream readFully(InputStream stream) throws IOException {
|
||||
byte[] data = new byte[4096];
|
||||
ByteArrayOutputStream entryBuffer = new ByteArrayOutputStream();
|
||||
int len;
|
||||
@@ -203,7 +203,7 @@ public class IOUtils {
|
||||
entryBuffer.write(data, 0, len);
|
||||
} while (len != -1);
|
||||
|
||||
return entryBuffer.toByteArray();
|
||||
return entryBuffer;
|
||||
}
|
||||
|
||||
public static void closeQuietly(Reader input) {
|
||||
|
||||
@@ -275,6 +275,8 @@ launcher.theme=\u4e3b\u9898
|
||||
launcher.proxy=\u4ee3\u7406
|
||||
launcher.decorated=\u542f\u7528\u7a97\u53e3\u8fb9\u6846(Linux\u4e0b\u53ef\u89e3\u51b3\u7a0b\u5e8f\u754c\u9762\u5168\u7070\u95ee\u9898)
|
||||
launcher.modpack=<html><a href="http://blog.163.com/huanghongxun2008@126/blog/static/7738046920160323812771/">\u6574\u5408\u5305\u4f5c\u8005\u5e2e\u52a9</a></html>
|
||||
launcher.enable_animation=\u542f\u7528\u52a8\u6001\u6548\u679c
|
||||
launcher.lang=\u8bed\u8a00
|
||||
|
||||
launcher.title.game=\u6e38\u620f\u8bbe\u7f6e
|
||||
launcher.title.main=\u4e3b\u9875
|
||||
@@ -369,4 +371,6 @@ wizard.close_mnemonic=\u5173
|
||||
wizard.summary=\u6982\u8981
|
||||
wizard.failed=\u5931\u8d25
|
||||
wizard.steps=\u6b65\u9aa4
|
||||
advancedsettings.debug_mode=\u8c03\u8bd5\u6a21\u5f0f
|
||||
|
||||
lang=\u7b80\u4f53\u4e2d\u6587
|
||||
lang.default=\u8ddf\u968f\u7cfb\u7edf\u8bed\u8a00
|
||||
@@ -275,6 +275,8 @@ launcher.theme=Theme
|
||||
launcher.proxy=Proxy
|
||||
launcher.decorated=Enable system window border(in order to fix the problem that the ui become all gray in Linux OS)
|
||||
launcher.modpack=<html><a href="http://blog.163.com/huanghongxun2008@126/blog/static/7738046920160323812771/">Documentations for modpacks.</a></html>
|
||||
launcher.enable_animation=Enable Animation
|
||||
launcher.lang=Language
|
||||
|
||||
launcher.title.game=Games
|
||||
launcher.title.main=Home
|
||||
@@ -368,4 +370,7 @@ wizard.close=Close
|
||||
wizard.close_mnemonic=C
|
||||
wizard.summary=Summary
|
||||
wizard.failed=Failed
|
||||
wizard.steps=Steps
|
||||
wizard.steps=Steps
|
||||
|
||||
lang=English
|
||||
lang.default=Belong to OS language.
|
||||
@@ -275,6 +275,8 @@ launcher.theme=\u4e3b\u9898
|
||||
launcher.proxy=\u4ee3\u7406
|
||||
launcher.decorated=\u542f\u7528\u7a97\u53e3\u8fb9\u6846(Linux\u4e0b\u53ef\u89e3\u51b3\u7a0b\u5e8f\u754c\u9762\u5168\u7070\u95ee\u9898)
|
||||
launcher.modpack=<html><a href="http://blog.163.com/huanghongxun2008@126/blog/static/7738046920160323812771/">\u6574\u5408\u5305\u4f5c\u8005\u5e2e\u52a9</a></html>
|
||||
launcher.enable_animation=\u542f\u7528\u52a8\u6001\u6548\u679c
|
||||
launcher.lang=\u8bed\u8a00
|
||||
|
||||
launcher.title.game=\u6e38\u620f\u8bbe\u7f6e
|
||||
launcher.title.main=\u4e3b\u9875
|
||||
@@ -368,4 +370,7 @@ wizard.close=\u5173\u95ed
|
||||
wizard.close_mnemonic=\u5173
|
||||
wizard.summary=\u6982\u8981
|
||||
wizard.failed=\u5931\u8d25
|
||||
wizard.steps=\u6b65\u9aa4
|
||||
wizard.steps=\u6b65\u9aa4
|
||||
|
||||
lang=\u7b80\u4f53\u4e2d\u6587
|
||||
lang.default=\u8ddf\u968f\u7cfb\u7edf\u8bed\u8a00
|
||||
@@ -275,6 +275,8 @@ launcher.theme=\u4e3b\u9898
|
||||
launcher.proxy=\u4ee3\u7406
|
||||
launcher.decorated=\u555f\u7528\u7a97\u53e3\u908a\u6846(Linux\u4e0b\u53ef\u89e3\u6c7a\u7a0b\u5e8f\u754c\u9762\u5168\u7070\u554f\u984c)
|
||||
launcher.modpack=<html><a href="http://blog.163.com/huanghongxun2008@126/blog/static/7738046920160323812771/">\u6574\u5408\u5305\u4f5c\u8005\u5e2e\u52a9</a></html>
|
||||
launcher.enable_animation=\u555f\u7528\u52d5\u614b\u6548\u679c
|
||||
launcher.lang=\u8a9e\u8a00
|
||||
|
||||
launcher.title.game=\u904a\u6232\u8a2d\u5b9a
|
||||
launcher.title.main=\u4e3b\u9801
|
||||
@@ -368,4 +370,7 @@ wizard.close=\u95dc\u9589
|
||||
wizard.close_mnemonic=\u95dc
|
||||
wizard.summary=\u6982\u8981
|
||||
wizard.failed=\u5931\u8d25
|
||||
wizard.steps=\u6b65\u9a5f
|
||||
wizard.steps=\u6b65\u9a5f
|
||||
|
||||
lang=\u6b63\u9ad4\u4e2d\u6587
|
||||
lang.default=\u8ddf\u96a8\u7cfb\u7d71\u8a9e\u8a00
|
||||
Reference in New Issue
Block a user