Example usage for java.util Locale getLanguage

List of usage examples for java.util Locale getLanguage

Introduction

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

Prototype

public String getLanguage() 

Source Link

Document

Returns the language code of this Locale.

Usage

From source file:com.processpuzzle.internalization.domain.ProcessPuzzleLocale.java

public int compareTo(Object other) {
    Locale javaLocale = getJavaLocale();
    int result = 0;
    if (other instanceof ProcessPuzzleLocale) {
        ProcessPuzzleLocale o = (ProcessPuzzleLocale) other;
        result = new CompareToBuilder().append(javaLocale.getLanguage(), o.getLanguage())
                .append(javaLocale.getCountry(), o.getCountry()).append(javaLocale.getVariant(), o.getVariant())
                .toComparison();//from   ww w  . jav a 2  s  .  c o  m
    }
    return result;
}

From source file:com.haulmont.cuba.core.global.MessageTools.java

/**
 * Locale representation depending on {@code cuba.useLocaleLanguageOnly} application property.
 *
 * @param locale locale instance/*  w w w  .  ja  va2  s.  co m*/
 * @return language code if {@code cuba.useLocaleLanguageOnly=true}, or full locale representation otherwise
 */
public String localeToString(Locale locale) {
    return useLocaleLanguageOnly() ? locale.getLanguage() : locale.toString();
}

From source file:com.jaeksoft.searchlib.index.IndexDocument.java

public IndexDocument(Locale lang) {
    this();//www.j ava  2s  .c om
    if (lang != null)
        this.lang = LanguageEnum.findByCode(lang.getLanguage());
}

From source file:architecture.ee.component.core.lifecycle.ConfigServiceImpl.java

/**
 * ?? .// w  w w  .  java2s . com
 * 
 * @param newLocale
 */
public void setLocale(Locale newLocale) {
    String country = newLocale.getCountry();
    String language = newLocale.getLanguage();
    setApplicationProperty(ApplicationConstants.LOCALE_COUNTRY_PROP_NAME, country);
    setApplicationProperty(ApplicationConstants.LOCALE_LANGUAGE_PROP_NAME, language);
    resetL10N();
}

From source file:com.magicmod.mmweather.engine.YahooWeatherProvider.java

private String getLanguage() {
    Locale locale = mContext.getResources().getConfiguration().locale;
    String country = locale.getCountry();
    String language = locale.getLanguage();

    if (TextUtils.isEmpty(country)) {
        return language;
    }/*from  ww  w.  j av  a  2s  . c o  m*/
    return language + "-" + country;
}

From source file:eu.delving.core.storage.impl.StaticRepoImpl.java

private String localeTitle(Locale locale) {
    if (locale == null) {
        return Page.TITLE;
    } else {/*from  w w  w. j  a  v a  2 s.  c om*/
        return String.format("%s_%s", Page.TITLE, locale.getLanguage());
    }
}

From source file:WelcomeServlet.java

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

    //Get the client's Locale
    Locale locale = request.getLocale();

    ResourceBundle bundle = ResourceBundle.getBundle("i18n.WelcomeBundle", locale);

    String welcome = bundle.getString("Welcome");

    //Display the locale
    response.setContentType("text/html");
    java.io.PrintWriter out = response.getWriter();

    out.println("<html><head><title>" + welcome + "</title></head><body>");

    out.println("<h2>" + welcome + "</h2>");

    out.println("Locale: ");
    out.println(locale.getLanguage() + "_" + locale.getCountry());

    out.println("</body></html>");
    out.close();//from  w ww . j a  v a  2 s  .co m

}

From source file:eu.delving.core.storage.impl.StaticRepoImpl.java

private String localeContent(Locale locale) {
    if (locale == null) {
        return Page.CONTENT;
    } else {//w  w w .j a  v a2  s. co  m
        return String.format("%s_%s", Page.CONTENT, locale.getLanguage());
    }
}

From source file:edu.ku.brc.specify.tools.schemalocale.SchemaLocalizerXMLHelper.java

/**
 * @param locale/*from  w ww.j ava 2 s. co  m*/
 * @return
 */
protected static String makeLocaleKey(final Locale locale) {
    return makeLocaleKey(locale.getLanguage(), locale.getCountry(), locale.getVariant());
}

From source file:com.haulmont.cuba.core.global.MessageTools.java

/**
 * Trims locale to language-only if {@link #useLocaleLanguageOnly()} is true.
 * @param locale    a locale//from ww w  .  ja  v  a  2  s.  c  om
 * @return          the locale with the same language and empty country and variant
 */
public Locale trimLocale(Locale locale) {
    return useLocaleLanguageOnly() ? Locale.forLanguageTag(locale.getLanguage()) : locale;
}