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)
| 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); |