Silently revert to system i18n language, if the currently selected language is not available.

This commit is contained in:
Cristian Maglie 2013-09-03 11:36:57 +02:00
parent 448595d0b2
commit ed41a67614
2 changed files with 12 additions and 5 deletions

View File

@ -28,14 +28,16 @@ public class I18n {
static String PROMPT_OK;
static String PROMPT_BROWSE;
static protected void init (String language) {
static protected void init (String language) throws MissingResourceException {
// there might be a null pointer exception ... most likely will never happen but the jvm gets mad
try {
if (language != null && language.trim().length() > 0) {
Locale.setDefault(new Locale(language));
Locale locale = new Locale(language);
i18n = ResourceBundle.getBundle("processing.app.i18n.Resources", locale);
Locale.setDefault(locale);
} else {
i18n = ResourceBundle.getBundle("processing.app.i18n.Resources", Locale.getDefault());
}
i18n = ResourceBundle.getBundle("processing.app.i18n.Resources", Locale.getDefault());
PROMPT_YES = _("Yes");
PROMPT_NO = _("No");
PROMPT_CANCEL = _("Cancel");

View File

@ -267,7 +267,12 @@ public class Preferences {
}
// load the I18n module for internationalization
I18n.init(Preferences.get("editor.languages.current"));
try {
I18n.init(Preferences.get("editor.languages.current"));
} catch (MissingResourceException e) {
I18n.init("");
Preferences.set("editor.languages.current", "");
}
// set some other runtime constants (not saved on preferences file)
table.put("runtime.os", PConstants.platformNames[PApplet.platform]);