Example usage for java.util Locale getDisplayName

List of usage examples for java.util Locale getDisplayName

Introduction

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

Prototype

public String getDisplayName(Locale inLocale) 

Source Link

Document

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

Usage

From source file:edu.cornell.mannlib.vitro.webapp.controller.freemarker.ViewLabelsServlet.java

private HashMap<String, String> buildLocaleMap(Locale locale, Locale currentLocale)
        throws FileNotFoundException {
    HashMap<String, String> map = new HashMap<String, String>();
    //Replacing the underscore with a hyphen because that is what is represented in the actual literals
    map.put("code", locale.toString().replace("_", "-"));
    map.put("label", locale.getDisplayName(currentLocale));
    return map;//from   w w w  . j a  v  a 2  s.c o  m
}

From source file:org.codelibs.fess.helper.SystemHelper.java

@PostConstruct
public void init() {
    final FessConfig fessConfig = ComponentUtil.getFessConfig();
    filterPathEncoding = fessConfig.getPathEncoding();
    supportedLanguages = fessConfig.getSupportedLanguagesAsArray();
    langItemsCache = CacheBuilder.newBuilder().maximumSize(20).expireAfterAccess(1, TimeUnit.HOURS)
            .build(new CacheLoader<String, List<Map<String, String>>>() {
                @Override//from  www  .j a  va 2 s  . c o m
                public List<Map<String, String>> load(final String key) throws Exception {
                    final ULocale uLocale = new ULocale(key);
                    final Locale displayLocale = uLocale.toLocale();
                    final List<Map<String, String>> langItems = new ArrayList<>(supportedLanguages.length);
                    final String msg = ComponentUtil.getMessageManager().getMessage(displayLocale,
                            "labels.allLanguages");
                    final Map<String, String> defaultMap = new HashMap<>(2);
                    defaultMap.put(Constants.ITEM_LABEL, msg);
                    defaultMap.put(Constants.ITEM_VALUE, "all");
                    langItems.add(defaultMap);

                    for (final String lang : supportedLanguages) {
                        final Locale locale = LocaleUtils.toLocale(lang);
                        final String label = locale.getDisplayName(displayLocale);
                        final Map<String, String> map = new HashMap<>(2);
                        map.put(Constants.ITEM_LABEL, label);
                        map.put(Constants.ITEM_VALUE, lang);
                        langItems.add(map);
                    }
                    return langItems;
                }
            });

    ComponentUtil.doInitProcesses(p -> p.run());

    parseProjectProperties();
}

From source file:pct.droid.dialogfragments.EpisodeDialogFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mTitle.setText(mEpisode.title);/*from  www . ja  va2s.c o  m*/
    mAired.setVisibility(mEpisode.aired > 0 ? View.VISIBLE : View.GONE);
    Date airedDate = new Date((long) mEpisode.aired * 1000);
    mAired.setText(String.format(getString(R.string.aired),
            new SimpleDateFormat("MMMM dd, yyyy", LocaleUtils.getCurrentAsLocale()).format(airedDate)));

    mSynopsis.setText(mEpisode.overview);

    String seasonStr = Integer.toString(mEpisode.season);
    if (seasonStr.length() < 2)
        seasonStr = "0" + seasonStr;
    String episodeStr = Integer.toString(mEpisode.episode);
    if (episodeStr.length() < 2)
        episodeStr = "0" + episodeStr;

    mInfo.setText("S" + seasonStr + "E" + episodeStr);

    mSubtitles.setFragmentManager(getFragmentManager());
    mQuality.setFragmentManager(getFragmentManager());
    mSubtitles.setTitle(R.string.subtitles);
    mQuality.setTitle(R.string.quality);

    final String[] qualities = mEpisode.torrents.keySet().toArray(new String[mEpisode.torrents.size()]);
    SortUtils.sortQualities(qualities);
    mQuality.setData(qualities);
    mSelectedQuality = qualities[qualities.length - 1];
    mQuality.setText(mSelectedQuality);
    mQuality.setDefault(qualities.length - 1);
    updateMagnet();

    mQuality.setListener(new OptionSelector.SelectorListener() {
        @Override
        public void onSelectionChanged(int position, String value) {
            mSelectedQuality = value;
            updateMagnet();
        }
    });

    mSubtitles.setText(R.string.loading_subs);
    mSubtitles.setClickable(false);
    if (mSubsProvider != null) {
        mSubsProvider.getList(mShow, mEpisode, new SubsProvider.Callback() {
            @Override
            public void onSuccess(Map<String, String> subtitles) {
                if (!mAttached)
                    return;

                mEpisode.subtitles = subtitles;

                String[] languages = subtitles.keySet().toArray(new String[subtitles.size()]);
                Arrays.sort(languages);
                final String[] adapterLanguages = new String[languages.length + 1];
                adapterLanguages[0] = "no-subs";
                System.arraycopy(languages, 0, adapterLanguages, 1, languages.length);

                String[] readableNames = new String[adapterLanguages.length];
                for (int i = 0; i < readableNames.length; i++) {
                    String language = adapterLanguages[i];
                    if (language.equals("no-subs")) {
                        readableNames[i] = getString(R.string.no_subs);
                    } else {
                        Locale locale = LocaleUtils.toLocale(language);
                        readableNames[i] = locale.getDisplayName(locale);
                    }
                }

                mSubtitles.setListener(new OptionSelector.SelectorListener() {
                    @Override
                    public void onSelectionChanged(int position, String value) {
                        onSubtitleLanguageSelected(adapterLanguages[position]);
                    }
                });
                mSubtitles.setData(readableNames);
                ThreadUtils.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        mSubtitles.setClickable(true);
                    }
                });

                String defaultSubtitle = PrefUtils.get(mSubtitles.getContext(), Prefs.SUBTITLE_DEFAULT, null);
                if (subtitles.containsKey(defaultSubtitle)) {
                    onSubtitleLanguageSelected(defaultSubtitle);
                    mSubtitles.setDefault(Arrays.asList(adapterLanguages).indexOf(defaultSubtitle));
                } else {
                    onSubtitleLanguageSelected("no-subs");
                    mSubtitles.setDefault(Arrays.asList(adapterLanguages).indexOf("no-subs"));
                }
            }

            @Override
            public void onFailure(Exception e) {
                mSubtitles.setData(new String[0]);
                mSubtitles.setClickable(true);
            }
        });
    } else {
        mSubtitles.setText(R.string.no_subs_available);
    }

    mScrollView.setListener(new BottomSheetScrollView.Listener() {
        @Override
        public void onScroll(int scrollY, BottomSheetScrollView.Direction direction) {
        }

        @Override
        public void onTouch(boolean touching) {
            mTouching = touching;
            int scrollY = mScrollView.getScrollY();
            if (!mTouching && mOpened && scrollY <= mThreshold) {
                smoothDismiss();
            }
        }

        @Override
        public void onScrollStart() {
        }

        @Override
        public void onScrollEnd() {
            if (!mTouching && mOpened && mScrollView.getScrollY() <= mThreshold) {
                smoothDismiss();
            }
        }
    });

    if (mMetaProvider != null) {
        mMetaProvider.getEpisodeMeta(mEpisode.imdbId, mEpisode.season, mEpisode.episode,
                new MetaProvider.Callback() {
                    @Override
                    public void onResult(MetaProvider.MetaData metaData, Exception e) {
                        String imageUrl = mEpisode.headerImage;
                        if (e == null) {
                            imageUrl = metaData.images.poster;
                        }
                        Picasso.with(mHeaderImage.getContext()).load(imageUrl).into(mHeaderImage);
                    }
                });
    } else {
        Picasso.with(mHeaderImage.getContext()).load(mEpisode.headerImage).into(mHeaderImage);
    }
}

From source file:butter.droid.fragments.dialog.EpisodeDialogFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    if (!TextUtils.isEmpty(mEpisode.title)) {
        mTitle.setText(mEpisode.title);/*from w w w . ja  v a2 s .c om*/
        mHeaderImage.setContentDescription(mEpisode.title);
    } else {
        mTitle.setText(R.string.no_title_available);
        mHeaderImage.setContentDescription(getString(R.string.no_title_available));
    }

    mAired.setVisibility(mEpisode.aired > 0 ? View.VISIBLE : View.GONE);
    Date airedDate = new Date((long) mEpisode.aired * 1000);
    mAired.setText(String.format(getString(R.string.aired),
            new SimpleDateFormat("MMMM dd, yyyy", LocaleUtils.getCurrent()).format(airedDate)));

    if (!TextUtils.isEmpty(mEpisode.overview))
        mSynopsis.setText(mEpisode.overview);
    else
        mSynopsis.setText(R.string.no_synopsis_available);

    String seasonStr = Integer.toString(mEpisode.season);
    if (seasonStr.length() < 2)
        seasonStr = "0" + seasonStr;
    String episodeStr = Integer.toString(mEpisode.episode);
    if (episodeStr.length() < 2)
        episodeStr = "0" + episodeStr;

    mInfo.setText("S" + seasonStr + "E" + episodeStr);

    mSubtitles.setFragmentManager(getFragmentManager());
    mQuality.setFragmentManager(getFragmentManager());
    mSubtitles.setTitle(R.string.subtitles);
    mQuality.setTitle(R.string.quality);

    final String[] qualities = mEpisode.torrents.keySet().toArray(new String[mEpisode.torrents.size()]);
    SortUtils.sortQualities(qualities);
    mQuality.setData(qualities);

    String quality = DefaultQuality.get(mActivity, Arrays.asList(qualities));
    int qualityIndex = Arrays.asList(qualities).indexOf(quality);
    mSelectedQuality = quality;
    mQuality.setText(mSelectedQuality);
    mQuality.setDefault(qualityIndex);

    updateMagnet();

    mQuality.setListener(new OptionSelector.SelectorListener() {
        @Override
        public void onSelectionChanged(int position, String value) {
            mSelectedQuality = value;
            updateMagnet();
        }
    });

    mSubtitles.setText(R.string.loading_subs);
    mSubtitles.setClickable(false);
    if (mSubsProvider != null) {
        mSubsProvider.getList(mEpisode, new SubsProvider.Callback() {
            @Override
            public void onSuccess(Map<String, String> subtitles) {
                if (!FragmentUtil.isAdded(EpisodeDialogFragment.this))
                    return;

                mEpisode.subtitles = subtitles;

                String[] languages = subtitles.keySet().toArray(new String[subtitles.size()]);
                Arrays.sort(languages);
                final String[] adapterLanguages = new String[languages.length + 1];
                adapterLanguages[0] = "no-subs";
                System.arraycopy(languages, 0, adapterLanguages, 1, languages.length);

                String[] readableNames = new String[adapterLanguages.length];
                for (int i = 0; i < readableNames.length; i++) {
                    String language = adapterLanguages[i];
                    if (language.equals("no-subs")) {
                        readableNames[i] = getString(R.string.no_subs);
                    } else {
                        Locale locale = LocaleUtils.toLocale(language);
                        readableNames[i] = locale.getDisplayName(locale);
                    }
                }

                mSubtitles.setListener(new OptionSelector.SelectorListener() {
                    @Override
                    public void onSelectionChanged(int position, String value) {
                        onSubtitleLanguageSelected(adapterLanguages[position]);
                    }
                });
                mSubtitles.setData(readableNames);
                ThreadUtils.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        mSubtitles.setClickable(true);
                    }
                });

                String defaultSubtitle = PrefUtils.get(mSubtitles.getContext(), Prefs.SUBTITLE_DEFAULT, null);
                if (subtitles.containsKey(defaultSubtitle)) {
                    onSubtitleLanguageSelected(defaultSubtitle);
                    mSubtitles.setDefault(Arrays.asList(adapterLanguages).indexOf(defaultSubtitle));
                } else {
                    onSubtitleLanguageSelected("no-subs");
                    mSubtitles.setDefault(Arrays.asList(adapterLanguages).indexOf("no-subs"));
                }
            }

            @Override
            public void onFailure(Exception e) {
                mSubtitles.setData(new String[0]);
                mSubtitles.setClickable(true);
            }
        });
    } else {
        mSubtitles.setText(R.string.no_subs_available);
    }

    mScrollView.setListener(new BottomSheetScrollView.Listener() {
        @Override
        public void onScroll(int scrollY, BottomSheetScrollView.Direction direction) {
        }

        @Override
        public void onTouch(boolean touching) {
            mTouching = touching;
            int scrollY = mScrollView.getScrollY();
            if (!mTouching && mOpened && scrollY <= mThreshold) {
                smoothDismiss();
            }
        }

        @Override
        public void onScrollStart() {
        }

        @Override
        public void onScrollEnd() {
            if (!mTouching && mOpened && mScrollView.getScrollY() <= mThreshold) {
                smoothDismiss();
            }
        }
    });

    if (mMetaProvider != null) {
        mMetaProvider.getEpisodeMeta(mEpisode.imdbId, mEpisode.season, mEpisode.episode,
                new MetaProvider.Callback() {
                    @Override
                    public void onResult(MetaProvider.MetaData metaData, Exception e) {
                        String imageUrl = mEpisode.headerImage;
                        if (e == null) {
                            imageUrl = metaData.images.poster;
                        }
                        Picasso.with(mHeaderImage.getContext()).load(imageUrl).into(mHeaderImage);
                    }
                });
    } else {
        Picasso.with(mHeaderImage.getContext()).load(mEpisode.headerImage).into(mHeaderImage);
    }
}

From source file:butter.droid.fragments.dialog.EpisodeDialogFragment.java

private void onSubtitleLanguageSelected(String language) {
    mSelectedSubtitleLanguage = language;
    if (!language.equals("no-subs")) {
        final Locale locale = LocaleUtils.toLocale(language);
        ThreadUtils.runOnUiThread(new Runnable() {
            @Override/* w w w  . ja  v a 2  s . com*/
            public void run() {
                mSubtitles.setText(StringUtils.uppercaseFirst(locale.getDisplayName(locale)));
            }
        });
    } else {
        ThreadUtils.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                mSubtitles.setText(R.string.no_subs);
            }
        });
    }
}

From source file:org.opencms.ui.sitemap.CmsLocaleComparePanel.java

/**
 * Initializes the locale comparison view.<p>
 *
 * @param id the structure id of the currrent sitemap root entry
 * @param initialComparisonLocale if not null, the initially selected ccomparison locale
 *
 * @throws CmsException if something goes wrong
 *//* w  w  w .  j a va 2  s  .co  m*/
public void initialize(CmsUUID id, Locale initialComparisonLocale) throws CmsException {

    removeAllComponents();
    CmsObject cms = A_CmsUI.getCmsObject();
    CmsResource res = cms.readResource(id);
    m_currentRoot = res;
    CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(res.getRootPath());

    Locale rootLocale = OpenCms.getLocaleManager().getDefaultLocale(cms, res);
    m_rootLocale = rootLocale;
    Locale mainLocale = site.getMainTranslationLocale(null);
    List<Locale> secondaryLocales = site.getSecondaryTranslationLocales();

    List<Locale> possibleLocaleSelections = getMainLocaleSelectOptions(cms, res, mainLocale, secondaryLocales);
    m_rootLocaleSelector = new ComboBox();
    m_rootLocaleSelector.addStyleName("o-sitemap-localeselect");
    m_rootLocaleSelector.setNullSelectionAllowed(false);
    for (Locale selectableLocale : possibleLocaleSelections) {
        m_rootLocaleSelector.addItem(selectableLocale);
        m_rootLocaleSelector.setItemIcon(selectableLocale, FontOpenCms.SPACE);
        m_rootLocaleSelector.setItemCaption(selectableLocale,
                selectableLocale.getDisplayName(A_CmsUI.get().getLocale()));
    }
    m_rootLocaleSelector.setItemIcon(mainLocale, MAIN_LOCALE_ICON);
    m_rootLocaleSelector.setValue(m_rootLocale);
    m_rootLocaleSelector.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        @SuppressWarnings("synthetic-access")
        public void valueChange(ValueChangeEvent event) {

            if (!m_handlingLocaleChange) {
                m_handlingLocaleChange = true;
                try {
                    Locale newLocale = (Locale) (event.getProperty().getValue());
                    switchToLocale(newLocale);
                } catch (Exception e) {
                    LOG.error(e.getLocalizedMessage(), e);
                    CmsErrorDialog.showErrorDialog(e);
                } finally {
                    m_handlingLocaleChange = false;
                }
            }
        }
    });

    m_comparisonLocaleSelector = new ComboBox();
    m_comparisonLocaleSelector.addStyleName("o-sitemap-localeselect");
    m_comparisonLocaleSelector.setNullSelectionAllowed(false);

    List<Locale> comparisonLocales = getComparisonLocales();
    Locale selectedComparisonLocale = null;
    for (Locale comparisonLocale : comparisonLocales) {
        m_comparisonLocaleSelector.addItem(comparisonLocale);
        m_comparisonLocaleSelector.setItemIcon(comparisonLocale, FontOpenCms.SPACE);
        m_comparisonLocaleSelector.setItemCaption(comparisonLocale,
                comparisonLocale.getDisplayName(A_CmsUI.get().getLocale()));
        if ((selectedComparisonLocale == null) && !comparisonLocale.equals(m_rootLocale)) {
            selectedComparisonLocale = comparisonLocale;
        }
        if ((initialComparisonLocale != null) && comparisonLocale.equals(initialComparisonLocale)
                && !comparisonLocale.equals(m_rootLocale)) {
            // if an initial comparison locale is given, it should have priority over the first comparison locale
            selectedComparisonLocale = comparisonLocale;
        }

    }
    m_comparisonLocale = selectedComparisonLocale;
    m_comparisonLocaleSelector.setValue(selectedComparisonLocale);
    m_comparisonLocaleSelector.setItemIcon(mainLocale, MAIN_LOCALE_ICON);

    m_comparisonLocaleSelector.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        @SuppressWarnings("synthetic-access")
        public void valueChange(ValueChangeEvent event) {

            if (!m_handlingLocaleChange) {
                m_handlingLocaleChange = true;
                try {
                    Locale locale = (Locale) (event.getProperty().getValue());
                    if (m_rootLocale.equals(locale)) {
                        Locale oldComparisonLocale = m_comparisonLocale;
                        if (getLocaleGroup().getResourcesByLocale().keySet().contains(oldComparisonLocale)) {
                            m_comparisonLocale = locale;
                            switchToLocale(oldComparisonLocale);
                            updateLocaleWidgets();
                        } else {
                            Notification.show(CmsVaadinUtils.getMessageText(
                                    Messages.GUI_LOCALECOMPARE_CANNOT_SWITCH_COMPARISON_LOCALE_0));
                            m_comparisonLocaleSelector.setValue(oldComparisonLocale);
                        }
                    } else {
                        m_comparisonLocale = locale;
                        updateLocaleWidgets();
                        initTree(m_currentRoot);
                    }

                } catch (Exception e) {
                    LOG.error(e.getLocalizedMessage(), e);
                    CmsErrorDialog.showErrorDialog(e);
                } finally {
                    m_handlingLocaleChange = false;
                }
            }
        }
    });

    CssLayout localeSelectors = new CssLayout();
    localeSelectors.addStyleName(OpenCmsTheme.SITEMAP_LOCALE_BAR);

    m_rootLocaleSelector.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_LOCALECOMPARE_MAIN_LOCALE_0));
    m_comparisonLocaleSelector
            .setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_LOCALECOMPARE_COMPARISON_LOCALE_0));

    localeSelectors.setWidth("100%");
    localeSelectors.addComponent(m_rootLocaleSelector);
    localeSelectors.addComponent(m_comparisonLocaleSelector);
    // localeSelectors.setComponentAlignment(wrapper2, Alignment.MIDDLE_RIGHT);

    setSpacing(true);
    addComponent(localeSelectors);
    addComponent(m_treeContainer);
    m_treeContainer.setWidth("100%");
    initTree(res);
}

From source file:com.jecelyin.editor.v2.core.text.TextUtils.java

/**
 * Fallback algorithm to detect the locale direction. Rely on the fist char of the
 * localized locale name. This will not work if the localized locale name is in English
 * (this is the case for ICU 4.4 and "Urdu" script)
 *
 * @param locale/*  w  w  w.jav  a 2s. c o m*/
 * @return the layout direction. This may be one of:
 * {@link android.view.View#LAYOUT_DIRECTION_LTR} or
 * {@link android.view.View#LAYOUT_DIRECTION_RTL}.
 *
 * Be careful: this code will need to be updated when vertical scripts will be supported
 *
 * @hide
 */
private static int getLayoutDirectionFromFirstChar(Locale locale) {
    switch (Character.getDirectionality(locale.getDisplayName(locale).charAt(0))) {
    case Character.DIRECTIONALITY_RIGHT_TO_LEFT:
    case Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:
        return View.LAYOUT_DIRECTION_RTL;

    case Character.DIRECTIONALITY_LEFT_TO_RIGHT:
    default:
        return View.LAYOUT_DIRECTION_LTR;
    }
}

From source file:pct.droid.fragments.BaseVideoPlayerFragment.java

public void subsClick() {
    if (mMedia != null && mMedia.subtitles != null) {
        if (getFragmentManager().findFragmentByTag("overlay_fragment") != null)
            return;
        String[] subtitles = mMedia.subtitles.keySet().toArray(new String[mMedia.subtitles.size()]);
        Arrays.sort(subtitles);/*from w  w w  . ja  v  a  2 s  . com*/
        final String[] adapterSubtitles = new String[subtitles.length + 2];
        System.arraycopy(subtitles, 0, adapterSubtitles, 1, subtitles.length);

        adapterSubtitles[0] = "no-subs";
        adapterSubtitles[adapterSubtitles.length - 1] = "custom";
        String[] readableNames = new String[adapterSubtitles.length];

        for (int i = 0; i < readableNames.length - 1; i++) {
            String language = adapterSubtitles[i];
            if (language.equals("no-subs")) {
                readableNames[i] = getString(R.string.no_subs);
            } else {
                Locale locale = LocaleUtils.toLocale(language);
                readableNames[i] = locale.getDisplayName(locale);
            }
        }

        readableNames[readableNames.length - 1] = "Custom..";

        StringArraySelectorDialogFragment.showSingleChoice(getFragmentManager(), R.string.subtitles,
                readableNames, Arrays.asList(adapterSubtitles).indexOf(mCurrentSubsLang),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(final DialogInterface dialog, int position) {
                        if (position == adapterSubtitles.length - 1) {
                            FileSelectorDialogFragment.show(getChildFragmentManager(),
                                    new FileSelectorDialogFragment.Listener() {
                                        @Override
                                        public void onFileSelected(File f) {
                                            if (!f.getPath().endsWith(".srt")) {
                                                Toast.makeText(getActivity(), R.string.unknown_error,
                                                        Toast.LENGTH_SHORT).show();
                                                return;
                                            }
                                            FileSelectorDialogFragment.hide();
                                            mSubsFile = f;
                                            startSubtitles();
                                            dialog.dismiss();
                                        }
                                    });
                            return;
                        }
                        onSubtitleLanguageSelected(adapterSubtitles[position]);
                        dialog.dismiss();
                    }
                });
    }
}

From source file:unikn.dbis.univis.explorer.VExplorer.java

License:asdf

private void makeLanguageMenu() {

    german.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Locale locale = Locale.GERMAN;
            MessageResolver.setLocale(locale);
            whatLanguageLabel.setText(locale.getDisplayName(locale));
            ComponentUtilities.repaintComponentTree(VExplorer.this);
        }/* w ww .j  a  va2 s .  co m*/
    });

    english.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Locale locale = Locale.ENGLISH;
            MessageResolver.setLocale(locale);
            whatLanguageLabel.setText(locale.getDisplayName(locale));
            ComponentUtilities.repaintComponentTree(VExplorer.this);
        }
    });

    newLanguage.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(VExplorer.this.getContentPane(), languageMessage, languageTitle, 1);
        }
    });

    final ButtonGroup languageGroup = new ButtonGroup();
    german.setSelected(true);
    languageGroup.add(german);
    languageGroup.add(english);
    languageMenu.add(german);
    languageMenu.add(english);
    languageMenu.add(newLanguage);
}

From source file:org.glom.web.server.ConfiguredDocument.java

/**
 * @return//  w  w w. j  a v a2 s. com
 */
DocumentInfo getDocumentInfo(final String localeID) {
    final DocumentInfo documentInfo = new DocumentInfo();

    // get arrays of table names and titles, and find the default table index
    final List<String> tablesVec = document.getTableNames();

    final int numTables = Utils.safeLongToInt(tablesVec.size());
    // we don't know how many tables will be hidden so we'll use half of the number of tables for the default size
    // of the ArrayList
    final ArrayList<String> tableNames = new ArrayList<String>(numTables / 2);
    final ArrayList<String> tableTitles = new ArrayList<String>(numTables / 2);
    boolean foundDefaultTable = false;
    int visibleIndex = 0;
    for (int i = 0; i < numTables; i++) {
        final String tableName = tablesVec.get(i);
        if (!document.getTableIsHidden(tableName)) {
            tableNames.add(tableName);

            //The comparison will only be called if we haven't already found the default table
            if (!foundDefaultTable && tableName.equals(document.getDefaultTable())) {
                documentInfo.setDefaultTableIndex(visibleIndex);
                foundDefaultTable = true;
            }
            tableTitles.add(document.getTableTitle(tableName, localeID));
            visibleIndex++;
        }
    }

    // set everything we need
    documentInfo.setTableNames(tableNames);
    documentInfo.setTableTitles(tableTitles);
    documentInfo.setTitle(document.getDatabaseTitle(localeID));

    // Fetch arrays of locale IDs and titles:
    final List<String> localesVec = document.getTranslationAvailableLocales();
    final int numLocales = Utils.safeLongToInt(localesVec.size());
    final ArrayList<String> localeIDs = new ArrayList<String>(numLocales);
    final ArrayList<String> localeTitles = new ArrayList<String>(numLocales);
    for (int i = 0; i < numLocales; i++) {
        final String this_localeID = localesVec.get(i);
        localeIDs.add(this_localeID);

        // Use java.util.Locale to get a title for the locale:
        final String[] locale_parts = this_localeID.split("_");
        String locale_lang = this_localeID;
        if (locale_parts.length > 0) {
            locale_lang = locale_parts[0];
        }
        String locale_country = "";
        if (locale_parts.length > 1) {
            locale_country = locale_parts[1];
        }

        final Locale locale = new Locale(locale_lang, locale_country);
        final String title = locale.getDisplayName(locale);
        localeTitles.add(title);
    }
    documentInfo.setLocaleIDs(localeIDs);
    documentInfo.setLocaleTitles(localeTitles);

    return documentInfo;
}