List of usage examples for java.util Locale getDisplayName
public String getDisplayName(Locale inLocale)
From source file:com.erudika.scoold.controllers.TranslateController.java
@GetMapping({ "/{locale}", "/{locale}/{index}" }) public String translate(@PathVariable String locale, @PathVariable(required = false) String index, HttpServletRequest req, Model model) { Locale showLocale = utils.getLangutils().getProperLocale(locale); if (showLocale == null || "en".equals(showLocale.getLanguage())) { // can't translate default language return "redirect:" + LANGUAGESLINK; }// ww w. j ava 2 s . c om int showIndex = -1; List<Translation> translationslist = Collections.emptyList(); Pager itemcount = utils.getPager("page", req); if (!StringUtils.isBlank(index)) { showIndex = getIndex(index, langkeys); // this is what is currently shown for translation translationslist = utils.getLangutils().readAllTranslationsForKey(showLocale.getLanguage(), langkeys.get(showIndex), itemcount); } String title = utils.getLang(req).get("translate.title") + " - " + showLocale.getDisplayName(showLocale); int showLocaleProgress = utils.getLangutils().getTranslationProgressMap().get(showLocale.getLanguage()); model.addAttribute("path", "translate.vm"); model.addAttribute("title", title); model.addAttribute("showIndex", showIndex); model.addAttribute("showLocale", showLocale); model.addAttribute("langkeys", langkeys); model.addAttribute("deflang", deflang); model.addAttribute("showLocaleProgress", showLocaleProgress); model.addAttribute("translationslist", translationslist); model.addAttribute("itemcount", itemcount); return "base"; }
From source file:butter.droid.base.fragments.BaseVideoPlayerFragment.java
private void subsLanguageSettings() { String[] subtitles = mMedia.subtitles.keySet().toArray(new String[mMedia.subtitles.size()]); Arrays.sort(subtitles);/*from w ww. j a va 2 s. c o m*/ final String[] adapterSubtitles = new String[subtitles.length + 2]; System.arraycopy(subtitles, 0, adapterSubtitles, 1, subtitles.length); adapterSubtitles[0] = SubsProvider.SUBTITLE_LANGUAGE_NONE; 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(SubsProvider.SUBTITLE_LANGUAGE_NONE)) { 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(getChildFragmentManager(), 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")) { Snackbar.make(mRootView, R.string.unknown_error, Snackbar.LENGTH_SHORT).show(); return; } FileSelectorDialogFragment.hide(); mSubsFile = f; dialog.dismiss(); } }); return; } onSubtitleLanguageSelected(adapterSubtitles[position]); dialog.dismiss(); } }); }
From source file:paulscode.android.mupen64plusae.persistent.UserPrefs.java
/** * Instantiates a new user preferences wrapper. * // www .j av a 2 s . c o m * @param context The application context. */ @SuppressWarnings("deprecation") @SuppressLint("InlinedApi") @TargetApi(17) public UserPrefs(Context context) { AppData appData = new AppData(context); mPreferences = PreferenceManager.getDefaultSharedPreferences(context); // Locale mLocaleCode = mPreferences.getString(KEY_LOCALE_OVERRIDE, DEFAULT_LOCALE_OVERRIDE); mLocale = TextUtils.isEmpty(mLocaleCode) ? Locale.getDefault() : createLocale(mLocaleCode); Locale[] availableLocales = Locale.getAvailableLocales(); String[] values = context.getResources().getStringArray(R.array.localeOverride_values); String[] entries = new String[values.length]; for (int i = values.length - 1; i > 0; i--) { Locale locale = createLocale(values[i]); // Get intersection of languages (available on device) and (translated for Mupen) if (ArrayUtils.contains(availableLocales, locale)) { // Get the name of the language, as written natively entries[i] = WordUtils.capitalize(locale.getDisplayName(locale)); } else { // Remove the item from the list entries = (String[]) ArrayUtils.remove(entries, i); values = (String[]) ArrayUtils.remove(values, i); } } entries[0] = context.getString(R.string.localeOverride_entrySystemDefault); mLocaleNames = entries; mLocaleCodes = values; // Files userDataDir = mPreferences.getString("pathGameSaves", ""); galleryDataDir = userDataDir + "/GalleryData"; profilesDir = userDataDir + "/Profiles"; crashLogDir = userDataDir + "/CrashLogs"; coreUserDataDir = userDataDir + "/CoreConfig/UserData"; coreUserCacheDir = userDataDir + "/CoreConfig/UserCache"; hiResTextureDir = coreUserDataDir + "/mupen64plus/hires_texture/"; // MUST match what rice assumes natively romInfoCache_cfg = galleryDataDir + "/romInfoCache.cfg"; controllerProfiles_cfg = profilesDir + "/controller.cfg"; touchscreenProfiles_cfg = profilesDir + "/touchscreen.cfg"; emulationProfiles_cfg = profilesDir + "/emulation.cfg"; customCheats_txt = profilesDir + "/customCheats.txt"; // Plug-ins audioPlugin = new Plugin(mPreferences, appData.libsDir, "audioPlugin"); // Touchscreen prefs isTouchscreenFeedbackEnabled = mPreferences.getBoolean("touchscreenFeedback", false); touchscreenRefresh = getSafeInt(mPreferences, "touchscreenRefresh", 0); touchscreenScale = ((float) mPreferences.getInt("touchscreenScale", 100)) / 100.0f; touchscreenTransparency = (255 * mPreferences.getInt("touchscreenTransparency", 100)) / 100; touchscreenSkin = appData.touchscreenSkinsDir + "/" + mPreferences.getString("touchscreenStyle", "Outline"); touchscreenAutoHold = getSafeInt(mPreferences, "touchscreenAutoHold", 0); // Xperia PLAY touchpad prefs isTouchpadEnabled = appData.hardwareInfo.isXperiaPlay && mPreferences.getBoolean("touchpadEnabled", true); isTouchpadFeedbackEnabled = mPreferences.getBoolean("touchpadFeedback", false); touchpadSkin = appData.touchpadSkinsDir + "/Xperia-Play"; ConfigFile touchpad_cfg = new ConfigFile(appData.touchpadProfiles_cfg); ConfigSection section = touchpad_cfg.get(mPreferences.getString("touchpadLayout", "")); if (section != null) touchpadProfile = new Profile(true, section); else touchpadProfile = null; // Video prefs displayOrientation = getSafeInt(mPreferences, "displayOrientation", 0); displayPosition = getSafeInt(mPreferences, "displayPosition", Gravity.CENTER_VERTICAL); int transparencyPercent = mPreferences.getInt("displayActionBarTransparency", 50); displayActionBarTransparency = (255 * transparencyPercent) / 100; displayFpsRefresh = getSafeInt(mPreferences, "displayFpsRefresh", 0); isFpsEnabled = displayFpsRefresh > 0; videoHardwareType = getSafeInt(mPreferences, "videoHardwareType", -1); videoPolygonOffset = SafeMethods.toFloat(mPreferences.getString("videoPolygonOffset", "-0.2"), -0.2f); isImmersiveModeEnabled = mPreferences.getBoolean("displayImmersiveMode", false); // Audio prefs audioSwapChannels = mPreferences.getBoolean("audioSwapChannels", false); audioSecondaryBufferSize = getSafeInt(mPreferences, "audioBufferSize", 2048); if (audioPlugin.enabled) isFramelimiterEnabled = mPreferences.getBoolean("audioSynchronize", true); else isFramelimiterEnabled = !mPreferences.getString("audioPlugin", "").equals("nospeedlimit"); // User interface modes String navMode = mPreferences.getString("navigationMode", "auto"); if (navMode.equals("bigscreen")) isBigScreenMode = true; else if (navMode.equals("standard")) isBigScreenMode = false; else isBigScreenMode = AppData.IS_OUYA_HARDWARE; // TODO: Add other systems as they enter market isActionBarAvailable = AppData.IS_HONEYCOMB && !isBigScreenMode; // Peripheral share mode isControllerShared = mPreferences.getBoolean("inputShareController", false); // Determine the key codes that should not be mapped to controls boolean volKeysMappable = mPreferences.getBoolean("inputVolumeMappable", false); List<Integer> unmappables = new ArrayList<Integer>(); unmappables.add(KeyEvent.KEYCODE_MENU); if (AppData.IS_HONEYCOMB) { // Back key is needed to show/hide the action bar in HC+ unmappables.add(KeyEvent.KEYCODE_BACK); } if (!volKeysMappable) { unmappables.add(KeyEvent.KEYCODE_VOLUME_UP); unmappables.add(KeyEvent.KEYCODE_VOLUME_DOWN); unmappables.add(KeyEvent.KEYCODE_VOLUME_MUTE); } unmappableKeyCodes = Collections.unmodifiableList(unmappables); // Determine the pixel dimensions of the rendering context and view surface { // Screen size final WindowManager windowManager = (WindowManager) context .getSystemService(android.content.Context.WINDOW_SERVICE); Display display = windowManager.getDefaultDisplay(); int stretchWidth; int stretchHeight; if (display == null) { stretchWidth = stretchHeight = 0; } else if (AppData.IS_KITKAT && isImmersiveModeEnabled) { DisplayMetrics metrics = new DisplayMetrics(); display.getRealMetrics(metrics); stretchWidth = metrics.widthPixels; stretchHeight = metrics.heightPixels; } else { stretchWidth = display.getWidth(); stretchHeight = display.getHeight(); } float aspect = 0.75f; // TODO: Handle PAL boolean isLetterboxed = ((float) stretchHeight / (float) stretchWidth) > aspect; int zoomWidth = isLetterboxed ? stretchWidth : Math.round((float) stretchHeight / aspect); int zoomHeight = isLetterboxed ? Math.round((float) stretchWidth * aspect) : stretchHeight; int cropWidth = isLetterboxed ? Math.round((float) stretchHeight / aspect) : stretchWidth; int cropHeight = isLetterboxed ? stretchHeight : Math.round((float) stretchWidth * aspect); int hResolution = getSafeInt(mPreferences, "displayResolution", 0); String scaling = mPreferences.getString("displayScaling", "zoom"); if (hResolution == 0) { // Native resolution if (scaling.equals("stretch")) { videoRenderWidth = videoSurfaceWidth = stretchWidth; videoRenderHeight = videoSurfaceHeight = stretchHeight; } else if (scaling.equals("crop")) { videoRenderWidth = videoSurfaceWidth = cropWidth; videoRenderHeight = videoSurfaceHeight = cropHeight; } else // scaling.equals( "zoom") || scaling.equals( "none" ) { videoRenderWidth = videoSurfaceWidth = zoomWidth; videoRenderHeight = videoSurfaceHeight = zoomHeight; } } else { // Non-native resolution switch (hResolution) { case 720: videoRenderWidth = 960; videoRenderHeight = 720; break; case 600: videoRenderWidth = 800; videoRenderHeight = 600; break; case 480: videoRenderWidth = 640; videoRenderHeight = 480; break; case 360: videoRenderWidth = 480; videoRenderHeight = 360; break; case 240: videoRenderWidth = 320; videoRenderHeight = 240; break; case 120: videoRenderWidth = 160; videoRenderHeight = 120; break; default: videoRenderWidth = Math.round((float) hResolution / aspect); videoRenderHeight = hResolution; break; } if (scaling.equals("zoom")) { videoSurfaceWidth = zoomWidth; videoSurfaceHeight = zoomHeight; } else if (scaling.equals("crop")) { videoSurfaceWidth = cropWidth; videoSurfaceHeight = cropHeight; } else if (scaling.equals("stretch")) { videoSurfaceWidth = stretchWidth; videoSurfaceHeight = stretchHeight; } else // scaling.equals( "none" ) { videoSurfaceWidth = videoRenderWidth; videoSurfaceHeight = videoRenderHeight; } } } }
From source file:paulscode.android.mupen64plusae.persistent.GlobalPrefs.java
/** * Instantiates a new user preferences wrapper. * * @param context/*from w w w.j av a 2 s . c om*/ * The application context. */ public GlobalPrefs(Context context, AppData appData) { mPreferences = PreferenceManager.getDefaultSharedPreferences(context); // Locale mLocaleCode = mPreferences.getString(KEY_LOCALE_OVERRIDE, DEFAULT_LOCALE_OVERRIDE); mLocale = TextUtils.isEmpty(mLocaleCode) ? Locale.getDefault() : createLocale(mLocaleCode); final Locale[] availableLocales = Locale.getAvailableLocales(); String[] values = context.getResources().getStringArray(R.array.localeOverride_values); String[] entries = new String[values.length]; for (int i = values.length - 1; i > 0; i--) { final Locale locale = createLocale(values[i]); // Get intersection of languages (available on device) and (translated for Mupen) if (ArrayUtils.contains(availableLocales, locale)) { // Get the name of the language, as written natively entries[i] = WordUtils.capitalize(locale.getDisplayName(locale)); } else { // Remove the item from the list entries = (String[]) ArrayUtils.remove(entries, i); values = (String[]) ArrayUtils.remove(values, i); } } entries[0] = context.getString(R.string.localeOverride_entrySystemDefault); mLocaleNames = entries; mLocaleCodes = values; // Files userDataDir = mPreferences.getString("pathGameSaves", ""); galleryCacheDir = userDataDir + "/GalleryCache"; coverArtDir = galleryCacheDir + "/CoverArt"; unzippedRomsDir = galleryCacheDir + "/UnzippedRoms"; profilesDir = userDataDir + "/Profiles"; crashLogDir = userDataDir + "/CrashLogs"; coreUserDataDir = userDataDir + "/CoreConfig/UserData"; coreUserCacheDir = userDataDir + "/CoreConfig/UserCache"; hiResTextureDir = coreUserDataDir + "/mupen64plus/hires_texture/"; // MUST match what rice assumes natively textureCacheDir = coreUserCacheDir + "/mupen64plus/cache"; romInfoCache_cfg = galleryCacheDir + "/romInfoCache.cfg"; controllerProfiles_cfg = profilesDir + "/controller.cfg"; touchscreenProfiles_cfg = profilesDir + "/touchscreen.cfg"; emulationProfiles_cfg = profilesDir + "/emulation.cfg"; customCheats_txt = profilesDir + "/customCheats.txt"; touchscreenCustomSkinsDir = userDataDir + "/CustomSkins"; legacyAutoSaves = userDataDir + "/AutoSaves"; legacySlotSaves = userDataDir + "/SlotSaves"; // Plug-ins audioPlugin = new Plugin(mPreferences, appData.libsDir, "audioPlugin"); // Library prefs isRecentShown = mPreferences.getBoolean("showRecentlyPlayed", true); isFullNameShown = mPreferences.getBoolean("showFullNames", true); // Touchscreen prefs isTouchscreenFeedbackEnabled = mPreferences.getBoolean("touchscreenFeedback", false); touchscreenScale = (mPreferences.getInt("touchscreenScale", 100)) / 100.0f; touchscreenTransparency = (255 * mPreferences.getInt("touchscreenTransparency", 100)) / 100; touchscreenAutoHold = getSafeInt(mPreferences, "touchscreenAutoHold", 0); // Video prefs displayOrientation = getSafeInt(mPreferences, "displayOrientation", 0); displayPosition = getSafeInt(mPreferences, "displayPosition", Gravity.CENTER_VERTICAL); final int transparencyPercent = mPreferences.getInt("displayActionBarTransparency", 50); displayActionBarTransparency = (255 * transparencyPercent) / 100; isFpsEnabled = mPreferences.getBoolean("displayFps", false); final int selectedHardwareType = getSafeInt(mPreferences, "videoHardwareType", -1); isPolygonOffsetHackEnabled = selectedHardwareType > -2; videoHardwareType = selectedHardwareType < 0 ? appData.hardwareInfo.hardwareType : selectedHardwareType; switch (videoHardwareType) { case HardwareInfo.HARDWARE_TYPE_OMAP: videoPolygonOffset = 0.2f; break; case HardwareInfo.HARDWARE_TYPE_OMAP_2: videoPolygonOffset = -1.5f; break; case HardwareInfo.HARDWARE_TYPE_QUALCOMM: videoPolygonOffset = -0.2f; break; case HardwareInfo.HARDWARE_TYPE_IMAP: videoPolygonOffset = -0.001f; break; case HardwareInfo.HARDWARE_TYPE_TEGRA: videoPolygonOffset = -2.0f; break; case HardwareInfo.HARDWARE_TYPE_UNKNOWN: videoPolygonOffset = -1.5f; break; default: videoPolygonOffset = SafeMethods.toFloat(mPreferences.getString("videoPolygonOffset", "-1.5"), -1.5f); break; } isImmersiveModeEnabled = mPreferences.getBoolean("displayImmersiveMode", false); // Audio prefs audioSwapChannels = mPreferences.getBoolean("audioSwapChannels", false); audioSDLSecondaryBufferSize = getSafeInt(mPreferences, "audioSDLBufferSize", 2048); audioSLESSecondaryBufferSize = getSafeInt(mPreferences, "audioSLESBufferSize2", 256); audioSLESSecondaryBufferNbr = getSafeInt(mPreferences, "audioSLESBufferNbr2", 20); audioSLESSamplingRate = getSafeInt(mPreferences, "audioSLESSamplingRate", 0); if (audioPlugin.enabled) isFramelimiterEnabled = !mPreferences.getBoolean("audioSynchronize", true); else isFramelimiterEnabled = !mPreferences.getString("audioPlugin", "").equals("nospeedlimit"); // User interface modes final String navMode = mPreferences.getString("navigationMode", "auto"); if (navMode.equals("bigscreen")) isBigScreenMode = true; else if (navMode.equals("standard")) isBigScreenMode = false; else isBigScreenMode = AppData.IS_OUYA_HARDWARE || appData.isAndroidTv; // TODO: Add other systems as they enter market // Peripheral share mode isControllerShared = mPreferences.getBoolean("inputShareController", false); maxAutoSaves = mPreferences.getInt("gameAutoSaves", 5); // Determine the key codes that should not be mapped to controls final boolean volKeysMappable = mPreferences.getBoolean("inputVolumeMappable", false); final List<Integer> unmappables = new ArrayList<>(); unmappables.add(KeyEvent.KEYCODE_MENU); // Back key is needed to show/hide the action bar in HC+ unmappables.add(KeyEvent.KEYCODE_BACK); if (!volKeysMappable) { unmappables.add(KeyEvent.KEYCODE_VOLUME_UP); unmappables.add(KeyEvent.KEYCODE_VOLUME_DOWN); unmappables.add(KeyEvent.KEYCODE_VOLUME_MUTE); } unmappableKeyCodes = Collections.unmodifiableList(unmappables); // Controller profiles controllerProfile1 = loadControllerProfile(mPreferences, GamePrefs.CONTROLLER_PROFILE1, getControllerProfileDefault(1), GetControllerProfilesConfig(), appData.GetControllerProfilesConfig()); controllerProfile2 = loadControllerProfile(mPreferences, GamePrefs.CONTROLLER_PROFILE2, getControllerProfileDefault(2), GetControllerProfilesConfig(), appData.GetControllerProfilesConfig()); controllerProfile3 = loadControllerProfile(mPreferences, GamePrefs.CONTROLLER_PROFILE3, getControllerProfileDefault(3), GetControllerProfilesConfig(), appData.GetControllerProfilesConfig()); controllerProfile4 = loadControllerProfile(mPreferences, GamePrefs.CONTROLLER_PROFILE4, getControllerProfileDefault(4), GetControllerProfilesConfig(), appData.GetControllerProfilesConfig()); // Player map playerMap = new PlayerMap(mPreferences.getString(GamePrefs.PLAYER_MAP, "")); // Determine whether controller deconfliction is needed int numControllers = 0; numControllers += controllerProfile1 != null ? 1 : 0; numControllers += controllerProfile2 != null ? 1 : 0; numControllers += controllerProfile3 != null ? 1 : 0; numControllers += controllerProfile4 != null ? 1 : 0; playerMap.setEnabled(numControllers > 1 && !isControllerShared); }
From source file:org.jahia.modules.rolesmanager.RolesAndPermissionsHandler.java
public Map<String, String> getAvailableLanguages() throws RepositoryException { Set<String> languages = new TreeSet<String>( getSession().getNodeByIdentifier(roleBean.getUuid()).getResolveSite().getLanguages()); Map<String, I18nRoleProperties> i18nProperties = roleBean.getI18nProperties(); for (String l : i18nProperties.keySet()) { if (i18nProperties.get(l) != null) { languages.remove(l);// w w w .j a v a2 s .c o m } } TreeMap<String, String> availableLanguages = new TreeMap<String, String>(); for (String l : languages) { Locale locale = new Locale(l); availableLanguages.put(l, locale.getDisplayName(LocaleContextHolder.getLocale())); } return availableLanguages; }
From source file:org.opencms.workplace.editors.CmsDialogCopyLanguage.java
/** * Builds the html String for a form list of all possible page elements.<p> * // w w w .j av a 2s. c om * @return the html String for a form list */ public String buildLanguageList() { try { StringBuffer retValue = new StringBuffer(512); retValue.append("<table border=\"0\">\n"); // get locale for current element Locale elLocale = getElementLocale(); // get locale names based on properties and global settings List localeList = OpenCms.getLocaleManager().getAvailableLocales(getCms(), getParamTempfile()); // read xml content for checking locale availability CmsFile file = getCms().readFile(getParamTempfile(), CmsResourceFilter.IGNORE_EXPIRATION); CmsXmlContent content = CmsXmlContentFactory.unmarshal(getCms(), file); // show all possible elements Iterator i = localeList.iterator(); while (i.hasNext()) { // get the current list element Locale curLocale = (Locale) i.next(); // skip locale of current element if (elLocale.equals(curLocale)) { continue; } // build an element row retValue.append("<tr>\n"); retValue.append("\t<td class=\"textcenter\" unselectable=\"on\"><input type=\"checkbox\" name=\""); retValue.append(PARAM_LANGUAGE); retValue.append("\" value=\""); retValue.append(curLocale.toString()); retValue.append("\">"); retValue.append("</td>\n"); retValue.append("\t<td style=\"white-space: nowrap;\" unselectable=\"on\">"); retValue.append(curLocale.getDisplayName(getLocale())); retValue.append(!content.hasLocale(curLocale) ? " [-]" : ""); retValue.append("</td>\n"); retValue.append("\t<td style=\"white-space: nowrap;\" unselectable=\"on\">"); retValue.append(!content.hasLocale(curLocale) ? Messages.get().getBundle(getLocale()).key(Messages.GUI_EDITOR_DIALOG_COPYLANGUAGE_NEW_0) : ""); retValue.append("</td>\n"); retValue.append("</tr>\n"); } retValue.append("</table>\n"); return retValue.toString(); } catch (Throwable e) { // should usually never happen if (LOG.isInfoEnabled()) { LOG.info(e); } return ""; } }
From source file:org.exoplatform.wcm.webui.seo.UISEOForm.java
public List<SelectItemOption<String>> getLanguages() throws Exception { WebuiRequestContext rc = WebuiRequestContext.getCurrentInstance(); Locale inLocale = WebuiRequestContext.getCurrentInstance().getLocale(); // Get default locale Locale defaultLocale = Locale.getDefault(); // set default locale to current user selected language Locale.setDefault(Util.getUIPortal().getAncestorOfType(UIPortalApplication.class).getLocale()); LocaleConfigService localService = WCMCoreUtils.getService(LocaleConfigService.class); List<SelectItemOption<String>> languages = new ArrayList<SelectItemOption<String>>(); Iterator<LocaleConfig> iter = localService.getLocalConfigs().iterator(); ResourceBundle resourceBundle = rc.getApplicationResourceBundle(); while (iter.hasNext()) { LocaleConfig localConfig = iter.next(); Locale locale = localConfig.getLocale(); String lang = locale.getLanguage(); String country = locale.getCountry(); if (StringUtils.isNotEmpty(country)) lang += "_" + country; if (seoLanguages == null || !seoLanguages.contains(lang)) { try { languages.add(new SelectItemOption<String>(CapitalFirstLetters(locale.getDisplayName(inLocale)), lang));// w w w. jav a2 s. c o m } catch (MissingResourceException mre) { languages.add(new SelectItemOption<String>(lang, lang)); } } } // Set back to the default locale Locale.setDefault(defaultLocale); Collections.sort(languages, new ItemOptionComparator()); languages.add(0, new SelectItemOption<String>(getLabel(resourceBundle, "select-language"), "language")); return languages; }
From source file:org.jboss.dashboard.ui.components.DataProviderHandler.java
protected void checkConfig() { // Name must exist al least for the current locale. String name = (String) localeManager.localize(descriptions); if (name == null || "".equals(name)) { setProviderMessage(MessageFormat.format(getMessage("dataProviderComponent.nameInvalid"), localeManager.getLangDisplayName(localeManager.getCurrentLang()))); setHasErrors(true);/*from ww w . j ava2 s . com*/ return; } // Check for existing names StringBuilder messagePart = new StringBuilder(""); for (Iterator descIt = descriptions.keySet().iterator(); descIt.hasNext();) { Locale descLoc = (Locale) descIt.next(); String descName = (String) descriptions.get(descLoc); DataProvider currentProvider = null; try { currentProvider = getDataProvider(); } catch (Exception e) { log.error("Error: ", e); } if (nameExists(currentProvider, descLoc, descName)) { if (messagePart.length() > 0) messagePart.append(", "); messagePart.append(descLoc.getDisplayName(LocaleManager.currentLocale())).append(":") .append(descName); } } if (messagePart.length() > 0) { setProviderMessage( MessageFormat.format(getMessage("dataProviderComponent.nameExists"), messagePart.toString())); setHasErrors(true); } }
From source file:org.opencms.workplace.tools.accounts.A_CmsEditUserDialog.java
/** * Returns a list of options for the locale selector.<p> * //from w w w .ja va2 s . c o m * @return a list of options for the locale selector */ private List<CmsSelectWidgetOption> getLanguages() { List<CmsSelectWidgetOption> locales = new ArrayList<CmsSelectWidgetOption>(); Locale defLocale = null; if ((m_user != null) && CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_user.getName())) { defLocale = new CmsUserSettings(m_user).getLocale(); } if (defLocale == null) { defLocale = getCms().getRequestContext().getLocale(); } Iterator<Locale> itLocales = OpenCms.getLocaleManager().getAvailableLocales().iterator(); while (itLocales.hasNext()) { Locale locale = itLocales.next(); boolean selected = locale.equals(defLocale); locales.add(new CmsSelectWidgetOption(locale.toString(), selected, locale.getDisplayName(getLocale()), null)); } return locales; }