List of usage examples for java.util Locale getDisplayCountry
public final String getDisplayCountry()
From source file:org.sisto.jeeplate.jsf.Oracle.java
@PostConstruct public void init() { this.populateTimezones(); this.populateCountries(); this.populateLanguages(); for (String lang : supportedLanguages) { Locale systemLocale = new Locale(lang); this.systemLanguages.put(systemLocale.getDisplayCountry(), lang); }//from w w w. j av a 2s .com }
From source file:org.mifos.config.Localization.java
public String getDisplayName(Short localeId) { Locale locale = LOCALE_MAP.get(localeId); String country = locale.getDisplayCountry(); if (StringUtils.isBlank(country)) { return locale.getDisplayLanguage() + " - (" + locale.getDisplayLanguage(locale) + ") [" + locale + "]"; }/*from w ww . j av a 2 s. c o m*/ return locale.getDisplayLanguage() + " - (" + locale.getDisplayLanguage(locale) + ") : " + country + " [" + locale + "]"; }
From source file:com.baruckis.nanodegree.spotifystreamer.fragments.SettingsFragment.java
private void updateCountryListPreferenceSummary(String country) { Locale locale = new Locale("", country); mCountryListPreference.setSummary(locale.getDisplayCountry()); }
From source file:org.jspringbot.keyword.i18n.I18nHelper.java
public void setLocale(String localeID) { LOG.keywordAppender().appendProperty("Locale ID", localeID); Locale locale = I18nUtil.getLocaleFromString(localeID); LocaleContextHolder.setLocale(locale); if (StringUtils.isNotBlank(locale.getDisplayCountry())) { LOG.keywordAppender().appendProperty("Display Country", locale.getDisplayCountry()); }//from w ww .j av a 2s. c o m if (StringUtils.isNotBlank(locale.getDisplayLanguage())) { LOG.keywordAppender().appendProperty("Display Language", locale.getDisplayLanguage()); } }
From source file:org.glucosio.android.activity.HelloActivity.java
private void initCountrySpinner(final LocaleHelper localeHelper) { // Get countries list from locale ArrayList<String> countries = new ArrayList<>(); Locale[] locales = Locale.getAvailableLocales(); for (Locale locale : locales) { String country = locale.getDisplayCountry(); if ((country.trim().length() > 0) && (!countries.contains(country))) { countries.add(country);/*from w w w .ja v a2 s . c o m*/ } } Collections.sort(countries); // Populate Spinners with array countrySpinner.setItemsArray(countries); // Get locale country name and set the spinner String localCountry = localeHelper.getDeviceLocale().getDisplayCountry(); setSelection(localCountry, countrySpinner); }
From source file:mo.iguideu.ui.initGuideProfile.FragmentInitGuideDataStep2.java
private void initMoreLanguageSpinner() { String languages = getResources().getString(R.string.spinner_choose_more_language) + ","; int idx = 0;// w w w.ja va 2 s . c om for (Locale locale : supportLocale) { languages += locale.getDisplayCountry() + "-" + locale.getDisplayLanguage() + ((idx == supportLocale.size() - 1) ? "" : ","); idx++; } String[] langArray = languages.split(","); ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, langArray); spinnerMoreLang.setAdapter(adapter); spinnerMoreLang.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (position == 0) return; if (layoutInflater == null) return; //-1 cause first element is choose more Locale selectedLocale = supportLocale.get(position - 1); String selectString = spinnerMoreLang.getSelectedItem().toString(); String langCode = selectedLocale.getLanguage() + "_" + selectedLocale.getCountry(); //Avoid select repeat for (int i = 0; i < scrollContainer.getChildCount(); i++) { View langChkView = scrollContainer.getChildAt(i); if (langChkView.getTag().toString().equals(langCode)) { //Language already selected, break; return; } } View itemLanguage = layoutInflater.inflate(R.layout.item_chk_language, scrollContainer, false); itemLanguage.setTag(langCode); CheckBox chkBox = (CheckBox) itemLanguage.findViewById(R.id.lang_chk); chkBox.setChecked(true); TextView countryName = (TextView) itemLanguage.findViewById(R.id.item_chk_lang_txt_country_name); countryName.setText(selectString); // ImageView flag = (ImageView) itemLanguage.findViewById(R.id.item_chk_lang_img_flag_tw); scrollContainer.addView(itemLanguage); scrollViewLangs.scrollTo(0, scrollViewLangs.getBottom()); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); }
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 ava2 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(); }
From source file:org.jspringbot.keyword.i18n.I18nHelper.java
public String getMessage(String code) { Locale locale = getLocale(); LOG.keywordAppender().appendProperty("Message Code", code).appendProperty("Locale ID", locale.toString()); if (StringUtils.isNotBlank(locale.getDisplayCountry())) { LOG.keywordAppender().appendProperty("Display Country", locale.getDisplayCountry()); }/* w w w.j a v a2 s .co m*/ if (StringUtils.isNotBlank(locale.getDisplayLanguage())) { LOG.keywordAppender().appendProperty("Display Language", locale.getDisplayLanguage()); } String message = messages.getMessage(code); LOG.keywordAppender().appendProperty("Message Value", message); return message; }
From source file:com.claude.sharecam.util.CountryMaster.java
/** * Returns the full name of the country/*from w w w. j a v a 2 s . com*/ * * @param isoCode String * @return String */ private String getCountryName(String isoCode) { Locale locale = new Locale(Locale.getDefault().getDisplayLanguage(), isoCode); return locale.getDisplayCountry().trim(); }
From source file:com.baruckis.nanodegree.spotifystreamer.fragments.SettingsFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); // Getting preferences from the preference resource. mCountryListPreference = (ListPreference) getPreferenceManager() .findPreference(getString(R.string.list_preference_country_code_key)); mNotificationSwitchPreference = (SwitchPreference) getPreferenceManager() .findPreference(getString(R.string.switch_preference_notification_key)); Preference sourcePreference = getPreferenceManager() .findPreference(getString(R.string.preference_source_key)); Preference authorPreference = getPreferenceManager() .findPreference(getString(R.string.preference_author_key)); Preference licencePreference = getPreferenceManager() .findPreference(getString(R.string.preference_licence_key)); Preference versionPreference = getPreferenceManager() .findPreference(getString(R.string.preference_version_key)); // Setting up to display a list of countries List<String> countriesCodesList = new ArrayList<String>(); List<String> countriesNamesList = new ArrayList<String>(); String[] countries = Locale.getISOCountries(); // will return a list of all 2-letter country codes defined in ISO 3166 for (String countryCode : countries) { Locale locale = new Locale("", countryCode); countriesCodesList.add(locale.getCountry()); countriesNamesList.add(locale.getDisplayCountry()); }/*from w w w.j av a 2 s . c o m*/ final CharSequence[] countriesCodes = countriesCodesList .toArray(new CharSequence[countriesCodesList.size()]); final CharSequence[] countriesNames = countriesNamesList .toArray(new CharSequence[countriesNamesList.size()]); mCountryListPreference.setEntryValues(countriesCodes); mCountryListPreference.setEntries(countriesNames); mCountryListPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { updateCountryListPreferenceSummary((String) newValue); return true; } }); // set initial default country if (mCountryListPreference.getValue() == null) { mCountryListPreference.setValue(Locale.getDefault().getCountry()); } updateCountryListPreferenceSummary(mCountryListPreference.getValue()); mNotificationSwitchPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { ((SwitchPreference) preference).setChecked((boolean) newValue); updateNotificationSwitchPreferenceIcon(); // When notification visibility is changed, inform service immediately to show or stop showing notification. Intent notificationIntent = new Intent(PlayerService.RECEIVE_BROADCAST_INTENT_NOTIFICATION); notificationIntent.putExtra(PlayerService.RECEIVE_BROADCAST_INTENT_NOTIFICATION, (boolean) newValue); LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(notificationIntent); return true; } }); updateNotificationSwitchPreferenceIcon(); // on source preference click open web browser with the url link sourcePreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { String url = getString(R.string.preference_source_url); Intent viewIntent = new Intent(Intent.ACTION_VIEW); viewIntent.setData(Uri.parse(url)); startActivity(viewIntent); return true; } }); // on author preference click open web browser with the url link authorPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { String url = getString(R.string.preference_author_url); Intent viewIntent = new Intent(Intent.ACTION_VIEW); viewIntent.setData(Uri.parse(url)); startActivity(viewIntent); return true; } }); // on licence preference click open fragment dialog with the message licencePreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { MessageDialogFragment .newInstance(R.drawable.ic_certificate_grey600_36dp, getString(R.string.licence_title), getString(R.string.licence_body, getString(R.string.app_name), Utils.getAppVersionNumber(getActivity()))) .show(getFragmentManager(), MessageDialogFragment.TAG); return true; } }); // setting app version number String version = getString(R.string.preference_version_summary) + Utils.getAppVersionNumber(getActivity()); versionPreference.setSummary(version); }