Example usage for java.util Locale getCountry

List of usage examples for java.util Locale getCountry

Introduction

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

Prototype

public String getCountry() 

Source Link

Document

Returns the country/region code for this locale, which should either be the empty string, an uppercase ISO 3166 2-letter code, or a UN M.49 3-digit code.

Usage

From source file:Main.java

public static void main(String[] args) {
    Locale locale = Locale.SIMPLIFIED_CHINESE;

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

    // print the country of this locale
    System.out.println("Country:" + locale.getCountry());

}

From source file:Main.java

public static void main(String[] args) {
    Locale locale = Locale.TRADITIONAL_CHINESE;

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

    // print the country of this locale
    System.out.println("Country:" + locale.getCountry());

}

From source file:Main.java

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

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

    // print the country of this locale
    System.out.println("Country:" + locale.getCountry());

}

From source file:modelibra.swing.app.config.NatLang.java

public static void main(String[] args) {
    Log4jConfigurator log4jConfigurator = new Log4jConfigurator();
    log4jConfigurator.configure();// ww  w . j a va 2  s.  c o  m

    NatLang lang = new NatLang();
    lang.setNaturalLanguage("en");
    Locale locale = lang.getLocale();
    log.info("--- Language ---");
    log.info("Country: " + locale.getCountry());
    log.info("Language: " + locale.getLanguage());
    String text = lang.getText("selectDirectory");
    log.info("Selected text: " + text);
}

From source file:Main.java

public static String getCountry() {
    Locale locale = Locale.getDefault();
    return locale.getCountry();
}

From source file:Main.java

public static String getCountry() {
    Locale locale = Locale.getDefault();
    String countryCode = locale.getCountry();
    if (TextUtils.isEmpty(countryCode)) {
        countryCode = "";
    }// w  w  w .  j av  a 2 s . c  o m
    return countryCode;
}

From source file:Main.java

public static String getLocaleLanguage() {
    Locale l = Locale.getDefault();
    return String.format("%s-%s", l.getLanguage(), l.getCountry());
}

From source file:Main.java

/**
 * Get locale pairs. /*  w w w.j  a  v  a2s  .  c  o  m*/
 * @param source
 * @param target
 * @return In the pattern like, "ENUS-DEDE"
 */
public static String getLocalePairs(Locale source, Locale target) {
    String part1 = source.getLanguage() + source.getCountry();
    String part2 = target.getLanguage() + target.getCountry();
    return part1 + "-" + part2;
}

From source file:Main.java

private static String getLocale() {
    final Locale locale = Locale.getDefault();
    return locale.getLanguage() + "-" + locale.getCountry().toLowerCase();
}

From source file:Main.java

private static String constructLink(Locale locale, String path) {
    String domain = locale.getCountry().toLowerCase();

    // ISO-3166-to-TLD exceptions...
    if (domain.equals("us")) {
        domain = "com";
    } else if (domain.equals("ao")) {
        domain = "it.ao";
    } else if (domain.equals("gb")) {
        domain = "co.uk";
    } else {//  w  w w .  j  a v a 2 s.c om
        for (int i = 0; i < DOT_COM.length; i++) {
            if (domain.equals(DOT_COM[i])) {
                domain = "com." + domain;
                break;
            }
        }
        for (int i = 0; i < DOT_CO.length; i++) {
            if (domain.equals(DOT_CO[i])) {
                domain = "co." + domain;
                break;
            }
        }
        if (locale.toString().equals(Locale.CANADA_FRENCH.toString())) {
            path += "?hl=fr";
        }
    }

    return "http://m.google." + domain + path;
}