mirror of
https://github.com/TheEntropyShard/JDarkroom.git
synced 2024-11-23 21:26:22 +03:00
Fixed setting locale: now only language is needed: ru or en
This commit is contained in:
parent
2025e371e6
commit
f9e4b60533
3 changed files with 11 additions and 15 deletions
|
@ -1,2 +1,2 @@
|
||||||
@ECHO OFF
|
@ECHO OFF
|
||||||
java -jar JDarkroom.jar en-US
|
java -jar JDarkroom.jar en
|
|
@ -1,2 +1,2 @@
|
||||||
@ECHO OFF
|
@ECHO OFF
|
||||||
java -jar JDarkroom.jar ru-RU
|
java -jar JDarkroom.jar ru
|
|
@ -19,23 +19,19 @@ package me.theentropyshard.jdarkroom;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
if(args.length > 0) {
|
if(args.length > 0) {
|
||||||
Pattern localePattern = Pattern.compile("([a-z]{2})-([A-Z]{2})$");
|
String lang = args[0].toLowerCase(Locale.ROOT);
|
||||||
Matcher matcher = localePattern.matcher(args[0]);
|
if(!"ruen".contains(lang)) {
|
||||||
if(matcher.matches()) {
|
lang = "en";
|
||||||
try {
|
}
|
||||||
String[] langAndCountry = args[0].split("-");
|
|
||||||
Locale.setDefault(new Locale(langAndCountry[0], langAndCountry[1]));
|
try {
|
||||||
} catch (Exception se) {
|
Locale.setDefault(new Locale(lang));
|
||||||
se.printStackTrace();
|
} catch (Exception e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
} else {
|
|
||||||
System.err.println("Incorrect locale supplied: " + args[0]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue