List of usage examples for java.util Locale setDefault
public static synchronized void setDefault(Locale newLocale)
From source file:org.ado.biblio.desktop.db.DatabaseConnectionTest.java
public void setUp() throws Exception { FileUtils.deleteQuietly(DATABASE_FILE_TMP); if (DATABASE_FILE.exists()) { FileUtils.moveFile(DATABASE_FILE, DATABASE_FILE_TMP); }/*from w ww. j a v a 2 s . c o m*/ Locale.setDefault(Locale.ENGLISH); }
From source file:net.sf.dynamicreports.test.jasper.chart.ShowValuesChartDataTest.java
@Override protected void configureReport(JasperReportBuilder rb) { TextColumnBuilder<String> column1; TextColumnBuilder<Integer> column2; TextColumnBuilder<Integer> column3; TextColumnBuilder<Date> column4; Locale.setDefault(Locale.ENGLISH); rb.setPageFormat(PageType.A2, PageOrientation.PORTRAIT) .columns(column1 = col.column("Column1", "field1", String.class), column2 = col.column("Column2", "field2", Integer.class), column3 = col.column("Column3", "field3", Integer.class), column4 = col.column("Column4", "field4", Date.class)) .summary(cmp.horizontalList( cht.barChart().setShowValues(true).setCategory(column1).series(cht.serie(column2), cht.serie(column3)), cht.bar3DChart().setShowValues(true).setValuePattern("#,##0.#").setCategory(column1) .series(cht.serie(column2), cht.serie(column3)), cht.stackedBarChart().setShowValues(true).setCategory(column1).series(cht.serie(column2), cht.serie(column3)), cht.stackedBar3DChart().setShowValues(true).setCategory(column1).series(cht.serie(column2), cht.serie(column3))), cmp.horizontalList(/* w ww . ja va 2 s. co m*/ cht.areaChart().setShowValues(true).setCategory(column1).series(cht.serie(column3), cht.serie(column2)), cht.lineChart().setShowValues(true).setCategory(column1).series(cht.serie(column2), cht.serie(column3)), cht.groupedStackedBarChart().setShowValues(true).setCategory(column1) .series(cht.groupedSerie(column2).setGroup(column1).setSeries(column1))), cmp.horizontalList( cht.pieChart().setShowValues(true).setKey(column1).series(cht.serie(column2)), cht.pie3DChart().setShowValues(true).setValuePattern("#,##0.#").setKey(column1) .series(cht.serie(column2))), cmp.horizontalList( cht.xyBarChart().setShowValues(true).setXValue(column2) .series(cht.xySerie(column3)), cht.xyLineChart().setShowValues(true).setValuePattern("#,##0.#").setXValue(column2) .series(cht.xySerie(column3)), cht.scatterChart().setShowValues(true).setXValue(column2) .series(cht.xySerie(column3))), cmp.horizontalList(cht.timeSeriesChart().setShowValues(true).setTimePeriod(column4) .series(cht.serie(column2), cht.serie(column3)).setTimePeriodType(TimePeriod.DAY), cht.differenceChart().setShowValues(true).setTimePeriod(column4) .series(cht.serie(column2), cht.serie(column3)) .setTimePeriodType(TimePeriod.DAY), cht.xyStepChart().setShowValues(true).setValuePattern("#,##0.#").setXValue(column2) .series(cht.xySerie(column3)), cht.waterfallBarChart().setShowValues(true).setValuePattern("#,##0.#") .setCategory(column1).series(cht.serie(column2)))); }
From source file:org.squale.squaleweb.resources.WebMessages.java
/** * Retourne True si la cl demande est prsente et si elle contient bien un message * /*from w w w . j a va 2 s . c o m*/ * @param pKey nom de la cl * @return true si un message est prsent */ public static Boolean existString(String pKey) { Boolean valid = false; String value = null; Locale defaut = new Locale(""); Locale.setDefault(defaut); ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_NAME, defaut); try { value = bundle.getString(pKey); if (value == null) { value = DataBaseMessages.getMessage(defaut, pKey); } } catch (MissingResourceException e) { valid = false; } if (value != null) { valid = true; } return valid; }
From source file:org.marketcetera.util.log.I18NMessageProviderTest.java
@Test public void retrievals() { assertEquals("Hello", TestMessages.PROVIDER.getText(TestMessages.HELLO_MSG)); assertEquals("Hello World!", TestMessages.PROVIDER.getText(TestMessages.HELLO_TITLE, "World")); assertEquals("Bonjour", TestMessages.PROVIDER.getText(Locale.FRENCH, TestMessages.HELLO_MSG)); assertEquals("Bonjour Le Monde!", TestMessages.PROVIDER.getText(Locale.FRENCH, TestMessages.HELLO_TITLE, "Le Monde")); Locale saved = Locale.getDefault(); try {//from w w w . j a v a 2s . c o m Locale.setDefault(Locale.ROOT); assertEquals("Hello", TestMessages.PROVIDER.getText(Locale.GERMAN, TestMessages.HELLO_MSG)); Locale.setDefault(Locale.JAPANESE); assertEquals("Hello", TestMessages.PROVIDER.getText(Locale.GERMAN, TestMessages.HELLO_MSG)); Locale.setDefault(Locale.FRENCH); assertEquals("Bonjour", TestMessages.PROVIDER.getText(Locale.GERMAN, TestMessages.HELLO_MSG)); } finally { Locale.setDefault(saved); } assertEquals("Hello a {0} 'a' \"a\" b!", TestMessages.PROVIDER.getText(TestMessages.HELLO_ECHO, "a", "b")); assertEquals("Bonjour a {0} 'a' \"a\" {1}!", TestMessages.PROVIDER.getText(Locale.FRENCH, TestMessages.HELLO_ECHO, "a")); assertEquals("Bonjour a {0} 'a' \"a\" b!", TestMessages.PROVIDER.getText(Locale.FRENCH, TestMessages.HELLO_ECHO, "a", "b", "c")); assertEquals("There are no orders ma'am.", TestMessages.PROVIDER.getText(TestMessages.CHOICE_MSG, 0)); assertEquals("There is just one order ma'am.", TestMessages.PROVIDER.getText(TestMessages.CHOICE_MSG, 1)); assertEquals("There are 2 orders ma'am.", TestMessages.PROVIDER.getText(TestMessages.CHOICE_MSG, 2)); assertEquals("Pas des ordres ma'am.", TestMessages.PROVIDER.getText(Locale.FRENCH, TestMessages.CHOICE_MSG, 0)); assertEquals("Seulemont un ordre ma'am.", TestMessages.PROVIDER.getText(Locale.FRENCH, TestMessages.CHOICE_MSG, 1)); assertEquals("Il y a 2 ordres ma'am.", TestMessages.PROVIDER.getText(Locale.FRENCH, TestMessages.CHOICE_MSG, 2)); assertEquals("Hello {0}!", TestMessages.PROVIDER.getText(TestMessages.HELLO_TITLE, (Object[]) null)); assertEquals("Hello null!", TestMessages.PROVIDER.getText(TestMessages.HELLO_TITLE, (Object) null)); ActiveLocale.setProcessLocale(Locale.FRENCH); assertEquals("Bonjour", TestMessages.PROVIDER.getText(TestMessages.HELLO_MSG)); assertEquals("Bonjour Le Monde!", TestMessages.PROVIDER.getText(TestMessages.HELLO_TITLE, "Le Monde")); }
From source file:org.apache.james.imap.tester.base.AbstractSimpleScriptedTestProtocol.java
@After public void tearDown() throws Exception { super.tearDown(); Locale.setDefault(BASE_DEFAULT_LOCALE); }
From source file:org.apache.rave.portal.web.controller.MessageBundleController.java
public MessageBundleController() { clientMessagesCache = new HashMap<Locale, String>(); acceptHeaderLocaleResolver = new AcceptHeaderLocaleResolver(); clientMessagesResponseHeaders = new HttpHeaders(); // set the common response headers that will be used by the getClientMessages response clientMessagesResponseHeaders.setCacheControl("max-age=" + CLIENT_MESSAGE_BUNDLE_CACHE_CONTROL_MAX_AGE); clientMessagesResponseHeaders.setContentType(MediaType.parseMediaType(JAVASCRIPT_CONTENT_TYPE)); Locale.setDefault(Locale.ENGLISH); }
From source file:test.unit.be.fedict.eid.applet.MessagesTest.java
@Test public void testUnsupportedLanguageUnsupportedDefaultLanguage() throws Exception { Locale.setDefault(Locale.CHINESE); Locale locale = Locale.JAPANESE; Messages messages = new Messages(locale); String message = messages.getMessage(Messages.MESSAGE_ID.GENERIC_ERROR); LOG.debug("message: " + message); assertEquals("Generic Error.", message); }
From source file:uk.q3c.krail.i18n.DefaultPatternUtilityTest.java
@Test public void writeOut_locales_provided_all_keys() throws IOException { // given File testOutDir = new File(ResourceUtils.userTempDirectory(), "testOut"); if (testOutDir.exists()) { FileUtils.deleteQuietly(testOutDir); }//from www .j av a 2 s. c om File targetDir = new File(ResourceUtils.userTempDirectory(), "testOut/codeModel"); writer.setOptionWritePath(targetDir); Set<Locale> locales = new HashSet<>(); locales.add(Locale.GERMAN); locales.add(Locale.ITALIAN); locales.add(Locale.UK); locales.add(Locale.forLanguageTag("")); File referenceFile = new File(TestResource.testResourceRootDir("krail"), "Labels.ref"); File targetFile = new File(targetDir, "Labels.java"); File referenceFile_de = new File(TestResource.testResourceRootDir("krail"), "Labels_de.ref"); File targetFile_de = new File(targetDir, "Labels_de.java"); File referenceFile_it = new File(TestResource.testResourceRootDir("krail"), "Labels_it.ref"); File targetFile_it = new File(targetDir, "Labels_it.java"); File referenceFile_en_GB = new File(TestResource.testResourceRootDir("krail"), "Labels_en_GB.ref"); File targetFile_en_GB = new File(targetDir, "Labels_en_GB.java"); // this is to make sure that setting the default does not mess things up Locale.setDefault(Locale.CANADA_FRENCH); //when utility.writeOut(writer, LabelKey.class, locales, Optional.empty()); //then line 4 is the timestamp assertThat(FileTestUtil.compare(referenceFile, targetFile, 4)).isEqualTo(Optional.empty()); assertThat(FileTestUtil.compare(referenceFile_de, targetFile_de, 4)).isEqualTo(Optional.empty()); assertThat(FileTestUtil.compare(referenceFile_it, targetFile_it, 4)).isEqualTo(Optional.empty()); assertThat(FileTestUtil.compare(referenceFile_en_GB, targetFile_en_GB, 4)).isEqualTo(Optional.empty()); }
From source file:edu.ku.brc.specify.plugins.sgr.SGRResultsDisplay.java
public SGRResultsDisplay(int width, MatchResults results) { if (Main.m_settings == null) { Main.m_settings = new JSettings(true); Main.m_settings.load(/*from w w w .j a va 2 s . com*/ JPathHelper.addSeparator(System.getProperty("user.home")) + JSettings.SETTINGS_FILE, "1.8"); Main.m_sysLocale = Locale.getDefault(); if (Main.m_settings.getLocale().length() > 0) { Locale.setDefault(new Locale(Main.m_settings.getLocale())); } } SGRColumnOrdering columns = SGRColumnOrdering.getInstance(); String[] fields = columns.getFields(); DefaultTableModel resultsTableModel = new DefaultTableModel(columns.getHeadings(), 0); final List<List<Color>> rowColors = new LinkedList<List<Color>>(); for (Match result : results) { SGRRecord match = result.match; float score = result.score; float maxScore = 22.0f; //results.maxScore; List<Color> cellColors = new LinkedList<Color>(); List<String> data = new LinkedList<String>(); for (String field : fields) { if (field.equals("id")) { data.add(match.id); cellColors.add(SGRColors.colorForScore(score, maxScore)); } else if (field.equals("score")) { data.add(((Float) score).toString()); cellColors.add(SGRColors.colorForScore(score, maxScore)); } else { data.add(StringUtils.join(match.getFieldValues(field).toArray(), ';')); Float fieldContribution = result.fieldScoreContributions().get(field); Color color = SGRColors.colorForScore(score, maxScore, fieldContribution); cellColors.add(color); } } resultsTableModel.addRow(data.toArray()); rowColors.add(cellColors); } JTable table = createTable(resultsTableModel, rowColors); Dimension preferredSize = table.getPreferredSize(); preferredSize.width = Math.min((int) (0.9 * width), preferredSize.width); table.setPreferredScrollableViewportSize(preferredSize); table.getColumnModel().addColumnModelListener(this); add(new JScrollPane(table)); }