List of usage examples for java.util Locale getDisplayName
public final String getDisplayName()
From source file:org.pentaho.reporting.engine.classic.demo.ancient.demo.internationalisation.LocaleSelectionReportController.java
private KeyedComboBoxModel createLocalesModel() { final KeyedComboBoxModel cn = new KeyedComboBoxModel(); final Locale[] locales = Locale.getAvailableLocales(); for (int i = 0; i < locales.length; i++) { final Locale locale = locales[i]; cn.add(locale, locale.getDisplayName()); }/*from w w w. j a v a 2 s.c o m*/ cn.setSelectedKey(Locale.getDefault()); return cn; }
From source file:com.aurel.track.prop.LoginBL.java
/** * This method controls entire login procedure. * * @param isInTestMode/* w ww.j a va2 s . co m*/ * @param isMobileApplication * @param username * @param usingContainerBasedAuthentication * @param password * @param forwardUrl * @param springAuthenticated * @param mobileApplicationVersionNo * @param locale * @return */ public static String login(String isInTestMode, boolean isMobileApplication, String username, boolean usingContainerBasedAuthentication, String password, String forwardUrl, boolean springAuthenticated, Integer mobileApplicationVersionNo, Locale _locale) { Boolean ready = (Boolean) ServletActionContext.getServletContext().getAttribute(ApplicationStarter.READY); if (ready == null || !ready.booleanValue()) { return "loading"; } HttpServletRequest request = ServletActionContext.getRequest(); HttpSession httpSession = request.getSession(); String nonce = (String) httpSession.getAttribute("NONCE"); if ("true".equals(isInTestMode)) { nonce = null; // accept clear text passwords } httpSession.setAttribute(ISMOBILEAPP, isMobileApplication); Locale locale = _locale; if (locale == null) { locale = Locale.getDefault(); LOGGER.debug("Requested locale is null. Using default:" + locale.getDisplayName()); } else { LOGGER.debug("Requested locale " + locale.getDisplayName()); } httpSession.setAttribute("localizationJSON", LocalizeJSON.encodeLocalization(locale)); TMotdBean motd = MotdBL.loadMotd(locale.getLanguage()); if (motd == null) { motd = MotdBL.loadMotd("en"); } // if already logged in forward to home page if (SessionUtils.getCurrentUser(httpSession) != null) { String redirectMapEntry = "itemNavigator"; TPersonBean personBean = (TPersonBean) httpSession.getAttribute(Constants.USER_KEY); if (personBean != null && personBean.getHomePage() != null && personBean.getHomePage().trim().length() > 0) { redirectMapEntry = personBean.getHomePage(); } StringBuilder sb = new StringBuilder(); sb.append("{"); JSONUtility.appendBooleanValue(sb, JSONUtility.JSON_FIELDS.SUCCESS, true); sb.append(DATABRACE); JSONUtility.appendStringValue(sb, "jsonURL", redirectMapEntry + DOTACTION, true); sb.append("}"); sb.append("}"); return LoginBL.writeJSONResponse(sb); // The redirect is done by the // client JavaScript } // if Container Based Authentication is enabled and we can get a remote // user we use that one, no more questions asked. However, a local login // always overrules. if ((username == null || "".equals(username) || password == null || "".equals(password)) && (request.getRemoteUser() != null && ApplicationBean.getInstance().getSiteBean().getIsCbaAllowed())) { username = request.getRemoteUser(); usingContainerBasedAuthentication = true; } List<LabelValueBean> errors = new ArrayList<LabelValueBean>(); StringBuilder sb = new StringBuilder(); String redirectMapEntry = ""; sb = LoginBL.createLoginResponseJSON(username, password, nonce, usingContainerBasedAuthentication, springAuthenticated, request, errors, httpSession, forwardUrl, motd, isMobileApplication, locale, mobileApplicationVersionNo, redirectMapEntry); if (errors != null && errors.size() > 0 && usingContainerBasedAuthentication) { return "forwardToLogin"; // could not verify container registered // user with Genji } if (usingContainerBasedAuthentication && !isMobileApplication) { ACCESSLOGGER.info("User was authenticated via container."); if (redirectMapEntry.isEmpty()) return SUCCESS; return redirectMapEntry; } return writeJSONResponse(sb); // The redirect is done by the client // JavaScript }
From source file:org.pdfsam.ui.dashboard.preference.PreferenceAppearencePaneTest.java
@Test public void eventSentOnLocaleChange() { Listener<SetLocaleEvent> listener = mock(Listener.class); eventStudio().add(SetLocaleEvent.class, listener); Locale first = DefaultI18nContext.SUPPORTED_LOCALES.stream().findFirst().get(); click("#localeCombo").click(StringUtils.capitalize(first.getDisplayName())); ArgumentCaptor<SetLocaleEvent> captor = ArgumentCaptor.forClass(SetLocaleEvent.class); verify(listener).onEvent(captor.capture()); assertEquals(first.toLanguageTag(), captor.getValue().getLocaleString()); verify(userContext).setStringPreference(eq(StringUserPreference.LOCALE), eq(first.toLanguageTag())); }
From source file:org.jia.ptrack.web.Visit.java
public List getSupportedtLocaleItems() { if (localeItems == null) { localeItems = new ArrayList(); Application app = FacesContext.getCurrentInstance().getApplication(); for (Iterator i = app.getSupportedLocales(); i.hasNext();) { Locale locale = (Locale) i.next(); SelectItem item = new SelectItem(locale.toString(), locale.getDisplayName()); localeItems.add(item);//from ww w.j av a 2 s.com } if (localeItems.size() == 0) { Locale defaultLocale = app.getDefaultLocale(); localeItems.add(new SelectItem(defaultLocale.toString(), defaultLocale.getDisplayName())); } } return localeItems; }
From source file:ch.silviowangler.dox.TranslationServiceImpl.java
@Override @Transactional(readOnly = true, propagation = SUPPORTS) public String findTranslation(String key, Locale locale) throws NoTranslationFoundException { logger.debug("Trying to find message for key '{}' and locale '{}'", key, locale.getDisplayName()); Translation translation = translationRepository.findByKeyAndLocale(key, locale); if (translation == null) { final Locale fallbackLocale = new Locale(locale.getLanguage()); logger.debug("No translation found for key '{}' and locale '{}'. Falling back to locale '{}'", new Object[] { key, locale.getDisplayName(), fallbackLocale.getDisplayName() }); translation = translationRepository.findByKeyAndLocale(key, fallbackLocale); if (translation == null && !fallbackLocale.equals(GERMAN)) { translation = translationRepository.findByKeyAndLocale(key, GERMAN); if (translation == null) { logger.warn("No translation found for key '{}' and locale '{}'", key, locale); throw new NoTranslationFoundException(key, locale); }/*from w w w. j av a 2 s . co m*/ return translation.getLanguageSpecificTranslation(); } else { logger.debug("Found translation of key '{}' using fallback locale '{}'", key, fallbackLocale.getDisplayName()); if (translation == null) throw new NoTranslationFoundException(key, locale); return translation.getLanguageSpecificTranslation(); } } else { logger.debug("Found translation of key '{}' on first attempt using locale '{}'", key, locale.getDisplayName()); return translation.getLanguageSpecificTranslation(); } }
From source file:com.ibm.mil.readyapps.summit.fragments.DashboardFragment.java
private void getDashboardData() { // see if data was cached previously if (Utils.notNull(allItems, recommendedItems, featuredItems)) { // data cached, set data adapters directly setDataAdapters();/* w w w . ja va 2 s . c o m*/ return; } // make WL call to fetch data WLProcedureCaller wlProcedureCaller = new WLProcedureCaller("SummitAdapter", "getHomeViewMetadata", new CircularProgressDialog(getActivity())); // retrieve current user locale Locale locale = getResources().getConfiguration().locale; Object[] params = new Object[] { locale.getDisplayName() }; wlProcedureCaller.invoke(params, new WLResponseListener() { @Override public void onSuccess(WLResponse wlResponse) { Log.i(TAG, wlResponse.getResponseJSON().toString()); parseJson(wlResponse.getResponseJSON().toString()); } @Override public void onFailure(WLFailResponse wlFailResponse) { Log.i(TAG, wlFailResponse.getErrorMsg()); } }); }
From source file:org.appd.login.V_Login.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); et_User = (EditText) getActivity().findViewById(R.id.et_User); et_Pass = (EditText) getActivity().findViewById(R.id.et_Pass); ch_SavePass = (CheckBox) getActivity().findViewById(R.id.ch_SavePass); ch_AutomaticVisitClosing = (CheckBox) getActivity().findViewById(R.id.ch_AutomaticVisitClosing); sp_Language = (Cust_Spinner) getActivity().findViewById(R.id.sp_Language); ArrayList<DisplaySpinner> data = new ArrayList<DisplaySpinner>(); for (Locale loc : Locale.getAvailableLocales()) { data.add(new DisplaySpinner(0, loc.getDisplayName(), loc.toString())); }/* w w w . j a v a2s. co m*/ sp_Language.load(data); }
From source file:com.jaspersoft.studio.swt.widgets.WLocale.java
/** * This returns the list index for a given locale. * //from ww w . ja va 2 s. c o m * @param locale * @return int index */ private int getIndexFromLocale(Locale locale) { int returnedIndex = -1; if (locale != null) { for (int i = 0; i < strLocales.length; i++) { if (strLocales[i].equals(locale.getDisplayName())) returnedIndex = i; } } return returnedIndex; }
From source file:com.bellman.bible.android.Bible.java
public void initAll(Application application) { this.application = application; Log.i(TAG, "OS:" + System.getProperty("os.name") + " ver " + System.getProperty("os.version")); Log.i(TAG, "Java:" + System.getProperty("java.vendor") + " ver " + System.getProperty("java.version")); Log.i(TAG, "Java home:" + System.getProperty("java.home")); Log.i(TAG,//from w w w.j ava2s . co m "User dir:" + System.getProperty("user.dir") + " Timezone:" + System.getProperty("user.timezone")); // fix for null context class loader (http://code.google.com/p/android/issues/detail?id=5697) // this affected jsword dynamic classloading Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); installJSwordErrorReportListener(); // initialise link to Android progress control display in Notification bar ProgressNotificationManager.getInstance().initialise(); Locale locale = Locale.getDefault(); Log.i(TAG, "Locale language:" + locale.getLanguage() + " Variant:" + locale.getDisplayName()); // various initialisations required every time at app startup Initialisation.getInstance().initialiseEventually(); }
From source file:org.jasig.portlet.cms.mvc.portlet.ConfigureContentController.java
/** * Get the list of supported locales to populate the drop-down list with. * //from w w w .j a v a 2 s .c o m * @param request * @return */ // @ModelAttribute("supportedLocales") public HashMap<String, String> getLocales(PortletRequest request) { PortletPreferences preferences = request.getPreferences(); String[] supportedLocales = preferences.getValues("supportedLocales", new String[] {}); HashMap<String, String> locales = new HashMap<String, String>(); for (String localeString : supportedLocales) { localeString = localeString.trim(); Locale locale = StringUtils.parseLocaleString(localeString.trim()); locales.put(localeString.trim(), localeString.trim() + ": " + locale.getDisplayName()); } return locales; }