From f9e4b6053396f42a998480ee5831062d60b999b5 Mon Sep 17 00:00:00 2001 From: TheEntropyShard Date: Wed, 8 Mar 2023 12:54:01 +0300 Subject: [PATCH] Fixed setting locale: now only language is needed: ru or en --- run-en.bat | 2 +- run-ru.bat | 2 +- src/me/theentropyshard/jdarkroom/Main.java | 22 +++++++++------------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/run-en.bat b/run-en.bat index e5f49a1..4d9735a 100644 --- a/run-en.bat +++ b/run-en.bat @@ -1,2 +1,2 @@ @ECHO OFF -java -jar JDarkroom.jar en-US \ No newline at end of file +java -jar JDarkroom.jar en \ No newline at end of file diff --git a/run-ru.bat b/run-ru.bat index 2cc7e0a..7109c45 100644 --- a/run-ru.bat +++ b/run-ru.bat @@ -1,2 +1,2 @@ @ECHO OFF -java -jar JDarkroom.jar ru-RU \ No newline at end of file +java -jar JDarkroom.jar ru \ No newline at end of file diff --git a/src/me/theentropyshard/jdarkroom/Main.java b/src/me/theentropyshard/jdarkroom/Main.java index e4fb0d3..4ea6b89 100644 --- a/src/me/theentropyshard/jdarkroom/Main.java +++ b/src/me/theentropyshard/jdarkroom/Main.java @@ -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(); } }