MCPcopy Create free account
hub / github.com/RipMeApp/ripme / getResourceBundle

Method getResourceBundle

src/main/java/com/rarchives/ripme/utils/Utils.java:736–755  ·  view source on GitHub ↗

Gets the ResourceBundle AKA language package. Used for choosing the language of the UI. @return Returns the default resource bundle using the language specified in the config file.

(String langSelect)

Source from the content-addressed store, hash-verified

734 * the config file.
735 */
736 public static ResourceBundle getResourceBundle(String langSelect) {
737 if (langSelect == null) {
738 if (!getConfigString("lang", "").equals("")) {
739 LOGGER.info("Setting locale to " + getConfigString("lang", ""));
740 return ResourceBundle.getBundle("LabelsBundle", Locale.forLanguageTag(getConfigString("lang", "")),
741 new UTF8Control());
742 }
743 } else {
744 String[] langCode = langSelect.split("-");
745 LOGGER.info("set locale, langcoe: {}, selected langauge: {}, locale: {}", langCode, langSelect, Locale.forLanguageTag(langSelect));
746 return ResourceBundle.getBundle("LabelsBundle", Locale.forLanguageTag(langSelect), new UTF8Control());
747 }
748 try {
749 LOGGER.info("Setting locale to default");
750 return ResourceBundle.getBundle("LabelsBundle", Locale.getDefault(), new UTF8Control());
751 } catch (MissingResourceException e) {
752 LOGGER.info("Setting locale to root");
753 return ResourceBundle.getBundle("LabelsBundle", Locale.ROOT);
754 }
755 }
756
757 public static void setLanguage(String langSelect) {
758 resourceBundle = getResourceBundle(langSelect);

Callers 4

testKeyCountMethod · 0.95
testKeyNameMethod · 0.95
UtilsClass · 0.95
setLanguageMethod · 0.95

Calls 1

getConfigStringMethod · 0.95

Tested by 2

testKeyCountMethod · 0.76
testKeyNameMethod · 0.76