List of usage examples for java.util Locale getCountry
public String getCountry()
From source file:org.eclipse.jubula.autagent.commands.StartRcpAutServerCommand.java
/** * {@inheritDoc}// ww w . j a v a2s. co m */ protected String[] createCmdArray(String baseCmd, Map<String, String> parameters) { List<String> cmds; if (!isRunningFromExecutable(parameters)) { // Start using java cmds = createDirectAutJavaCall(parameters); cmds.add(0, baseCmd); createDirectAutJavaCallParameter(PATH_SEPARATOR, cmds, parameters); addLocale(cmds, LocaleUtils.toLocale(parameters.get(AutConfigConstants.AUT_LOCALE))); } else { // Start using executable file cmds = new Vector<String>(); cmds.add(0, baseCmd); createDirectAutExeCallParameter(cmds, parameters); // add locale // Note: This overrides the -nl defined in the <app>.ini file, if // any. It will not override a -nl from the command line. if (!cmds.contains(NL)) { Locale locale = LocaleUtils.toLocale(parameters.get(AutConfigConstants.AUT_LOCALE)); if (locale != null) { if ((locale.getCountry() != null && locale.getCountry().length() > 0) || (locale.getLanguage() != null && locale.getLanguage().length() > 0)) { // Add -nl argument if country and/or language is // available. cmds.add(1, NL); cmds.add(2, locale.toString()); } } } addDebugParams(cmds, true); } String[] cmdArray = cmds.toArray(new String[cmds.size()]); return cmdArray; }
From source file:com.processpuzzle.internalization.domain.ProcessPuzzleLocale.java
public int hashCode() { Locale javaLocale = getJavaLocale(); return new HashCodeBuilder().append(javaLocale.getLanguage()).append(javaLocale.getCountry()) .append(javaLocale.getVariant()).toHashCode(); }
From source file:org.fao.gast.gui.GuiBuilder.java
private ResourceBundle lookupResourceBundle(URL guiSpec, Locale locale) throws IOException { String[] parts = { locale.getLanguage(), locale.getCountry(), locale.getVariant() }; String baseString = guiSpec.toExternalForm(); if (baseString.indexOf('.') > 0) { baseString = baseString.substring(0, baseString.lastIndexOf(".")); }//from ww w . j ava 2s . c om for (int i = parts.length; i >= 0; i--) { ResourceBundle bundle = locateResourceBundleFile(baseString, parts, i); if (bundle != null) { return bundle; } } throw new IllegalStateException("Unable to find gui.xml file"); }
From source file:com.bdaum.zoom.gps.naming.google.internal.GoogleGeonamingService.java
public WaypointArea[] findLocation(String address) throws IOException, WebServiceException, SAXException, ParserConfigurationException { List<WaypointArea> pnts = new ArrayList<WaypointArea>(); Locale locale = Locale.getDefault(); try (InputStream in = openGoogleService(NLS.bind( "https://maps.googleapis.com/maps/api/geocode/xml?address={0}®ion={1}&language={2}", //$NON-NLS-1$ new Object[] { URLEncoder.encode(address, "UTF-8"), locale.getCountry(), locale.getLanguage() }))) { //$NON-NLS-1$ new GoogleGeoCodeParser(in).parse(pnts); } catch (DoneParsingException e) { // everything okay }/* w w w . ja v a2s .c om*/ return pnts.toArray(new WaypointArea[pnts.size()]); }
From source file:org.sonar.core.i18n.RuleI18nManager.java
public String getDescription(String repositoryKey, String ruleKey, Locale locale) { String relatedProperty = new StringBuilder().append(RULE_PREFIX).append(repositoryKey).append(".") .append(ruleKey).append(NAME_SUFFIX).toString(); Locale localeWithoutCountry = (locale.getCountry() == null ? locale : new Locale(locale.getLanguage())); String ruleDescriptionFilePath = "rules/" + repositoryKey + "/" + ruleKey + ".html"; String description = i18nManager.messageFromFile(localeWithoutCountry, ruleDescriptionFilePath, relatedProperty, true);/*from w w w . j a v a 2 s. c om*/ if (description == null) { // Following line is to ensure backward compatibility (SONAR-3319) description = lookUpDescriptionInFormerLocation(ruleKey, relatedProperty, localeWithoutCountry); if (description == null && !"en".equals(localeWithoutCountry.getLanguage())) { // nothing was found, let's get the value of the default bundle description = i18nManager.messageFromFile(Locale.ENGLISH, ruleDescriptionFilePath, relatedProperty, true); } } return description; }
From source file:com.limegroup.gnutella.gui.init.LanguagePanel.java
private Locale guessLocale(Locale[] locales) { String[] language = guessLanguage(); Locale result = null;/* www.j a va 2s. c o m*/ try { for (Locale l : locales) { if (l.getLanguage().equalsIgnoreCase(language[0]) && l.getCountry().equalsIgnoreCase(language[1]) && l.getVariant().equalsIgnoreCase(language[2])) { result = l; } if (l.getLanguage().equalsIgnoreCase(language[0]) && l.getCountry().equalsIgnoreCase(language[1]) && result == null) { result = l; } if (l.getLanguage().equalsIgnoreCase(language[0]) && result == null) { result = l; } } } catch (Throwable e) { //shhh! } return (result == null) ? new Locale(language[0], language[1], language[2]) : result; }
From source file:org.pentaho.platform.web.http.context.SolutionContextListener.java
public void contextInitialized(final ServletContextEvent event) { ServletContext context = event.getServletContext(); String encoding = context.getInitParameter("encoding"); //$NON-NLS-1$ if (encoding != null) { LocaleHelper.setSystemEncoding(encoding); }/*from w ww . ja va2 s . c o m*/ String textDirection = context.getInitParameter("text-direction"); //$NON-NLS-1$ if (textDirection != null) { LocaleHelper.setTextDirection(textDirection); } String localeLanguage = context.getInitParameter("locale-language"); //$NON-NLS-1$ String localeCountry = context.getInitParameter("locale-country"); //$NON-NLS-1$ boolean localeSet = false; if ((localeLanguage != null) && !"".equals(localeLanguage) && (localeCountry != null) && !"".equals(localeCountry)) { //$NON-NLS-1$ //$NON-NLS-2$ Locale[] locales = Locale.getAvailableLocales(); if (locales != null) { for (Locale element : locales) { if (element.getLanguage().equals(localeLanguage) && element.getCountry().equals(localeCountry)) { LocaleHelper.setLocale(element); localeSet = true; break; } } } } if (!localeSet) { // do this thread in the default locale LocaleHelper.setLocale(Locale.getDefault()); } LocaleHelper.setDefaultLocale(LocaleHelper.getLocale()); // log everything that goes on here Logger.info(SolutionContextListener.class.getName(), Messages.getInstance().getString("SolutionContextListener.INFO_INITIALIZING")); //$NON-NLS-1$ Logger.info(SolutionContextListener.class.getName(), Messages.getInstance().getString("SolutionContextListener.INFO_SERVLET_CONTEXT") + context); //$NON-NLS-1$ SolutionContextListener.contextPath = context.getRealPath(""); //$NON-NLS-1$ Logger.info(SolutionContextListener.class.getName(), Messages.getInstance().getString("SolutionContextListener.INFO_CONTEXT_PATH") //$NON-NLS-1$ + SolutionContextListener.contextPath); SolutionContextListener.solutionPath = PentahoHttpSessionHelper.getSolutionPath(context); if (StringUtils.isEmpty(SolutionContextListener.solutionPath)) { String errorMsg = Messages.getInstance() .getErrorString("SolutionContextListener.ERROR_0001_NO_ROOT_PATH"); //$NON-NLS-1$ Logger.error(getClass().getName(), errorMsg); /* * Since we couldn't find solution repository path there is no point in going forward and the user should know * that a major config setting was not found. So we are throwing in a RunTimeException with the requisite message. */ throw new RuntimeException(errorMsg); } Logger.info(getClass().getName(), Messages.getInstance().getString("SolutionContextListener.INFO_ROOT_PATH") + SolutionContextListener.solutionPath); //$NON-NLS-1$ String fullyQualifiedServerUrl = context.getInitParameter("fully-qualified-server-url"); //$NON-NLS-1$ if (fullyQualifiedServerUrl == null) { // assume this is a demo installation // TODO: Create a servlet that's loaded on startup to set this value fullyQualifiedServerUrl = "http://localhost:8080/pentaho/"; //$NON-NLS-1$ } IApplicationContext applicationContext = new WebApplicationContext(SolutionContextListener.solutionPath, fullyQualifiedServerUrl, context.getRealPath(""), context); //$NON-NLS-1$ /* * Copy out all the initParameter values from the servlet context and put them in the application context. */ Properties props = new Properties(); Enumeration<?> initParmNames = context.getInitParameterNames(); String initParmName; while (initParmNames.hasMoreElements()) { initParmName = (String) initParmNames.nextElement(); props.setProperty(initParmName, context.getInitParameter(initParmName)); } ((WebApplicationContext) applicationContext).setProperties(props); setSystemCfgFile(context); setObjectFactory(context); boolean initOk = PentahoSystem.init(applicationContext); this.showInitializationMessage(initOk, fullyQualifiedServerUrl); }
From source file:com.openbravo.pos.forms.AppConfig.java
private void loadDefault() { m_propsconfig = new Properties(); String dirname = System.getProperty("dirname.path"); dirname = dirname == null ? "./" : dirname; m_propsconfig.setProperty("db.driverlib", new File(new File(dirname), "lib/derby.jar").getAbsolutePath()); m_propsconfig.setProperty("db.driver", "org.apache.derby.jdbc.EmbeddedDriver"); m_propsconfig.setProperty("db.URL", "jdbc:derby:" + new File(new File(System.getProperty("user.home")), AppLocal.APP_ID + "-database") .getAbsolutePath() + ";create=true"); m_propsconfig.setProperty("db.user", ""); m_propsconfig.setProperty("db.password", ""); // m_propsconfig.setProperty("db.driverlib", new File(new File(dirname), "lib/hsqldb.jar").getAbsolutePath()); // m_propsconfig.setProperty("db.driver", "org.hsqldb.jdbcDriver"); // m_propsconfig.setProperty("db.URL", "jdbc:hsqldb:file:" + new File(new File(System.getProperty("user.home")), AppLocal.APP_ID + "-db").getAbsolutePath() + ";shutdown=true"); // m_propsconfig.setProperty("db.user", "sa"); // m_propsconfig.setProperty("db.password", ""); // m_propsconfig.setProperty("db.driver", "com.mysql.jdbc.Driver"); // m_propsconfig.setProperty("db.URL", "jdbc:mysql://localhost:3306/database"); // m_propsconfig.setProperty("db.user", "user"); // m_propsconfig.setProperty("db.password", "password"); // m_propsconfig.setProperty("db.driver", "org.postgresql.Driver"); // m_propsconfig.setProperty("db.URL", "jdbc:postgresql://localhost:5432/database"); // m_propsconfig.setProperty("db.user", "user"); // m_propsconfig.setProperty("db.password", "password"); m_propsconfig.setProperty("machine.hostname", getLocalHostName()); Locale l = Locale.getDefault(); m_propsconfig.setProperty("user.language", l.getLanguage()); m_propsconfig.setProperty("user.country", l.getCountry()); m_propsconfig.setProperty("user.variant", l.getVariant()); m_propsconfig.setProperty("swing.defaultlaf", System.getProperty("swing.defaultlaf", "javax.swing.plaf.metal.MetalLookAndFeel")); m_propsconfig.setProperty("machine.printer", "screen"); m_propsconfig.setProperty("machine.printer.2", "Not defined"); m_propsconfig.setProperty("machine.printer.3", "Not defined"); m_propsconfig.setProperty("machine.display", "screen"); m_propsconfig.setProperty("machine.scale", "Not defined"); m_propsconfig.setProperty("machine.screenmode", "window"); // fullscreen / window m_propsconfig.setProperty("machine.ticketsbag", "standard"); m_propsconfig.setProperty("machine.scanner", "Not defined"); m_propsconfig.setProperty("payment.gateway", "external"); m_propsconfig.setProperty("payment.magcardreader", "Not defined"); m_propsconfig.setProperty("payment.testmode", "false"); m_propsconfig.setProperty("payment.commerceid", ""); m_propsconfig.setProperty("payment.commercepassword", "password"); m_propsconfig.setProperty("machine.printername", "(Default)"); // Receipt printer paper set to 72mmx200mm m_propsconfig.setProperty("paper.receipt.x", "10"); m_propsconfig.setProperty("paper.receipt.y", "287"); m_propsconfig.setProperty("paper.receipt.width", "190"); m_propsconfig.setProperty("paper.receipt.height", "546"); m_propsconfig.setProperty("paper.receipt.mediasizename", "A4"); // Normal printer paper for A4 m_propsconfig.setProperty("paper.standard.x", "72"); m_propsconfig.setProperty("paper.standard.y", "72"); m_propsconfig.setProperty("paper.standard.width", "451"); m_propsconfig.setProperty("paper.standard.height", "698"); m_propsconfig.setProperty("paper.standard.mediasizename", "A4"); m_propsconfig.setProperty("machine.uniqueinstance", "false"); }
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 . j a 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:com.salesmanager.customer.profile.LogonAction.java
private void prepareZones() throws Exception { int shippingCountryId = PropertiesUtil.getConfiguration().getInt("core.system.defaultcountryid", Constants.US_COUNTRY_ID);//from www .j ava2s .c o m Locale locale = super.getLocale(); String countryCode = locale.getCountry(); if (!StringUtils.isBlank(countryCode)) { CountryDescription country = CountryUtil.getCountryByIsoCode(countryCode, locale); shippingCountryId = country.getId().getCountryId(); } Collection lcountries = RefCache .getAllcountriesmap(LanguageUtil.getLanguageNumberCode(super.getLocale().getLanguage())).values(); this.setCountries(lcountries); Collection lzones = RefCache.getFilterdByCountryZones(shippingCountryId, LanguageUtil.getLanguageNumberCode(super.getLocale().getLanguage())); this.setZones(lzones); }