add @PropertyKey to i18n methods for easier translation<->key navigation (#4831)
This commit is contained in:
@@ -21,6 +21,7 @@ import org.jackhuang.hmcl.download.RemoteVersion;
|
||||
import org.jackhuang.hmcl.download.game.GameRemoteVersion;
|
||||
import org.jackhuang.hmcl.util.i18n.translator.Translator;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.PropertyKey;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -59,11 +60,11 @@ public final class I18n {
|
||||
return locale.getTranslator();
|
||||
}
|
||||
|
||||
public static String i18n(String key, Object... formatArgs) {
|
||||
public static String i18n(@PropertyKey(resourceBundle = "assets.lang.I18N") String key, Object... formatArgs) {
|
||||
return locale.i18n(key, formatArgs);
|
||||
}
|
||||
|
||||
public static String i18n(String key) {
|
||||
public static String i18n(@PropertyKey(resourceBundle = "assets.lang.I18N") String key) {
|
||||
return locale.i18n(key);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.google.gson.stream.JsonWriter;
|
||||
import org.jackhuang.hmcl.util.StringUtils;
|
||||
import org.jackhuang.hmcl.util.gson.JsonUtils;
|
||||
import org.jackhuang.hmcl.util.i18n.translator.Translator;
|
||||
import org.jetbrains.annotations.PropertyKey;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -187,7 +188,7 @@ public final class SupportedLocale {
|
||||
return candidateLocales;
|
||||
}
|
||||
|
||||
public String i18n(String key, Object... formatArgs) {
|
||||
public String i18n(@PropertyKey(resourceBundle = "assets.lang.I18N") String key, Object... formatArgs) {
|
||||
try {
|
||||
return String.format(getResourceBundle().getString(key), formatArgs);
|
||||
} catch (MissingResourceException e) {
|
||||
@@ -199,7 +200,7 @@ public final class SupportedLocale {
|
||||
return key + Arrays.toString(formatArgs);
|
||||
}
|
||||
|
||||
public String i18n(String key) {
|
||||
public String i18n(@PropertyKey(resourceBundle = "assets.lang.I18N") String key) {
|
||||
try {
|
||||
return getResourceBundle().getString(key);
|
||||
} catch (MissingResourceException e) {
|
||||
|
||||
Reference in New Issue
Block a user