check locale string
This commit is contained in:
+24
-21
@@ -118,27 +118,30 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
|
|||||||
public Locale localeFromString(final String localeAsString) {
|
public Locale localeFromString(final String localeAsString) {
|
||||||
|
|
||||||
Locale locale = Locale.getDefault();
|
Locale locale = Locale.getDefault();
|
||||||
|
|
||||||
String[] localeParts = localeAsString.split("_");
|
if (StringUtils.isNotBlank(localeAsString)) {
|
||||||
String language = "en";
|
String[] localeParts = localeAsString.split("_");
|
||||||
String country = "GB";
|
|
||||||
String variant = "";
|
String language = "en";
|
||||||
if (localeParts != null && localeParts.length == 1) {
|
String country = "GB";
|
||||||
language = localeParts[0];
|
String variant = "";
|
||||||
locale = new Locale(language);
|
if (localeParts != null && localeParts.length == 1) {
|
||||||
}
|
language = localeParts[0];
|
||||||
|
locale = new Locale(language);
|
||||||
if (localeParts != null && localeParts.length == 2) {
|
}
|
||||||
language = localeParts[0];
|
|
||||||
country = localeParts[1];
|
if (localeParts != null && localeParts.length == 2) {
|
||||||
locale = new Locale(language, country);
|
language = localeParts[0];
|
||||||
}
|
country = localeParts[1];
|
||||||
|
locale = new Locale(language, country);
|
||||||
if (localeParts != null && localeParts.length == 3) {
|
}
|
||||||
language = localeParts[0];
|
|
||||||
country = localeParts[1];
|
if (localeParts != null && localeParts.length == 3) {
|
||||||
variant = localeParts[2];
|
language = localeParts[0];
|
||||||
locale = new Locale(language, country, variant);
|
country = localeParts[1];
|
||||||
|
variant = localeParts[2];
|
||||||
|
locale = new Locale(language, country, variant);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return locale;
|
return locale;
|
||||||
|
|||||||
Reference in New Issue
Block a user