Example usage for java.util Locale getDisplayLanguage

List of usage examples for java.util Locale getDisplayLanguage

Introduction

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

Prototype

public final String getDisplayLanguage() 

Source Link

Document

Returns a name for the locale's language that is appropriate for display to the user.

Usage

From source file:Main.java

public static void main(String[] args) {
    Locale locale = new Locale("ENGLISH", "US");

    System.out.println("Locale:" + locale);

    // print language
    System.out.println("Language:" + locale.getDisplayLanguage());

}

From source file:Test.java

public static void main(String[] args) {
    Calendar calendar = Calendar.getInstance();
    calendar.setWeekDate(2012, 16, 3);//w ww  . java 2s .  c  o  m

    Builder builder = new Builder();
    builder.setLanguage("hy");
    builder.setScript("Latn");
    builder.setRegion("IT");
    builder.setVariant("arevela");

    Locale locale = builder.build();
    Locale.setDefault(locale);

    System.out.println(
            DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(calendar.getTime()));
    System.out.println("" + locale.getDisplayLanguage());

    builder.setLanguage("zh");
    builder.setScript("Hans");
    builder.setRegion("CN");

    locale = builder.build();
    Locale.setDefault(locale);

    System.out.println(
            DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(calendar.getTime()));
    System.out.println("" + locale.getDisplayLanguage());

}

From source file:Test.java

public static void main(String[] args) {
    Locale locale = Locale.getDefault();
    Calendar calendar = Calendar.getInstance();
    calendar.setWeekDate(2012, 16, 3);/* ww  w  . ja v  a 2s.  c  o  m*/

    System.out.println(
            DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(calendar.getTime()));
    System.out.println("" + locale.getDisplayLanguage());

    Locale.setDefault(Locale.Category.FORMAT, Locale.JAPANESE);
    Locale.setDefault(Locale.Category.DISPLAY, Locale.GERMAN);

    System.out.println(
            DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(calendar.getTime()));
    System.out.println("" + locale.getDisplayLanguage());

}

From source file:Main.java

static void describeLocale(Locale l) {
    System.out.println("Country: " + l.getDisplayCountry());
    System.out.println("Language: " + l.getDisplayLanguage());
    System.out.println();//w w  w.  j av a 2 s.com
}

From source file:Main.java

public static void printLocaleDetails(Locale locale) {
    String languageCode = locale.getLanguage();
    String languageName = locale.getDisplayLanguage();
    String countryCode = locale.getCountry();
    String countryName = locale.getDisplayCountry();
    // Print the locale info
    System.out.println("Language: " + languageName + "(" + languageCode + "); " + "Country: " + countryName
            + "(" + countryCode + ")");
}

From source file:Main.java

public static String getLanguage(Context context) {
    Locale locale = context.getResources().getConfiguration().locale;
    String language = locale.getDisplayLanguage();
    return language;
}

From source file:Main.java

public static void updateConfiguration(Context context) {
    Resources resources = context.getResources();
    Configuration conf = resources.getConfiguration();
    Locale current = Locale.getDefault();
    String currentLanguage = current.getDisplayLanguage();

    if (Locale.CHINESE.getDisplayLanguage().equals(currentLanguage)
            || Locale.ENGLISH.getDisplayLanguage().equals(currentLanguage)) {
        return;//from w w w  .  ja  va 2 s  .  co  m
    }

    conf.locale = Locale.ENGLISH;
    resources.updateConfiguration(conf, resources.getDisplayMetrics());
}

From source file:hu.petabyte.redflags.web.ctrl.LangAdvice.java

@ModelAttribute("language")
public String language(Locale loc) {
    return loc.getDisplayLanguage();
}

From source file:org.jspringbot.keyword.i18n.I18nHelper.java

public String getDisplayLanguage() {
    Locale locale = getLocale();

    LOG.keywordAppender().appendProperty("Display Language", locale.getDisplayLanguage());

    return locale.getDisplayLanguage();
}

From source file:org.mayocat.rest.resources.LocalesResource.java

@GET
public Response getLocales() {
    if (localesRepresentations == null) {
        Set<LocaleRepresentation> locales = Sets.newHashSet();
        List<Locale> availableLocales = LocaleUtils.availableLocaleList();
        for (final Locale locale : availableLocales) {
            StringBuilder nameBuilder = new StringBuilder();
            nameBuilder.append(locale.getDisplayLanguage());
            if (!Strings.isNullOrEmpty(locale.getDisplayCountry())) {
                nameBuilder.append(" (");
                nameBuilder.append(locale.getDisplayCountry());
                nameBuilder.append(")");
            }/*w w  w . j  a  v  a2  s  .  c o m*/
            final String name = nameBuilder.toString();
            locales.add(new LocaleRepresentation(locale.toLanguageTag(), name));
        }
        Ordering<LocaleRepresentation> nameOrdering = Ordering.natural()
                .onResultOf(new Function<LocaleRepresentation, String>() {
                    public String apply(LocaleRepresentation from) {
                        return from.getName();
                    }
                });

        localesRepresentations = ImmutableSortedSet.orderedBy(nameOrdering).addAll(locales).build();
    }

    return Response.ok(localesRepresentations).build();
}