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:org.hoteia.qalingo.core.i18n.message.ExtReloadableResourceBundleMessageSource.java

protected PropertiesHolder getSpecificProperties(String fileNamePattern, Locale locale) {
    String fileName = "classpath:" + fileNamePattern + "_" + locale.toString();
    PropertiesHolder propertiesHolder = getProperties(fileName);
    if (propertiesHolder == null) {
        fileName = "classpath:" + fileNamePattern;
        propertiesHolder = getProperties(fileName);
    }/*from  w w w  . j a va  2 s  .c  om*/
    return propertiesHolder;
}

From source file:org.mm.demo.portlet.HomeController.java

/**
 * Simply selects the home view to render by returning its name.
 *//*from  w w  w.j  ava 2 s  .c  om*/
@RenderMapping
public String home(final Locale locale, final Model model) {
    LOG.info("Welcome home! the client locale is {}", locale.toString());

    final Date date = new Date();
    final DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);

    final String formattedDate = dateFormat.format(date);

    model.addAttribute("serverTime", formattedDate);
    model.addAttribute("organizationLocalServiceBeanIdentifier", organizationLocalService.getBeanIdentifier());

    return "home";
}

From source file:com.jaspersoft.studio.editor.preview.input.LocaleInput.java

public void updateInput() {
    Object value = params.get(param.getName());
    if (value != null && value instanceof String)
        value = LocaleUtils.toLocale((String) value);
    if (value != null && value instanceof Locale) {
        Locale locale = (Locale) value;
        wlocal.setSelection(locale);//from ww  w. ja  v  a 2 s .co m
        wlocal.setToolTipText(tooltip + locale.toString());
    }
    setDecoratorNullable(param);
}

From source file:com.progress.singapore.datadirect.jdbc.demo.saleskit.common.StaticMessageSource.java

@Override
protected MessageFormat resolveCode(String code, Locale locale) {
    String key = code + "_" + locale.toString();
    String msg = (String) this.messages.get(key);
    if (msg == null) {
        return null;
    }//from w  w w .  ja  v a 2s .  co  m
    synchronized (this.cachedMessageFormats) {
        MessageFormat messageFormat = this.cachedMessageFormats.get(key);
        if (messageFormat == null) {
            messageFormat = createMessageFormat(msg, locale);
            this.cachedMessageFormats.put(key, messageFormat);
        }
        return messageFormat;
    }
}

From source file:com.properned.application.ManageLocaleController.java

public void initializeList() {
    logger.info("Initialize locale list");
    list = FXCollections.observableArrayList(multiLanguageProperties.getMapPropertiesByLocale().keySet());

    SortedList<Locale> sortedList = new SortedList<>(list, new Comparator<Locale>() {
        @Override//from   w ww  .j  a va  2  s . c om
        public int compare(Locale o1, Locale o2) {
            return o1.toString().compareTo(o2.toString());
        }
    });

    localeList.setItems(sortedList);

    localeList.setCellFactory(c -> new LocaleListCell(multiLanguageProperties, this));

    list.addListener(new ListChangeListener<Locale>() {
        @Override
        public void onChanged(Change<? extends Locale> c) {
            if (c.next()) {
                if (c.wasAdded()) {
                    List<? extends Locale> addedSubList = c.getAddedSubList();
                    for (Locale locale : addedSubList) {
                        try {
                            MultiLanguageProperties.getInstance().addLocale(locale);
                        } catch (IOException e) {
                            Properned.getInstance().showError(
                                    MessageReader.getInstance().getMessage("manageLocale.error.errorAddLocale"),
                                    e);
                        }
                    }

                }
            }
        }
    });
}

From source file:org.jahia.ajax.gwt.helper.LanguageHelper.java

/**
 * Get current lang//w  ww .  j  a v  a 2  s. co  m
 *
 * @return
 * @param locale
 */
public GWTJahiaLanguage getCurrentLang(Locale locale) {
    String langCode = locale.toString();
    GWTJahiaLanguage item = new GWTJahiaLanguage();
    item.setLanguage(langCode);
    item.setDisplayName(getDisplayName(langCode));
    item.setImage(getLangIcon(Jahia.getContextPath(), locale));
    return item;
}

From source file:com.fredhopper.connector.index.populator.CategoryPopulatorTest.java

@Test
public void testRootCategory() {
    final FhCategoryData categoryData = new FhCategoryData();
    categoryPopulator.populate(source1, categoryData);
    assertEquals("cat1", categoryData.getCategoryId());
    assertNull(categoryData.getParentId());

    for (final Locale loc : localesEnDe) {
        assertEquals("name1" + loc.toString(), categoryData.getNames().get(loc));
    }/*from  w w  w .  j a  v a 2  s  .  c  o m*/
}

From source file:com.fredhopper.connector.index.populator.CategoryPopulatorTest.java

@Test
public void test() {
    final FhCategoryData categoryData = new FhCategoryData();
    categoryPopulator.populate(source2, categoryData);
    assertEquals("cat2", categoryData.getCategoryId());
    assertEquals("cat1", categoryData.getParentId());

    for (final Locale loc : localesEnDe) {
        assertEquals("name2" + loc.toString(), categoryData.getNames().get(loc));
    }/*  w w  w .  j a  v  a2 s  .c o m*/
}

From source file:com.progress.singapore.datadirect.jdbc.demo.saleskit.common.StaticMessageSource.java

@Override
protected String resolveCodeWithoutArguments(String code, Locale locale) {
    return (String) this.messages.get(code + "_" + locale.toString());
}

From source file:LocaleInformationServlet.java

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {

    response.setContentType("text/html");
    PrintWriter out = response.getWriter();

    Locale userPreferredLocale = request.getLocale();
    Enumeration userPreferredLocales = request.getLocales();

    out.println("Preferred Locale: " + userPreferredLocale.toString());
    out.println("");
    out.print("Preferred Locales: ");

    while (userPreferredLocales.hasMoreElements()) {
        userPreferredLocale = (Locale) userPreferredLocales.nextElement();
        out.print(userPreferredLocale.toString() + ", ");
    }//from w ww  .  j  a v  a  2 s  . c  o m
    out.println();
    out.println("");
}