Example usage for java.util Locale toString

List of usage examples for java.util Locale toString

Introduction

In this page you can find the example usage for java.util Locale toString.

Prototype

@Override
public final String toString() 

Source Link

Document

Returns a string representation of this Locale object, consisting of language, country, variant, script, and extensions as below:
language + "_" + country + "_" + (variant + "_#" | "#") + script + "_" + extensions
Language is always lower case, country is always upper case, script is always title case, and extensions are always lower case.

Usage

From source file:alfio.manager.PaypalManager.java

private static String toWebProfileName(Event event, Locale locale, APIContext apiContext) {
    return "ALFIO-"
            + DigestUtils.md5Hex(apiContext.getClientID() + "-" + event.getId() + "-" + event.getShortName())
            + "-" + locale.toString();
}

From source file:marytts.features.FeatureRegistry.java

public static Collection<Locale> getSupportedLocales() {
    Collection<Locale> locales = new TreeSet<Locale>(new Comparator<Locale>() {
        public int compare(Locale o1, Locale o2) {
            if (o1 == null) {
                if (o2 == null)
                    return 0;
                return -1;
            }//from ww  w .  j  a  v  a2  s .c o  m
            if (o2 == null) {
                return 1;
            }
            return o1.toString().compareTo(o2.toString());
        }
    });
    locales.addAll(managersByLocale.keySet());
    return locales;
}

From source file:com.hypersocket.i18n.I18N.java

private static File getOverrideFile(Locale locale, String bundle) {
    if (locale.equals(Locale.ENGLISH)) {
        return new File(overideDirector, bundle + ".properties");
    } else {// www.  j ava2  s .  c  om
        return new File(overideDirector, bundle + "_" + locale.toString() + ".properties");
    }
}

From source file:com.restfb.util.InsightUtilsTest.java

@BeforeClass
public static void beforeClass() throws ParseException {
    for (Locale locale : Locale.getAvailableLocales()) {
        if (locale.toString().equals("en_US")) {
            DEFAULT_LOCALE = locale;//  w  ww  . j ava  2  s .c o  m
            break;
        }
    }
    Assert.assertNotNull(DEFAULT_LOCALE);
    sdfUTC = newSimpleDateFormat("yyyyMMdd_HHmm", DEFAULT_LOCALE, UTC_TIMEZONE);
    sdfPST = newSimpleDateFormat("yyyyMMdd_HHmm", DEFAULT_LOCALE, PST_TIMEZONE);
    d20101204_0000pst = sdfPST.parse("20101204_0000");
    d20101205_0000pst = sdfPST.parse("20101205_0000");
}

From source file:net.sf.jasperreports.engine.util.JRResourcesUtil.java

public static ResourceBundle loadResourceBundle(RepositoryContext repositoryContext, String baseName,
        Locale locale) {/*from w  w w.  j  a v  a  2s  .c  o  m*/
    ResourceBundle resourceBundle = null;
    MissingResourceException ex = null;
    try {
        resourceBundle = loadResourceBundle(baseName, locale, null);
    } catch (MissingResourceException e) {
        ex = e;
    }

    if (resourceBundle == null) {
        CustomControl control = new CustomControl();
        List<Locale> locales = control.getCandidateLocales(baseName, locale);
        for (Locale lc : locales) {
            String suffix = lc.toString();
            suffix = (suffix.trim().length() > 0 ? "_" : "") + suffix;
            ResourceBundleResource resourceBundleResource = null;
            try {
                resourceBundleResource = RepositoryUtil.getInstance(repositoryContext).getResourceFromLocation(
                        baseName + suffix + PROPERTIES_FILE_EXTENSION, ResourceBundleResource.class);
            } catch (JRException e) {
            }
            if (resourceBundleResource != null) {
                resourceBundle = resourceBundleResource.getResourceBundle();
                break;
            }
        }
    }

    if (resourceBundle == null) {
        throw ex;
    }

    return resourceBundle;
}

From source file:org.b3log.latke.util.Locales.java

/**
 * Sets the specified locale into session of the specified request.
 *
 * <p>/* w w w . j av a  2s.  co  m*/
 * If no session of the specified request, do nothing.
 * </p>
 *
 * @param request the specified request
 * @param locale  a new locale
 */
public static void setLocale(final HttpServletRequest request, final Locale locale) {
    final HttpSession session = request.getSession(false);

    if (null == session) {
        LOGGER.warn("Ignores set locale caused by no session");

        return;
    }

    session.setAttribute(Keys.LOCALE, locale);
    LOGGER.log(Level.DEBUG, "Client[sessionId={0}] sets locale to [{1}]",
            new Object[] { session.getId(), locale.toString() });
}

From source file:com.acentic.cloudservices.session.web.PublicActions.java

private static Locale localefromString(String locale) {
    Locale l = null;
    String parts[] = locale.split("_", -1);
    if (parts.length == 1) {
        l = new Locale(parts[0]);
    } else if (parts.length == 2 || (parts.length == 3 && parts[2].startsWith("#"))) {
        l = new Locale(parts[0], parts[1]);
    } else {//from  ww  w . ja v  a 2s. c  o  m
        l = new Locale(parts[0], parts[1], parts[2]);
    }

    LOGGER.log(Level.DEBUG, "setting default locale to " + l.toString());
    return l;
}

From source file:org.apache.manifoldcf.core.i18n.Messages.java

/** Obtain a message given a resource bundle and message key.
*@return null if the message could not be found.
*//*w w w. j  a  v  a 2s. c o m*/
public static String getMessage(ResourceBundle resources, String bundleName, Locale locale, String messageKey) {
    String message;
    try {
        return resources.getString(messageKey);
    } catch (MissingResourceException e) {
        complainMissingMessage("Missing resource '" + messageKey + "' in bundle '" + bundleName
                + "' for locale '" + locale.toString() + "'", e, bundleName, locale, messageKey);
        return null;
    }
}

From source file:org.obiba.opal.web.magma.Dtos.java

public static LocaleDto asDto(Locale locale, @Nullable Locale displayLocale) {
    LocaleDto.Builder builder = LocaleDto.newBuilder().setName(locale.toString());

    if (displayLocale != null) {
        builder.setDisplay(locale.getDisplayName(displayLocale));
    }//from   w  ww .j  a  v  a  2s . co  m

    return builder.build();
}

From source file:org.apache.manifoldcf.core.i18n.Messages.java

private static String localizeResourceName(String pathName, String resourceName, Locale locale) {
    // Path names temporarily disabled, since they don't work.
    // MHL/*from   w  ww.ja v a 2 s .  com*/
    if (locale == null)
        return /*pathName + "." + */resourceName;
    int dotIndex = resourceName.lastIndexOf(".");
    if (dotIndex == -1)
        return /*pathName + "." + */resourceName + "_" + locale.toString();
    return /*pathName + "." + */resourceName.substring(0, dotIndex) + "_" + locale.toString()
            + resourceName.substring(dotIndex);
}