Skip to content

Commit ed41a67

Browse files
committed
Silently revert to system i18n language, if the currently selected language is not available.
1 parent 448595d commit ed41a67

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

app/src/processing/app/I18n.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,16 @@ public class I18n {
2828
static String PROMPT_OK;
2929
static String PROMPT_BROWSE;
3030

31-
static protected void init (String language) {
31+
static protected void init (String language) throws MissingResourceException {
3232
// there might be a null pointer exception ... most likely will never happen but the jvm gets mad
3333
try {
3434
if (language != null && language.trim().length() > 0) {
35-
Locale.setDefault(new Locale(language));
35+
Locale locale = new Locale(language);
36+
i18n = ResourceBundle.getBundle("processing.app.i18n.Resources", locale);
37+
Locale.setDefault(locale);
38+
} else {
39+
i18n = ResourceBundle.getBundle("processing.app.i18n.Resources", Locale.getDefault());
3640
}
37-
i18n = ResourceBundle.getBundle("processing.app.i18n.Resources", Locale.getDefault());
38-
3941
PROMPT_YES = _("Yes");
4042
PROMPT_NO = _("No");
4143
PROMPT_CANCEL = _("Cancel");

app/src/processing/app/Preferences.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,12 @@ static protected void init(String commandLinePrefs) {
267267
}
268268

269269
// load the I18n module for internationalization
270-
I18n.init(Preferences.get("editor.languages.current"));
270+
try {
271+
I18n.init(Preferences.get("editor.languages.current"));
272+
} catch (MissingResourceException e) {
273+
I18n.init("");
274+
Preferences.set("editor.languages.current", "");
275+
}
271276

272277
// set some other runtime constants (not saved on preferences file)
273278
table.put("runtime.os", PConstants.platformNames[PApplet.platform]);

0 commit comments

Comments
 (0)