org.bidib.wizard.api.utils.XmlLocaleUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bidibwizard-api Show documentation
Show all versions of bidibwizard-api Show documentation
jBiDiB BiDiB Wizard API POM
package org.bidib.wizard.api.utils;
import java.util.Locale;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class XmlLocaleUtils {
private static final Logger LOGGER = LoggerFactory.getLogger(XmlLocaleUtils.class);
public static final String DEFAULT_LOCALE = "en-US";
public static final String DEFAULT_LOCALE_VENDOR_CV = "en-EN";
public static final String DEFAULT_FALLBACK_LOCALE = "en";
public static String getXmlLocale() {
Locale locale = Locale.getDefault();
LOGGER.trace("Current locale: {}", locale);
String xmlLocale = null;
xmlLocale = locale.getLanguage();
// if (xmlLocale.equals("de")) {
// xmlLocale = "de-DE";
// }
// else {
// xmlLocale = DEFAULT_LOCALE;
// }
if (StringUtils.isBlank(xmlLocale)) {
xmlLocale = DEFAULT_LOCALE;
}
return xmlLocale;
}
public static String getXmlLocaleVendorCV() {
Locale locale = Locale.getDefault();
LOGGER.trace("Current locale: {}", locale);
String xmlLocale = null;
xmlLocale = locale.getLanguage();
// if (xmlLocale.equals("de")) {
// xmlLocale = "de-DE";
// }
// else {
// xmlLocale = DEFAULT_LOCALE_VENDOR_CV;
// }
if (StringUtils.isBlank(xmlLocale)) {
xmlLocale = DEFAULT_LOCALE_VENDOR_CV;
}
return xmlLocale;
}
public static String stripMainLanguage(String language) {
int idx = language.indexOf('-');
if (idx > -1) {
return language.substring(0, idx);
}
return language;
}
}