Example usage for org.apache.commons.lang3 SystemUtils USER_LANGUAGE

List of usage examples for org.apache.commons.lang3 SystemUtils USER_LANGUAGE

Introduction

In this page you can find the example usage for org.apache.commons.lang3 SystemUtils USER_LANGUAGE.

Prototype

String USER_LANGUAGE

To view the source code for org.apache.commons.lang3 SystemUtils USER_LANGUAGE.

Click Source Link

Document

The user.language System Property.

Usage

From source file:com.github.aynu.mosir.core.standard.util.PropertiesHelper.java

/**
 * ????// w  ww. ja  va2 s.  c o  m
 * @param baseName ??
 * @return ??
 */
private PropertiesConfiguration getPropertiesConfiguration(final String baseName) {
    final String languageTag = String.format("%s-%s", SystemUtils.USER_LANGUAGE, SystemUtils.USER_COUNTRY);
    final Control control = Control.getControl(Control.FORMAT_DEFAULT);
    final Collection<Locale> locales = control.getCandidateLocales("messages",
            Locale.forLanguageTag(languageTag));
    final StringBuilder builder = new StringBuilder();
    for (final Locale locale : locales) {
        final String bundleName = control.toBundleName(baseName, locale);
        final String resourceName = control.toResourceName(bundleName, "properties");
        final URL url = getClass().getResource("/" + resourceName);
        // final URL url = ClassLoader.getSystemResource(resourceName);
        if (url != null) {
            if (builder.length() > 0) {
                LOG.debug("Resource could not be found ({}).", builder.toString());
            }
            LOG.debug("Resource could be found ({}).", resourceName);
            try {
                return new PropertiesConfiguration(url);
            } catch (final ConfigurationException e) {
                throw new RuntimeException(e);
            }
        }
        builder.append(" " + resourceName);
    }
    throw new RuntimeException(String.format("PROPERTY is NOT_FOUND. [baseName=%s]", baseName));
}

From source file:com.github.aynu.yukar.framework.util.PropertiesHelper.java

/**
 * ????// w  ww  . jav a  2 s.  co m
 * @param baseName ??
 * @return ??
 */
private PropertiesConfiguration getPropertiesConfiguration(final String baseName) {
    final String languageTag = String.format("%s-%s", SystemUtils.USER_LANGUAGE, SystemUtils.USER_COUNTRY);
    final Control control = Control.getControl(Control.FORMAT_DEFAULT);
    final Collection<Locale> locales = control.getCandidateLocales("messages",
            Locale.forLanguageTag(languageTag));
    final StringBuilder builder = new StringBuilder();
    for (final Locale locale : locales) {
        try {
            final String bundleName = control.toBundleName(baseName, locale);
            final String resourceName = control.toResourceName(bundleName, "properties");
            final URL url = getClass().getResource("/" + resourceName);
            // final URL url = ClassLoader.getSystemResource(resourceName);
            if (url != null) {
                if (builder.length() > 0) {
                    LOG.debug("Resource could not be found ({}).", builder.toString());
                }
                LOG.debug("Resource could be found ({}).", resourceName);
                return new PropertiesConfiguration(url);
            }
            builder.append(" " + resourceName);
        } catch (final ConfigurationException e) {
            LOG.warn(e.toString(), e);
            throw new StandardRuntimeException(e);
        }
    }
    throw new StandardRuntimeException(String.format("PROPERTY is NOT_FOUND. [baseName=%s]", baseName));
}

From source file:pcgen.system.ConfigurationSettings.java

private ConfigurationSettings(String configFileName) {
    super(configFileName);
    //Initialize defaults
    setProperty(USER_LANGUAGE, SystemUtils.USER_LANGUAGE);
    setProperty(USER_COUNTRY, SystemUtils.USER_COUNTRY);
    setProperty(THEME_PACK_DIR, "@lib/lnf/themes".replace('/', File.separatorChar));
    setProperty(SYSTEMS_DIR, "@system");
    setProperty(OUTPUT_SHEETS_DIR, "@outputsheets");
    setProperty(PLUGINS_DIR, "@plugins");
    setProperty(PREVIEW_DIR, "@preview");
    setProperty(DOCS_DIR, "@docs");
    setProperty(PCC_FILES_DIR, "@data");
}