mirror of
https://github.com/TheEntropyShard/JDarkroom.git
synced 2024-11-22 04:46:21 +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]));
|
|
||||||
} catch (Exception se) {
|
|
||||||
se.printStackTrace();
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
System.err.println("Incorrect locale supplied: " + args[0]);
|
try {
|
||||||
|
Locale.setDefault(new Locale(lang));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue