1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-03-22 13:19:48 +01:00

If a language resource is missing, fallback to system default

This commit is contained in:
Cristian Maglie 2018-05-21 11:28:36 +02:00
parent a64d1cbeb1
commit 8dd9a3e999
2 changed files with 17 additions and 1 deletions

View File

@ -35,6 +35,15 @@ public class Languages {
public static final Language[] languages;
public static boolean have(String isoCode) {
for (Language language : languages) {
if (language.getIsoCode().equals(isoCode)) {
return true;
}
}
return false;
}
static {
languages = new Language[]{
new Language(tr("System Default"), "", ""),

View File

@ -1,6 +1,8 @@
package processing.app;
import org.apache.commons.compress.utils.IOUtils;
import cc.arduino.i18n.Languages;
import processing.app.helpers.PreferencesHelper;
import processing.app.helpers.PreferencesMap;
import processing.app.legacy.PApplet;
@ -78,8 +80,13 @@ public class PreferencesData {
}
// load the I18n module for internationalization
String lang = get("editor.languages.current");
if (lang == null || !Languages.have(lang)) {
lang = "";
set("editor.languages.current", "");
}
try {
I18n.init(get("editor.languages.current"));
I18n.init(lang);
} catch (MissingResourceException e) {
I18n.init("en");
set("editor.languages.current", "en");