/** * Gets a string. * * @param key * The name of the string * @return The localized string */ public String getSingleString(String key) { Properties labels = getLabels(); if (labels != null) { String value = labels.getProperty(key); if (value != null) { return value; } } return key; }
private synchronized Properties getLabels() { if (!labelsLoaded) { loadLabels(); labelsLoaded = true; } return loadedLabels; }
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."); } } }
private static void loadCommandLineSettings() { CommonConstants.CONTROL_ALL = SettingsManager.getInstance().isControllAll(); CommonConstants.ACTIVATE_ALL_PLAYERS = SettingsManager.getInstance().isActivateAllPlayers(); CommonConstants.ENABLE_CONSOLE_LOGGING = SettingsManager.getInstance().useConsoleOutput(); CommonConstants.DISABLE_ORIGINAL_MAPS = SettingsManager.getInstance().areOriginalMapsDisabled(); AbstractLabels.setPreferredLocale(SettingsManager.getInstance().getLocale()); }