Skip to content

Commit

Permalink
If a language resource is missing, fallback to system default
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed May 21, 2018
1 parent a64d1cb commit 8dd9a3e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
9 changes: 9 additions & 0 deletions arduino-core/src/cc/arduino/i18n/Languages.java
Original file line number Diff line number Diff line change
Expand Up @@ -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"), "", ""),
Expand Down
9 changes: 8 additions & 1 deletion arduino-core/src/processing/app/PreferencesData.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -78,8 +80,13 @@ static public void init(File file) throws Exception {
}

// 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");
Expand Down

0 comments on commit 8dd9a3e

Please sign in to comment.