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:org.megam.api.http.TransportResponse.java

public TransportResponse(StatusLine tempStatus, HttpEntity tempEntity, Locale tempLocale)
        throws ParseException, IOException {
    entity = EntityUtils.toString(tempEntity);
    status = tempStatus.toString();/*from  w  w  w . j a  va2s  .  co m*/
    locale = tempLocale.getDisplayCountry() + ":" + tempLocale.getDisplayLanguage();
}

From source file:de.skubware.opentraining.activity.create_exercise.NameFragment.java

public NameFragment() {
    super(R.layout.fragment_create_exercise_name);

    // set up language c spinnner
    mLanguageCodeMap = new HashMap<String, String>();
    Set<String> localeStringSet = new TreeSet<String>();
    for (Locale l : Locale.getAvailableLocales()) {
        if (localeStringSet.add(l.getDisplayLanguage())) {
            mLanguageCodeMap.put(l.getDisplayLanguage(), l.getLanguage());
        }/*w w w.j av a2  s.  c o  m*/
    }

    mSpinnerDataList = new ArrayList<String>(localeStringSet);
}

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;//from   w w w  .  ja v a  2  s .c  o m
    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.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 + "]";
    }//ww  w  .ja v  a2 s .  c  o  m
    return locale.getDisplayLanguage() + " - (" + locale.getDisplayLanguage(locale) + ") : " + country + " ["
            + locale + "]";
}

From source file:com.trenako.web.tags.LocalizedTextAreaTags.java

private String labelMessage(Locale locale) throws JspException {
    String code = getBindStatus().getPath() + ".local.label";
    return getMessageSource().getMessage(code, new Object[] { locale.getDisplayLanguage() }, code,
            getRequestContext().getLocale());
}

From source file:org.pdfsam.context.DefaultI18nContext.java

private DefaultI18nContext() {
    Locale locale = getBestLocale();
    LOG.trace("Loading i18n bundle for {}", locale);
    Locale.setDefault(locale);//from  w w  w  .j  a v  a  2 s  .  c  o m
    this.i18n = I18nFactory.getI18n(DefaultI18nContext.class, locale);
    LOG.debug("Locale set to {}", locale.getDisplayLanguage());
}

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 ww w . j  a va  2  s  .c  om*/
    if (StringUtils.isNotBlank(locale.getDisplayLanguage())) {
        LOG.keywordAppender().appendProperty("Display Language", locale.getDisplayLanguage());
    }
}

From source file:org.cee.service.language.LanguageService.java

public LanguageList getSupportedLanguages() {
    List<String> langIds = searchService.getSupportedLanguages();
    if (langIds == null) {
        //search service does not support languages at all, provide user with full list of languages
        langIds = Arrays.asList(Locale.getISOLanguages());
    }/*from  w  w  w.  j a  v  a 2s .  c om*/
    List<EntityKey> languages = new ArrayList<EntityKey>();
    int defaultLanguageIndex = 0;
    String defaultLanguage = "en";
    Locale currentUserLocale = LocaleContextHolder.getLocaleContext().getLocale();
    if (currentUserLocale != null) {
        defaultLanguage = currentUserLocale.getLanguage();
    }
    for (String langId : langIds) {
        Locale locale = Locale.forLanguageTag(langId);
        if (locale != null) {
            if (locale.getLanguage().startsWith(defaultLanguage)
                    || defaultLanguage.startsWith(locale.getLanguage())) {
                defaultLanguageIndex = languages.size();
            }
            languages.add(EntityKey.get(locale.getDisplayLanguage(), langId));
        } else {
            languages.add(EntityKey.get(langId, langId));
        }
    }
    LanguageList languageList = new LanguageList();
    languageList.setLanguages(languages);
    languageList.setDefaultLanguage(defaultLanguageIndex);
    return languageList;
}

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 .  ja  v a2s  . 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.ffmpegtest.VideoActivity.java

@Override
public void onFFDataSourceLoaded(FFmpegError err, FFmpegStreamInfo[] streams) {
    if (err != null) {
        String format = getResources().getString(R.string.main_could_not_open_stream);
        String message = String.format(format, err.getMessage());

        Builder builder = new AlertDialog.Builder(VideoActivity.this);
        builder.setTitle(R.string.app_name).setMessage(message)
                .setOnCancelListener(new DialogInterface.OnCancelListener() {

                    @Override//  w  ww . j a va 2  s . c  om
                    public void onCancel(DialogInterface dialog) {
                        VideoActivity.this.finish();
                    }
                }).show();
        return;
    }
    mPlayPauseButton.setBackgroundResource(android.R.drawable.ic_media_play);
    mPlayPauseButton.setEnabled(true);
    this.mControlsView.setVisibility(View.VISIBLE);
    this.mStreamsView.setVisibility(View.VISIBLE);
    this.mLoadingView.setVisibility(View.GONE);
    this.mVideoView.setVisibility(View.VISIBLE);
    MatrixCursor audio = new MatrixCursor(PROJECTION);
    MatrixCursor subtitles = new MatrixCursor(PROJECTION);
    subtitles.addRow(new Object[] { "None", FFmpegPlayer.NO_STREAM });
    for (FFmpegStreamInfo streamInfo : streams) {
        CodecType mediaType = streamInfo.getMediaType();
        Locale locale = streamInfo.getLanguage();
        String languageName = locale == null ? getString(R.string.unknown) : locale.getDisplayLanguage();
        if (FFmpegStreamInfo.CodecType.AUDIO.equals(mediaType)) {
            audio.addRow(new Object[] { languageName, streamInfo.getStreamNumber() });
        } else if (FFmpegStreamInfo.CodecType.SUBTITLE.equals(mediaType)) {
            subtitles.addRow(new Object[] { languageName, streamInfo.getStreamNumber() });
        }
    }
    mLanguageAdapter.swapCursor(audio);
    mSubtitleAdapter.swapCursor(subtitles);
}