mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Localizer fallback to English
This commit is contained in:
@@ -8,11 +8,7 @@ import java.net.URLClassLoader;
|
|||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.MissingResourceException;
|
|
||||||
import java.util.ResourceBundle;
|
|
||||||
|
|
||||||
public class Localizer {
|
public class Localizer {
|
||||||
|
|
||||||
@@ -83,7 +79,7 @@ public class Localizer {
|
|||||||
public String getMessage(final String key, final Object... messageArguments) {
|
public String getMessage(final String key, final Object... messageArguments) {
|
||||||
return getMessage(false, key, messageArguments);
|
return getMessage(false, key, messageArguments);
|
||||||
}
|
}
|
||||||
public String getMessage(final boolean forcedEnglish, final String key, final Object... messageArguments) {
|
public String getMessage(boolean forcedEnglish, final String key, final Object... messageArguments) {
|
||||||
MessageFormat formatter = null;
|
MessageFormat formatter = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -94,9 +90,23 @@ public class Localizer {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (formatter == null && !silent) {
|
if (formatter == null) {
|
||||||
System.err.println("INVALID PROPERTY: '" + key + "' -- Translation Needed?");
|
if (!silent) {
|
||||||
return "INVALID PROPERTY: '" + key + "' -- Translation Needed?";
|
System.err.println("INVALID PROPERTY: '" + key + "' -- Translation missing from " + locale);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (english || forcedEnglish) {
|
||||||
|
return "INVALID PROPERTY: '" + key + "' -- Translation missing from English?";
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
formatter = new MessageFormat(englishBundle.getString(key), Locale.ENGLISH);
|
||||||
|
forcedEnglish = true;
|
||||||
|
} catch (final IllegalArgumentException | MissingResourceException e) {
|
||||||
|
if (!silent) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return "INVALID PROPERTY: '" + key + "' -- Translation missing from English locale?";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
silent = false;
|
silent = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user