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) {
|
||||
|
||||
Locale locale = Locale.getDefault();
|
||||
|
||||
String[] localeParts = localeAsString.split("_");
|
||||
String language = "en";
|
||||
String country = "GB";
|
||||
String variant = "";
|
||||
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];
|
||||
locale = new Locale(language, country);
|
||||
}
|
||||
|
||||
if (localeParts != null && localeParts.length == 3) {
|
||||
language = localeParts[0];
|
||||
country = localeParts[1];
|
||||
variant = localeParts[2];
|
||||
locale = new Locale(language, country, variant);
|
||||
|
||||
if (StringUtils.isNotBlank(localeAsString)) {
|
||||
String[] localeParts = localeAsString.split("_");
|
||||
|
||||
String language = "en";
|
||||
String country = "GB";
|
||||
String variant = "";
|
||||
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];
|
||||
locale = new Locale(language, country);
|
||||
}
|
||||
|
||||
if (localeParts != null && localeParts.length == 3) {
|
||||
language = localeParts[0];
|
||||
country = localeParts[1];
|
||||
variant = localeParts[2];
|
||||
locale = new Locale(language, country, variant);
|
||||
}
|
||||
}
|
||||
|
||||
return locale;
|
||||
|
||||
Reference in New Issue
Block a user