@Override protected InputStream getLocaleStream(LocaleSuffix locale) throws IOException { String filename = locale.getFileName("labels", ".properties"); InputStream inputStream = getClass().getResourceAsStream(filename); return inputStream; }
private void loadLabels() { LocaleSuffix[] locales = getLocaleSuffixes(); for (LocaleSuffix locale : locales) { try { Properties currentLocaleLabels = new Properties(loadedLabels); InputStream inputStream = getLocaleStream(locale); if (inputStream == null) { throw new IOException(); } currentLocaleLabels.load(new InputStreamReader(inputStream, "UTF-8")); loadedLabels = currentLocaleLabels; // Store the most dominant locale found. usedLocale = locale.getLocale(); } catch (IOException e) { System.err.println("Warning: Could not load " + locale + ". Falling back to next file."); } } }
/** * Gets a list of locale suffixes. * * @return The list, ordered from least to most preferred. */ public LocaleSuffix[] getLocaleSuffixes() { LocaleSuffix[] locales = new LocaleSuffix[] { new LocaleSuffix(new Locale("en"), false), new LocaleSuffix(preferredLocale, false), new LocaleSuffix(preferredLocale, true), }; return locales; }
@Override protected InputStream getLocaleStream(LocaleSuffix locale) throws IOException { String filename = locale.getFileName("labels", ".properties"); InputStream stream = ExceptionLabels.class.getResourceAsStream(filename); if (stream == null) { throw new FileNotFoundException(filename); } return stream; } }
@Override protected InputStream getLocaleStream(LocaleSuffix locale) throws IOException { String filename = locale.getFileName("labels", ".properties"); InputStream stream = EditorLabels.class.getResourceAsStream(filename); if (stream == null) { throw new FileNotFoundException(filename); } return stream; } }