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:com.norconex.commons.wicket.markup.html.i18n.LocaleDropDownChoice.java

public LocaleDropDownChoice(String id, IModel<Locale> model, List<Locale> supportedLocales,
        final Locale displayLocale) {
    super(id, model, new ListModel<Locale>(supportedLocales), new IChoiceRenderer<Locale>() {
        private static final long serialVersionUID = 7765914025904608599L;

        @Override/*ww w.j a  va2  s.  c  o m*/
        public Object getDisplayValue(Locale locale) {
            Locale textLocale = displayLocale;
            if (textLocale == null) {
                textLocale = locale;
            }
            return StringUtils.capitalize(locale.getDisplayName(locale));
        }

        @Override
        public String getIdValue(Locale locale, int index) {
            return locale.toString();
        }
    });
}

From source file:org.freeplane.features.format.ScannerController.java

private Scanner findGoodMatch(final Locale locale) {
    final String localeAsString = locale.toString();
    Scanner countryScanner = null;
    for (Scanner scanner : scanners) {
        if (scanner.localeMatchesExactly(localeAsString))
            return scanner;
        else if (localeAsString.contains("_") && scanner.countryMatches(localeAsString))
            countryScanner = scanner;/*from w ww.java 2s  .  co m*/
    }
    return countryScanner;
}

From source file:org.freeplane.features.format.ScannerController.java

private Scanner findScanner(final Locale locale) {
    final String localeAsString = locale.toString();
    Scanner countryScanner = null;
    Scanner defaultScanner = null;
    for (Scanner scanner : scanners) {
        if (scanner.localeMatchesExactly(localeAsString))
            return scanner;
        else if (localeAsString.contains("_") && scanner.countryMatches(localeAsString))
            countryScanner = scanner;/*from   w  ww .ja v a  2 s . c  om*/
        else if (scanner.isDefault())
            defaultScanner = scanner;
    }
    return countryScanner == null ? defaultScanner : countryScanner;
}

From source file:com.balero.models.StaticPagesDAO.java

@Transactional
public void addPage(String pagename, String pagebody, String pageslug, Locale pagelocale) {
    Session session = sessionFactory.openSession();
    StaticPages staticPages = new StaticPages();
    staticPages.setPagename(pagename);//from   w  w w.  j  a  va 2s  .  c  o m
    staticPages.setPagebody(pagebody);
    staticPages.setPageslug(pageslug);
    staticPages.setPagelocale(pagelocale.toString());
    session.save(staticPages);
    session.flush();
    session.close();
}

From source file:com.liferay.ide.kaleo.core.KaleoConnection.java

public String getPortalLocale(long userId) throws KaleoAPIException {
    JSONObject user = getPortalUserById(userId);

    Locale defaultLocal = Locale.getDefault();

    String portalDefaultLocale = defaultLocal.toString();

    if (user != null) {
        try {/*from  www  . j av a  2  s  .c  o  m*/
            portalDefaultLocale = user.getString("languageId");
        } catch (JSONException jsone) {
        }
    }

    return portalDefaultLocale;
}

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

private MenuItem getDeleteMenu(Locale locale) {
    MenuItem deleteMenu = new MenuItem(MessageReader.getInstance().getMessage("action.deleteMessageKey"));
    deleteMenu.setOnAction(new EventHandler<ActionEvent>() {
        @Override//from  ww  w . jav a2s .c  o m
        public void handle(ActionEvent event) {
            logger.info("Clic on delete button for locale '" + locale.toString() + "'");

            String fileName = properties.getMapPropertiesFileByLocale().get(locale).getAbsolutePath();

            Alert alert = new Alert(AlertType.CONFIRMATION);
            alert.setTitle(MessageReader.getInstance().getMessage("manageLocale.confirmDelete.title"));
            alert.setHeaderText(MessageReader.getInstance().getMessage("manageLocale.confirmDelete.header"));
            alert.setContentText(
                    MessageReader.getInstance().getMessage("manageLocale.confirmDelete.content", fileName));
            Optional<ButtonType> result = alert.showAndWait();
            if (result.isPresent() && result.get() == ButtonType.OK) {
                logger.info("User say OK to the confirm");
                properties.deleteLocale(locale);

                // Reload list
                controller.initializeList();
            }

        }
    });

    if (properties.getMapPropertiesByLocale().keySet().size() <= 1) {
        // We can delete only if there is more than the current locale
        deleteMenu.setDisable(true);
    }

    return deleteMenu;
}

From source file:com.haulmont.cuba.gui.ScreensHelper.java

protected String getScreensCacheKey(String className, Locale locale, ScreenType filterScreenType) {
    return String.format("%s_%s_%s", className, locale.toString(), filterScreenType);
}

From source file:org.apache.cocoon.matching.LocaleMatcher.java

private boolean isValidResource(String pattern, Locale locale, Locale testLocale, Map map) {
    String url;//from   www. j  a  va  2s  .co  m

    String testLocaleStr = testLocale.toString();
    if ("".equals(testLocaleStr)) {
        // If same character found before and after the '*', leave only one.
        int starPos = pattern.indexOf("*");
        if (starPos < pattern.length() - 1 && starPos > 1
                && pattern.charAt(starPos - 1) == pattern.charAt(starPos + 1)) {
            url = pattern.substring(0, starPos - 1) + pattern.substring(starPos + 1);
        } else {
            url = StringUtils.replace(pattern, "*", "");
        }
    } else {
        url = StringUtils.replace(pattern, "*", testLocaleStr);
    }

    boolean result = true;
    if (testResourceExists) {
        Source source = null;
        try {
            source = resolver.resolveURI(url);
            result = source.exists();
        } catch (IOException e) {
            result = false;
        } finally {
            if (source != null) {
                resolver.release(source);
            }
        }
    }

    if (result) {
        map.put("source", url);
        map.put("matched-locale", testLocaleStr);
        if (locale != null) {
            map.put("locale", locale.toString());
            map.put("language", locale.getLanguage());
            map.put("country", locale.getCountry());
            map.put("variant", locale.getVariant());
        }
    }

    return result;
}

From source file:org.jboss.dashboard.provider.DataProviderImpl.java

public void setDescription(String descr, Locale l) {
    if (l == null)
        l = LocaleManager.currentLocale();
    if (descr == null)
        descriptions.remove(l.toString());
    else//w w  w .  j av  a2  s.  c om
        descriptions.put(l.toString(), descr);
}

From source file:io.uengine.web.configuration.ConfigurationController.java

/**
 *  ??   ? ./* w  w  w . j a  v a  2s .co  m*/
 */
@RequestMapping(value = "bundle", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
public Response getBundle(final Locale locale) throws IOException {
    Response response = new Response();
    try {
        Map map = Messages.toMap(locale);
        map.put("browser.language", locale.getLanguage());
        map.put("browser.country", locale.getCountry());
        map.put("browser.locale", locale.toString());

        MultiValueMap headers = new HttpHeaders();
        response.getMap().putAll(map);
        response.setSuccess(true);
    } catch (Exception ex) {
        response.getError().setMessage(ex.getMessage());
        if (ex.getCause() != null)
            response.getError().setCause(ex.getCause().getMessage());
        response.getError().setException(ExceptionUtils.getFullStackTrace(ex));
    }
    return response;
}