List of usage examples for java.util Locale getLanguage
public String getLanguage()
From source file:com.globalsight.connector.blaise.CreateBlaiseJobThread.java
private void createJob() throws Exception { try {//from w w w . java 2s . co m String jobName = BlaiseHelper.getEntryJobName(curEntry); jobName = addJobNameSuffix(jobName); String comment = blaiseForm.getComment(); String priority = blaiseForm.getPriority(); long l10Id = curFileProfile.getL10nProfileId(); BasicL10nProfile l10Profile = HibernateUtil.get(BasicL10nProfile.class, l10Id); String sourceLocaleName = l10Profile.getSourceLocale().getLocaleCode(); Locale trgLocale = curEntry.getTargetLocale(); String targetLocale = trgLocale.getLanguage() + "_" + trgLocale.getCountry(); targetLocale = BlaiseHelper.fixLocale(targetLocale); Job job = JobCreationMonitor.initializeJob(jobName, uuid, user.getUserId(), l10Id, priority, Job.IN_QUEUE, Job.JOB_TYPE_BLAISE); // init files and file profiles infomation List<String> descList = new ArrayList<String>(); retrieveRealFileFromBlaiseServer(descList, job, curEntry, sourceLocaleName); List<FileProfile> fpList = new ArrayList<FileProfile>(); fpList.add(curFileProfile); Map<String, long[]> filesToFpId = FileProfileUtil.excuteScriptOfFileProfile(descList, fpList, job); Set<String> fileNames = filesToFpId.keySet(); Integer pageCount = new Integer(fileNames.size()); // cache job attributes if there are any if (jobAttribtues != null && jobAttribtues.size() != 0) { RuntimeCache.addJobAtttibutesCache(uuid, jobAttribtues); } int count = 0; for (Iterator<String> i = fileNames.iterator(); i.hasNext();) { String fileName = i.next(); long[] tmp = filesToFpId.get(fileName); String fileProfileId = String.valueOf(tmp[0]); int exitValue = (int) tmp[1]; String key = jobName + fileName + ++count; CxeProxy.setTargetLocales(key, targetLocale); CxeProxy.importFromFileSystem(fileName, String.valueOf(job.getId()), jobName, fileProfileId, pageCount, count, 1, 1, Boolean.TRUE, Boolean.FALSE, CxeProxy.IMPORT_TYPE_L10N, exitValue, priority); } // save job attributes if there are any if (jobAttribtues != null) { saveAttributes(jobAttribtues, currentCompanyId, job); } // save job comment if (!StringUtils.isEmpty(comment) || !StringUtils.isEmpty(attachFileName)) { String dir = convertFilePath(AmbFileStoragePathUtils.getFileStorageDirPath(currentCompanyId)) + File.separator + "GlobalSight" + File.separator + "CommentReference" + File.separator + "tmp" + File.separator + uuid; File src = new File(dir + File.separator + attachFileName); if (attachFile != null) { FileUtil.copyFile(attachFile, src); } SaveCommentThread sct = new SaveCommentThread(jobName, comment, attachFileName, user.getUserId(), dir); sct.start(); } // Record this BlaiseConnectorJob bcj = new BlaiseConnectorJob(); bcj.setBlaiseConnectorId(this.connector.getId()); bcj.setBlaiseEntryId(this.curEntry.getId()); bcj.setJobId(job.getId()); HibernateUtil.saveOrUpdate(bcj); } catch (FileNotFoundException ex) { logger.error("Cannot find the tmp uploaded files.", ex); } catch (Exception e) { logger.error("Create job failed.", e); } }
From source file:com.puppycrawl.tools.checkstyle.filters.SuppressionCommentFilterTest.java
@Override protected Checker createChecker(Configuration checkConfig) throws CheckstyleException { final DefaultConfiguration checkerConfig = new DefaultConfiguration("configuration"); final DefaultConfiguration checksConfig = createCheckConfig(TreeWalker.class); checksConfig.addChild(createCheckConfig(FileContentsHolder.class)); checksConfig.addChild(createCheckConfig(MemberNameCheck.class)); checksConfig.addChild(createCheckConfig(ConstantNameCheck.class)); checksConfig.addChild(createCheckConfig(IllegalCatchCheck.class)); checkerConfig.addChild(checksConfig); if (checkConfig != null) { checkerConfig.addChild(checkConfig); }//from w w w.j a v a 2 s . c o m final Checker checker = new Checker(); final Locale locale = Locale.ROOT; checker.setLocaleCountry(locale.getCountry()); checker.setLocaleLanguage(locale.getLanguage()); checker.setModuleClassLoader(Thread.currentThread().getContextClassLoader()); checker.configure(checkerConfig); checker.addListener(new BriefLogger(stream)); return checker; }
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: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:com.ofalvai.bpinfo.ui.alertlist.AlertListPresenter.java
/** * Gets the current language's language code. * If a language has been set in the preferences, it reads the value from SharedPreferences. * If it has been set to "auto" or unset, it decides based on the current locale, using "en" for * any other language than Hungarian ("hu") * @return The app's current language's code. *//*from w w w .java 2s. c om*/ @NonNull private String getCurrentLanguageCode() { String languageCode = mSharedPreferences.getString(mContext.getString(R.string.pref_key_language), mContext.getString(R.string.pref_key_language_auto)); if (languageCode.equals(mContext.getString(R.string.pref_key_language_auto))) { Locale locale = Locale.getDefault(); if (locale.getLanguage().equals(AlertSearchContract.LANG_HU)) { languageCode = AlertSearchContract.LANG_HU; } else { languageCode = AlertSearchContract.LANG_EN; } } return languageCode; }
From source file:com.doculibre.constellio.lucene.impl.SkosIndexHelperImpl.java
@Override protected Field[] createIndexFields() { List<Field> fields = new ArrayList<Field>(); fields.add(new StringField(ID, "", Field.Store.YES)); fields.add(new StringField(THESAURUS_ID, "", Field.Store.YES)); Field prefLabelField = createDefaultIndexField(PREF_LABEL); prefLabelField.setBoost(4.0F);//w w w .j a v a 2 s .c o m fields.add(prefLabelField); fields.add(createDefaultIndexField(ALT_LABEL)); for (Locale locale : ConstellioSpringUtils.getSupportedLocales()) { String suffix = "_" + locale.getLanguage(); Field prefLabelLocaleField = createDefaultIndexField(PREF_LABEL + suffix); prefLabelLocaleField.setBoost(4.0F); fields.add(prefLabelLocaleField); fields.add(createDefaultIndexField(ALT_LABEL + suffix)); } return fields.toArray(new Field[0]); }
From source file:com.limegroup.gnutella.gui.init.LanguagePanel.java
private Locale guessLocale(Locale[] locales) { String[] language = guessLanguage(); Locale result = null;/*from w ww . ja v a2 s .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:edu.ku.brc.af.core.SchemaI18NService.java
/** * @param lang/* ww w. ja v a 2 s . co m*/ * @param country * @param variant * @return */ public Locale getLocaleByLangCountry(final String lang, final String country, final String variant) { if (lang != null) { for (Locale l : locales) { if (l.getLanguage().equals(lang)) { if (country == null && variant == null) { return l; } if (l.getCountry() != null && l.getCountry().equals(country)) { if (variant == null) { return l; } if (l.getVariant() != null && l.getVariant().equals(variant)) { return l; } } } } } return null; }
From source file:de.alpharogroup.lang.PropertiesUtils.java
/** * Load the properties file from the given class object. The filename from the properties file * is the same as the simple name from the class object and it looks at the same path as the * given class object. If locale is not null than the language will be added to the filename * from the properties file.//from w w w .j a v a 2 s. c om * * @param clazz * the clazz * @param locale * the locale * @return the properties * @throws IOException * Signals that an I/O exception has occurred. */ public static Properties loadPropertiesFromClassObject(final Class<?> clazz, final Locale locale) throws IOException { if (null == clazz) { throw new IllegalArgumentException("Class object must not be null!!!"); } StringBuilder propertiesName = new StringBuilder(); Properties properties = null; String language = null; String filename = null; String pathAndFilename = null; File propertiesFile = null; String absoluteFilename = null; final String packagePath = PackageUtils.getPackagePathWithSlash(clazz); final List<String> missedFiles = new ArrayList<>(); if (null != locale) { propertiesName.append(clazz.getSimpleName()); language = locale.getLanguage(); if (null != language && !language.isEmpty()) { propertiesName.append("_").append(language); } final String country = locale.getCountry(); if (null != country && !country.isEmpty()) { propertiesName.append("_").append(country); } propertiesName.append(FileExtension.PROPERTIES.getExtension()); filename = propertiesName.toString().trim(); pathAndFilename = packagePath + filename; URL url = ClassExtensions.getResource(clazz, filename); if (url != null) { absoluteFilename = url.getFile(); } else { missedFiles.add("File with filename '" + filename + "' does not exists."); } if (null != absoluteFilename) { propertiesFile = new File(absoluteFilename); } if (null != propertiesFile && propertiesFile.exists()) { properties = PropertiesUtils.loadProperties(pathAndFilename); } else { propertiesName = new StringBuilder(); if (null != locale) { propertiesName.append(clazz.getSimpleName()); language = locale.getLanguage(); if (null != language && !language.isEmpty()) { propertiesName.append("_").append(language); } propertiesName.append(FileExtension.PROPERTIES.getExtension()); filename = propertiesName.toString().trim(); pathAndFilename = packagePath + filename; url = ClassExtensions.getResource(clazz, filename); if (url != null) { absoluteFilename = url.getFile(); } else { missedFiles.add("File with filename '" + filename + "' does not exists."); } if (null != absoluteFilename) { propertiesFile = new File(absoluteFilename); } if (null != propertiesFile && propertiesFile.exists()) { properties = PropertiesUtils.loadProperties(pathAndFilename); } } } } if (null == properties) { propertiesName = new StringBuilder(); propertiesName.append(clazz.getSimpleName()).append(FileExtension.PROPERTIES.getExtension()); filename = propertiesName.toString().trim(); pathAndFilename = packagePath + filename; final URL url = ClassExtensions.getResource(clazz, filename); if (url != null) { absoluteFilename = url.getFile(); } else { properties = PropertiesUtils.loadProperties(pathAndFilename); missedFiles.add("File with filename '" + filename + "' does not exists."); } if (null != absoluteFilename) { propertiesFile = new File(absoluteFilename); } if (null != propertiesFile && propertiesFile.exists()) { properties = PropertiesUtils.loadProperties(pathAndFilename); } } if (properties == null) { for (final String string : missedFiles) { LOGGER.info(string); } } return properties; }
From source file:org.iti.agrimarket.view.OfferProductsController.java
@RequestMapping(value = { "offers.htm" }) public String OfferProducts(HttpServletRequest request, @RequestParam(value = "lang", required = false) Locale locale, @RequestParam(value = "name", required = false) String productName, @RequestParam(value = "category", required = false) Integer categoryName, Model model) { locale = LocaleContextHolder.getLocale(); String language = locale.getLanguage(); List<UserOfferProductFixed> offerproducts = null; System.out.println("language!!!!!!!!!!!!!!!" + language); if (productName != null && !productName.equals("")) { offerproducts = offerService.getOffersByProduct(productName); } else if (categoryName != null && categoryName != 0) { offerproducts = offerService.getOffersByCategory(categoryName); } else {// w ww .j ava 2s . c om offerproducts = offerService.getAllOfferProducts(); } model.addAttribute("getAllOfferProducts", offerproducts); model.addAttribute("lang", locale); return "offers_page"; }