List of usage examples for java.util Locale CANADA_FRENCH
Locale CANADA_FRENCH
To view the source code for java.util Locale CANADA_FRENCH.
Click Source Link
From source file:com.netflix.imfutility.itunes.metadata.tv.TvMetadataXmlProviderTest.java
@Test public void testUpdateLocale() throws Exception { TvMetadataXmlProvider provider = new TvMetadataXmlProvider(); provider.setLocale(Locale.CANADA_FRENCH); assertEquals("fr-CA", provider.getRootElement().getLanguage().get(0)); assertEquals("fr-CA", provider.getRootElement().getVideo().get(0).getOriginalSpokenLocale().get(0)); }
From source file:hk.idv.kenson.jrconsole.Console.java
/** * //from w ww .jav a 2 s .c o m * @param localeString * @return */ private static Locale getLocale(String localeString) { if ("default".equals(localeString)) return Locale.getDefault(); if ("canada".equals(localeString)) return Locale.CANADA; if ("canada_french".equals(localeString)) return Locale.CANADA_FRENCH; if ("china".equals(localeString)) return Locale.CHINA; if ("chinese".equals(localeString)) return Locale.CHINESE; if ("english".equals(localeString)) return Locale.ENGLISH; if ("franch".equals(localeString)) return Locale.FRANCE; if ("german".equals(localeString)) return Locale.GERMAN; if ("germany".equals(localeString)) return Locale.GERMANY; if ("italian".equals(localeString)) return Locale.ITALIAN; if ("italy".equals(localeString)) return Locale.ITALY; if ("japan".equals(localeString)) return Locale.JAPAN; if ("japanese".equals(localeString)) return Locale.JAPANESE; if ("korea".equals(localeString)) return Locale.KOREA; if ("korean".equals(localeString)) return Locale.KOREAN; if ("prc".equals(localeString)) return Locale.PRC; if ("simplified_chinese".equals(localeString)) return Locale.SIMPLIFIED_CHINESE; if ("taiwan".equals(localeString)) return Locale.TAIWAN; if ("traditional_chinese".equals(localeString)) return Locale.TRADITIONAL_CHINESE; if ("uk".equals(localeString)) return Locale.UK; if ("us".equals(localeString)) return Locale.US; String parts[] = localeString.split("_", -1); if (parts.length == 1) return new Locale(parts[0]); else if (parts.length == 2) return new Locale(parts[0], parts[1]); else return new Locale(parts[0], parts[1], parts[2]); }
From source file:com.netflix.imfutility.itunes.metadata.film.FilmMetadataXmlProviderTest.java
@Test public void testUpdateLocale() throws Exception { FilmMetadataXmlProvider provider = new FilmMetadataXmlProvider(); provider.setLocale(Locale.CANADA_FRENCH); assertEquals("fr-CA", provider.getRootElement().getLanguage().get(0)); assertEquals("fr-CA", provider.getRootElement().getVideo().get(0).getOriginalSpokenLocale().get(0)); }
From source file:ca.oson.json.gson.functional.DefaultTypeAdaptersTest.java
public void testLocaleSerializationWithLanguageCountry() { Locale target = Locale.CANADA_FRENCH; assertEquals("\"fr_CA\"", oson.toJson(target)); }
From source file:ca.oson.json.gson.functional.DefaultTypeAdaptersTest.java
public void testLocaleDeserializationWithLanguageCountry() { String json = "\"fr_CA\""; Locale locale = oson.fromJson(json, Locale.class); // System.err.println(locale.toString()); assertEquals(Locale.CANADA_FRENCH, locale); }
From source file:org.alfresco.repo.node.NodeServiceTest.java
@Test public void testLocaleSupport() throws Exception { // Ensure that the root node has the default locale Locale locale = (Locale) nodeService.getProperty(rootNodeRef, ContentModel.PROP_LOCALE); assertNotNull("Locale property must occur on every node", locale); assertEquals("Expected default locale on the root node", I18NUtil.getLocale(), locale); assertTrue("Every node must have sys:localized", nodeService.hasAspect(rootNodeRef, ContentModel.ASPECT_LOCALIZED)); // Now switch to a specific locale and create a new node I18NUtil.setLocale(Locale.CANADA_FRENCH); // Create a node using an explicit locale NodeRef nodeRef1 = nodeService/* w ww . j ava 2s. com*/ .createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()), ContentModel.TYPE_CONTAINER, Collections.singletonMap(ContentModel.PROP_LOCALE, (Serializable) Locale.GERMAN)) .getChildRef(); assertTrue("Every node must have sys:localized", nodeService.hasAspect(nodeRef1, ContentModel.ASPECT_LOCALIZED)); assertEquals("Didn't set the explicit locale during create. ", Locale.GERMAN, nodeService.getProperty(nodeRef1, ContentModel.PROP_LOCALE)); // Create a node using the thread's locale NodeRef nodeRef2 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()), ContentModel.TYPE_CONTAINER).getChildRef(); assertTrue("Every node must have sys:localized", nodeService.hasAspect(nodeRef2, ContentModel.ASPECT_LOCALIZED)); assertEquals("Didn't set the locale during create. ", Locale.CANADA_FRENCH, nodeService.getProperty(nodeRef2, ContentModel.PROP_LOCALE)); // Switch Locale and modify ml:text property I18NUtil.setLocale(Locale.CHINESE); nodeService.setProperty(nodeRef2, ContentModel.PROP_DESCRIPTION, "Chinese description"); I18NUtil.setLocale(Locale.FRENCH); nodeService.setProperty(nodeRef2, ContentModel.PROP_DESCRIPTION, "French description"); // Expect that we have MLText (if we are ML aware) boolean wasMLAware = MLPropertyInterceptor.setMLAware(true); try { MLText checkDescription = (MLText) nodeService.getProperty(nodeRef2, ContentModel.PROP_DESCRIPTION); assertEquals("Chinese description", checkDescription.getValue(Locale.CHINESE)); assertEquals("French description", checkDescription.getValue(Locale.FRENCH)); } finally { MLPropertyInterceptor.setMLAware(wasMLAware); } // But the node locale must not have changed assertEquals("Node modification should not affect node locale. ", Locale.CANADA_FRENCH, nodeService.getProperty(nodeRef2, ContentModel.PROP_LOCALE)); // Now explicitly set the node's locale nodeService.setProperty(nodeRef2, ContentModel.PROP_LOCALE, Locale.ITALY); assertEquals("Node locale must be settable. ", Locale.ITALY, nodeService.getProperty(nodeRef2, ContentModel.PROP_LOCALE)); // But mltext must be unchanged assertEquals("Canada-French must be closest to French. ", "French description", nodeService.getProperty(nodeRef2, ContentModel.PROP_DESCRIPTION)); // Finally, ensure that setting Locale to 'null' is takes the node back to its original locale nodeService.setProperty(nodeRef2, ContentModel.PROP_LOCALE, null); assertEquals("Node locale set to 'null' does nothing. ", Locale.ITALY, nodeService.getProperty(nodeRef2, ContentModel.PROP_LOCALE)); nodeService.removeProperty(nodeRef2, ContentModel.PROP_LOCALE); assertEquals("Node locale removal does nothing. ", Locale.ITALY, nodeService.getProperty(nodeRef2, ContentModel.PROP_LOCALE)); // Mass-set the properties, changing the locale in the process Map<QName, Serializable> props = nodeService.getProperties(nodeRef2); props.put(ContentModel.PROP_LOCALE, Locale.GERMAN); nodeService.setProperties(nodeRef2, props); assertEquals("Node locale not set in setProperties(). ", Locale.GERMAN, nodeService.getProperty(nodeRef2, ContentModel.PROP_LOCALE)); }
From source file:investiagenofx2.view.InvestiaGenOFXController.java
private void getTransactionsFromWeb() { try {//from www . ja va 2s .co m if (!htmlPage.getUrl().toString().contains("/TransactionReports/Select")) { if (InvestiaGenOFX.debug) { htmlPage = InvestiaGenOFX.getWebClient() .getPage(InvestiaGenOFX.debugFullPath + "-Transactions.htm"); } else { htmlPage = InvestiaGenOFX.getWebClient() .getPage(txt_investiaURL.getText() + "/TransactionReports/Select" + "?wcag=true"); waitForGeneratedTransactions(); } } @SuppressWarnings(("unchecked")) List<HtmlHeading4> h4from = (List<HtmlHeading4>) htmlPage .getByXPath("//h4[contains(text(),'Priode: de ')]"); String from = h4from.get(0).asText(); int index = from.indexOf("Priode: de "); LocalDate selFromDate = LocalDate.parse(from.substring(index + 12, index + 12 + 10)); if (dtp_lastDate.getValue().isBefore(selFromDate)) { @SuppressWarnings(("unchecked")) List<HtmlForm> forms = (List<HtmlForm>) htmlPage.getByXPath("//form"); HtmlForm form = forms.get(1); HtmlTextInput selPerFrom = form.getInputByName("selPerFrom"); selPerFrom.setValueAttribute(dtp_lastDate.getValue().toString()); HtmlAnchor generate = (HtmlAnchor) form.getByXPath("//a[contains(@class, 'btn-investia-blue')]") .get(0); if (InvestiaGenOFX.debug) { htmlPage = InvestiaGenOFX.getWebClient() .getPage(InvestiaGenOFX.debugFullPath + "-Transactions.htm"); } else { htmlPage = generate.click(); waitForGeneratedTransactions(); } } HtmlTable htmlTable = (HtmlTable) htmlPage.getElementById("tblTransactionReports"); if (htmlTable == null) { return; } for (int i = 0; i < htmlTable.getRowCount(); i++) { LocalDate transacDate = LocalDate.parse(htmlTable.getCellAt(i, 0).getTextContent(), DateTimeFormatter.ofPattern("dd MMM yyyy", Locale.CANADA_FRENCH)); if (transacDate.isBefore(dtp_lastDate.getValue())) { break; } String transacType = htmlTable.getCellAt(i, 2).getTextContent(); String[] token = transacType.split("[\\-/(]"); switch (token[0].replace(" ", "")) { case "Dividendes": transacType = "Distribution"; break; case "Achat": case "changeentrant": case "Prlvementautomatique": case "Transfertentrantdecourtier": case "Transfertexterneentrant": case "Transfertinterneentrant": transacType = "Purchase"; break; case "changesortant": case "Rachat": case "Transfertexternesortant": case "Transf.int.sort.": case "Transf.Int.sortant": case "Transfertinternesortant": transacType = "Switch Out"; break; case "Dpt": transacType = "Credit"; break; case "Retrait": case "Retenue": transacType = "Debit"; break; case "Crditenespces": case "Entred'espces": case "Fraisd'administration": case "Sortied'espces": case "Transfertd'espcesentrant": case "Transfertd'espcessortant": continue; default: try { throw new MyOwnException("Type de transaction non prise en charge: " + transacType.trim()); } catch (MyOwnException ex) { Logger.getLogger(OFXUtilites.class.getName()).log(Level.SEVERE, null, ex); continue; } } String transacAccount = accountOwnerName.split(" ")[0] + "\\" + htmlTable.getCellAt(i, 1).getTextContent(); String symbol = htmlTable.getCellAt(i, 3).getTextContent(); String unit = htmlTable.getCellAt(i, 5).getTextContent().replaceAll("[^0-9,]", "").replace(",", "."); String fitid = ""; String price = "0.00"; String amount; if ("Credit".equals(transacType) || "Debit".equals(transacType)) { amount = htmlTable.getCellAt(i, 9).getTextContent().replaceAll("[^0-9,]", "").replace(",", "."); fitid = StringUtils.stripAccents(htmlTable.getCellAt(i, 2).getTextContent()); } else { amount = htmlTable.getCellAt(i, 10).getTextContent().replaceAll("[^0-9,]", "").replace(",", "."); price = Float.toString(Float.parseFloat(amount) / Float.parseFloat(unit)); } if (PropertiesInit.getLinkAccountsTransac().indexOf(transacAccount) < 0) { linkAccountTransac(transacAccount); } int idxAccount = linkAccountToLocalAccountIndex[PropertiesInit.getLinkAccountsTransac() .indexOf(transacAccount)]; accounts.get(idxAccount) .add(new Transaction(transacDate, transacType, amount, fitid, symbol, unit, price, "")); } } catch (Exception ex) { Logger.getLogger(InvestiaGenOFXController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.alfresco.rest.framework.tests.core.SerializeTests.java
@Test public void testSerializeBinaryProperty() throws IOException { BinaryProperty prop = new BinaryProperty(Format.JSON.mimetype(), "UTF-8"); String out = writeResponse(prop); assertTrue("Only show the mimeType", out.equals("{\"mimeType\":\"application/json\"}")); prop = new BinaryProperty(Format.XML.mimetype(), "UTF-8", 45, null); out = writeResponse(prop);//ww w. java 2s . c om assertTrue("Type is xml.", StringUtils.contains(out, "\"mimeType\":\"text/xml\"")); assertTrue("Size must be serialized.", StringUtils.contains(out, "\"sizeInBytes\":45")); prop = new BinaryProperty(Format.XML.mimetype(), "UTF-8", 99, Locale.CANADA_FRENCH); out = writeResponse(prop); assertFalse("Locale should not be serialized", StringUtils.contains(out, "\"locale\"")); //Check binary properties serialize ok as part of a bean. Flock flock = new Flock("myflock", 50, null, prop); out = writeResponse(flock); assertFalse("Locale should not be serialized", StringUtils.contains(out, "\"locale\"")); assertTrue("Type is xml.", StringUtils.contains(out, "\"mimeType\":\"text/xml\"")); assertTrue("Size must be serialized.", StringUtils.contains(out, "\"sizeInBytes\":99")); }
From source file:investiagenofx2.view.InvestiaGenOFXController.java
private void getAccountsInvestmentsFromWeb() { @SuppressWarnings(("unchecked")) List<HtmlTable> tables = (List<HtmlTable>) htmlPage .getByXPath("//table[contains(@class, 'table-striped')]"); @SuppressWarnings(("unchecked")) List<HtmlDivision> divBalancesAs = (List<HtmlDivision>) htmlPage .getByXPath("//div[contains(text(),'Soldes au')]"); LocalDate balancesAs = LocalDate.parse(divBalancesAs.get(0).asText().replace("Soldes au ", ""), DateTimeFormatter.ofPattern("dd MMMM yyyy", Locale.CANADA_FRENCH)); int i = 0;//from w w w .ja v a2 s. c o m for (HtmlTable table : tables) { if (!table.asText().contains("Numro de \r\n compte")) { continue; } if (accounts.get(i).getAccountID() == null) { accounts.get(i).setAccountID(table.getCellAt(1, 3).getTextContent()); } Float total = 0f; for (int j = 1; j < table.getRowCount(); j++) { String symbol = table.getCellAt(j, 1).getTextContent(); String name = table.getCellAt(j, 0).getTextContent(); String quantity = table.getCellAt(j, 5).getTextContent().replaceAll("[^0-9,]", "").replace(",", "."); String lastPrice = table.getCellAt(j, 6).getTextContent().replaceAll("[^0-9,]", "").replace(",", "."); String marketValue = table.getCellAt(j, 7).getTextContent().replaceAll("[^0-9,]", "").replace(",", "."); Investment investment = new Investment(symbol, name, quantity, lastPrice, marketValue); accounts.get(i).add(investment); total += Float.valueOf(marketValue); } String totalString = String.format("%.02f", total); Investment investment = new Investment("", "Total", totalString, "1.00", totalString); accounts.get(i).add(investment); if (!balancesAs.equals(dataAsDate)) accounts.get(i).setBalanceDate(balancesAs); i++; } if (!balancesAs.equals(dataAsDate)) dataAsDate = balancesAs; }
From source file:fr.paris.lutece.portal.web.user.AdminUserJspBeanTest.java
public void testDoModifyDefaultUserParameterValues() throws AccessDeniedException, UserNotSignedException { String origDefaultStatus = DefaultUserParameterHome.findByKey(AdminUserService.DSKEY_DEFAULT_USER_STATUS); String origDefaultLevel = DefaultUserParameterHome.findByKey(AdminUserService.DSKEY_DEFAULT_USER_LEVEL); String origDefaultNotification = DefaultUserParameterHome .findByKey(AdminUserService.DSKEY_DEFAULT_USER_NOTIFICATION); String origDefaultLanguage = DefaultUserParameterHome .findByKey(AdminUserService.DSKEY_DEFAULT_USER_LANGUAGE); AdminUserJspBean bean = new AdminUserJspBean(); MockHttpServletRequest request = new MockHttpServletRequest(); AdminUser user = getUserToModify();/*from w ww . j a va 2s . c o m*/ AdminAuthenticationService.getInstance().registerUser(request, user); bean.init(request, "CORE_USERS_MANAGEMENT"); request.setParameter("status", Integer.toString(AdminUser.ANONYMIZED_CODE)); request.setParameter("user_level", "10"); request.setParameter("notify_user", "false"); request.setParameter("language", Locale.CANADA_FRENCH.toString()); request.addParameter(SecurityTokenService.PARAMETER_TOKEN, SecurityTokenService.getInstance().getToken(request, "ManageAdvancedParameters.jsp")); try { bean.doModifyDefaultUserParameterValues(request); assertEquals(Integer.toString(AdminUser.ANONYMIZED_CODE), DefaultUserParameterHome.findByKey(AdminUserService.DSKEY_DEFAULT_USER_STATUS)); assertEquals("10", DefaultUserParameterHome.findByKey(AdminUserService.DSKEY_DEFAULT_USER_LEVEL)); assertEquals("false", DefaultUserParameterHome.findByKey(AdminUserService.DSKEY_DEFAULT_USER_NOTIFICATION)); assertEquals(Locale.CANADA_FRENCH.toString(), DefaultUserParameterHome.findByKey(AdminUserService.DSKEY_DEFAULT_USER_LANGUAGE)); } finally { DefaultUserParameterHome.update(AdminUserService.DSKEY_DEFAULT_USER_STATUS, origDefaultStatus); DefaultUserParameterHome.update(AdminUserService.DSKEY_DEFAULT_USER_LEVEL, origDefaultLevel); DefaultUserParameterHome.update(AdminUserService.DSKEY_DEFAULT_USER_NOTIFICATION, origDefaultNotification); DefaultUserParameterHome.update(AdminUserService.DSKEY_DEFAULT_USER_LANGUAGE, origDefaultLanguage); disposeOfUser(user); } }