Skip to content

Commit f9e4b60

Browse files
Fixed setting locale: now only language is needed: ru or en
1 parent 2025e37 commit f9e4b60

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

run-en.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
@ECHO OFF
2-
java -jar JDarkroom.jar en-US
2+
java -jar JDarkroom.jar en

run-ru.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
@ECHO OFF
2-
java -jar JDarkroom.jar ru-RU
2+
java -jar JDarkroom.jar ru

src/me/theentropyshard/jdarkroom/Main.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,19 @@
1919

2020
import javax.swing.*;
2121
import java.util.Locale;
22-
import java.util.regex.Matcher;
23-
import java.util.regex.Pattern;
2422

2523
public class Main {
2624
public static void main(String[] args) {
2725
if(args.length > 0) {
28-
Pattern localePattern = Pattern.compile("([a-z]{2})-([A-Z]{2})$");
29-
Matcher matcher = localePattern.matcher(args[0]);
30-
if(matcher.matches()) {
31-
try {
32-
String[] langAndCountry = args[0].split("-");
33-
Locale.setDefault(new Locale(langAndCountry[0], langAndCountry[1]));
34-
} catch (Exception se) {
35-
se.printStackTrace();
36-
}
37-
} else {
38-
System.err.println("Incorrect locale supplied: " + args[0]);
26+
String lang = args[0].toLowerCase(Locale.ROOT);
27+
if(!"ruen".contains(lang)) {
28+
lang = "en";
29+
}
30+
31+
try {
32+
Locale.setDefault(new Locale(lang));
33+
} catch (Exception e) {
34+
e.printStackTrace();
3935
}
4036
}
4137

0 commit comments

Comments
 (0)