53
53
*/
54
54
public class Utils {
55
55
56
- private static final Pattern pattern = Pattern .compile ("LabelsBundle_(?<lang>[A-Za-z_]+).properties" );
57
- private static final String DEFAULT_LANG = "en_US" ;
58
56
private static final String RIP_DIRECTORY = "rips" ;
59
57
private static final String CONFIG_FILE = "rip.properties" ;
60
58
private static final String OS = System .getProperty ("os.name" ).toLowerCase ();
@@ -740,8 +738,8 @@ public static ResourceBundle getResourceBundle(String langSelect) {
740
738
new UTF8Control ());
741
739
}
742
740
} else {
743
- String [] langCode = langSelect .split ("_ " );
744
- LOGGER .info ("Setting locale to " + langSelect );
741
+ String [] langCode = langSelect .split ("- " );
742
+ LOGGER .info ("set locale, langcoe: {}, selected langauge: {}, locale: {}" , langCode , langSelect , Locale . forLanguageTag ( langSelect ) );
745
743
return ResourceBundle .getBundle ("LabelsBundle" , Locale .forLanguageTag (langSelect ), new UTF8Control ());
746
744
}
747
745
try {
@@ -755,6 +753,7 @@ public static ResourceBundle getResourceBundle(String langSelect) {
755
753
756
754
public static void setLanguage (String langSelect ) {
757
755
resourceBundle = getResourceBundle (langSelect );
756
+ LOGGER .info ("Selected resource bundle locale: {}, from {}" , resourceBundle .getLocale ().toString (), langSelect );
758
757
}
759
758
760
759
public static String getSelectedLanguage () {
@@ -763,6 +762,8 @@ public static String getSelectedLanguage() {
763
762
764
763
// All the langs ripme has been translated into
765
764
public static String [] getSupportedLanguages () {
765
+ final Pattern pattern = Pattern .compile ("LabelsBundle_(?<lang>[A-Za-z_]+).properties" );
766
+ final String DEFAULT_LANG = "en-US" ;
766
767
ArrayList <Path > filesList = new ArrayList <>();
767
768
try {
768
769
URI uri = Objects .requireNonNull (Utils .class .getResource ("/rip.properties" )).toURI ();
@@ -782,7 +783,7 @@ public static String[] getSupportedLanguages() {
782
783
for (int i = 0 ; i < filesList .size (); i ++) {
783
784
Matcher matcher = pattern .matcher (filesList .get (i ).toString ());
784
785
if (matcher .find ())
785
- langs [i ] = matcher .group ("lang" );
786
+ langs [i ] = matcher .group ("lang" ). replace ( "_" , "-" ) ;
786
787
}
787
788
788
789
return langs ;
0 commit comments