mirror of
https://github.com/TheEntropyShard/JDarkroom.git
synced 2024-11-21 12:26: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
|
||||
java -jar JDarkroom.jar en-US
|
||||
java -jar JDarkroom.jar en
|
|
@ -1,2 +1,2 @@
|
|||
@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 java.util.Locale;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
if(args.length > 0) {
|
||||
Pattern localePattern = Pattern.compile("([a-z]{2})-([A-Z]{2})$");
|
||||
Matcher matcher = localePattern.matcher(args[0]);
|
||||
if(matcher.matches()) {
|
||||
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]);
|
||||
String lang = args[0].toLowerCase(Locale.ROOT);
|
||||
if(!"ruen".contains(lang)) {
|
||||
lang = "en";
|
||||
}
|
||||
|
||||
try {
|
||||
Locale.setDefault(new Locale(lang));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue