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:Main.java

public static void main(String[] args) {

    Locale locale1 = new Locale("en", "US", "WIN");

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

    // print the locale as a string
    System.out.println("Locale:" + locale1.toString());

    Locale locale2 = new Locale("fr", "FRANCE", "WIN");

    System.out.println("Locale2:" + locale2);

    // print the locale as a string
    System.out.println("Locale2:" + locale2.toString());

}

From source file:com.rover12421.shaka.cli.Main.java

public static void main(String[] args) throws Exception {
    boolean smali = false;
    boolean baksmali = false;

    String[] realyArgs = args;/*from   w  w w. j  a v a 2 s.co m*/

    if (args.length > 0) {
        String cmd = args[0];
        if (cmd.equalsIgnoreCase("s") || cmd.equalsIgnoreCase("smali")) {
            smali = true;
        } else if (cmd.equalsIgnoreCase("bs") || cmd.equalsIgnoreCase("baksmali")) {
            baksmali = true;
        }

        if (smali || baksmali) {
            realyArgs = new String[args.length - 1];
            System.arraycopy(args, 1, realyArgs, 0, realyArgs.length);
        }
    }

    // cli parser
    CommandLineParser parser = new IgnoreUnkownArgsPosixParser();
    CommandLine commandLine;

    Option language = CommandLineArgEnum.LANGUAGE.getOption();

    Options options = new Options();
    options.addOption(language);

    try {
        commandLine = parser.parse(options, args, false);
        if (CommandLineArgEnum.LANGUAGE.hasMatch(commandLine)) {
            String lngStr = commandLine.getOptionValue(CommandLineArgEnum.LANGUAGE.getOpt());
            Locale locale = Locale.forLanguageTag(lngStr);
            if (locale.toString().isEmpty()) {
                lngStr = lngStr.replaceAll("_", "-");
                locale = Locale.forLanguageTag(lngStr);
            }
            MultiLanguageSupport.getInstance().setLang(locale);
        }
    } catch (Exception ex) {
    }

    if (smali) {
        smaliMainAj.setHookMain(ApktoolMainAj.getHookMain());
        org.jf.smali.main.main(realyArgs);
    } else if (baksmali) {
        baksmaliMainAj.setHookMain(ApktoolMainAj.getHookMain());
        org.jf.baksmali.main.main(realyArgs);
    } else {
        brut.apktool.Main.main(realyArgs);
    }
}

From source file:Main.java

public static String localeToString(Locale loc) {

    return loc != null ? loc.toString() : "";
}

From source file:Main.java

public final static String getSystemLocaleStringUsedAppStat(Context context) {

    Locale mlocale = context.getResources().getConfiguration().locale;
    return mlocale.toString().replace("_", "-");
}

From source file:com.netflix.imfutility.itunes.locale.LocaleHelper.java

public static String toITunesLocale(Locale locale) {
    return locale.toString().replace("_", "-");
}

From source file:nu.yona.server.Translator.java

public static String getStandardLocaleString(Locale locale) {
    return locale.toString().replace('_', '-');
}

From source file:org.smigo.user.Language.java

public static Map<String, String> getLanguagesForDisplay(Enumeration<Locale> locales, Locale additionalLocale) {
    SortedMap<String, String> ret = new TreeMap<>();
    for (Language t : Language.values()) {
        ret.put(t.locale.toString(), StringUtils.capitalize(t.locale.getDisplayName(t.locale)));
    }/*from w ww.  j a v a  2s. c  o  m*/
    while (locales.hasMoreElements()) {
        Locale locale = locales.nextElement();
        ret.put(locale.toString(), StringUtils.capitalize(locale.getDisplayName(locale)));
    }
    ret.put(additionalLocale.toString(),
            StringUtils.capitalize(additionalLocale.getDisplayName(additionalLocale)));
    return ret;
}

From source file:ChoiceFormatDemo.java

static void displayMessages(Locale currentLocale) {

    System.out.println("currentLocale = " + currentLocale.toString());
    System.out.println();//ww  w . j  ava  2s .  c o m

    ResourceBundle bundle = ResourceBundle.getBundle("ChoiceBundle", currentLocale);

    MessageFormat messageForm = new MessageFormat("");
    messageForm.setLocale(currentLocale);

    double[] fileLimits = { 0, 1, 2 };

    String[] fileStrings = { bundle.getString("noFiles"), bundle.getString("oneFile"),
            bundle.getString("multipleFiles") };

    ChoiceFormat choiceForm = new ChoiceFormat(fileLimits, fileStrings);

    String pattern = bundle.getString("pattern");
    Format[] formats = { choiceForm, null, NumberFormat.getInstance() };

    messageForm.applyPattern(pattern);
    messageForm.setFormats(formats);

    Object[] messageArguments = { null, "XDisk", null };

    for (int numFiles = 0; numFiles < 4; numFiles++) {
        messageArguments[0] = new Integer(numFiles);
        messageArguments[2] = new Integer(numFiles);
        String result = messageForm.format(messageArguments);
        System.out.println(result);
    }
}

From source file:com.norconex.commons.wicket.markup.html.i18n.SessionLocaleUtils.java

/**
 * Sets the locale to a cookie. //from   w w w  .ja v  a 2 s. c  om
 * @param locale session locale
 */
public static void setCookieLocale(Locale locale) {
    new CookieUtils().save(COOKIE_LOCALE_KEY, locale.toString());
}

From source file:org.opendatakit.common.android.utilities.ODKDataUtils.java

public static String getLocalizedDisplayName(Map<String, Object> localeMap) {
    Locale locale = Locale.getDefault();
    String full_locale = locale.toString();
    int underscore = full_locale.indexOf('_');
    String lang_only_locale = (underscore == -1) ? full_locale : full_locale.substring(0, underscore);

    String candidate = (String) localeMap.get(full_locale);
    if (candidate != null) {
        return candidate;
    }/*  w  ww . ja v  a 2  s  . c  o m*/
    candidate = (String) localeMap.get(lang_only_locale);
    if (candidate != null) {
        return candidate;
    }
    candidate = (String) localeMap.get("default");
    if (candidate != null) {
        return candidate;
    }
    return null;
}