List of usage examples for java.util Locale setDefault
public static synchronized void setDefault(Locale newLocale)
From source file:ca.nines.ise.cmd.Annotations.java
/** * {@inheritDoc}// w ww. j a v a2s .c o m */ @ErrorCode(code = { "dom.errors" }) @Override public void execute(CommandLine cmd) throws Exception { Log log = Log.getInstance(); Locale.setDefault(Locale.ENGLISH); PrintStream logOut = new PrintStream(System.out, true, "UTF-8"); if (cmd.hasOption("l")) { logOut = new PrintStream(new FileOutputStream(cmd.getOptionValue("l")), true, "UTF-8"); } String args[] = getArgList(cmd); File docFile = new File(args[0]); if (!docFile.exists()) { System.err.println("Cannot read document " + docFile.getCanonicalPath()); System.exit(1); } File annFile = new File(args[1]); if (!annFile.exists()) { System.err.println("Cannot read annotations " + annFile.getCanonicalPath()); System.exit(1); } DOM dom = new DOMBuilder(docFile).build(); if (dom.getStatus() != DOM.DOMStatus.ERROR) { Annotation annotation = Annotation.builder().from(annFile).build(); AnnotationValidator av = new AnnotationValidator(); av.validate(dom, annotation); } else { Message m = Message.builder("dom.errors").setSource(dom.getSource()).build(); log.add(m); } if (log.count() > 0) { logOut.print(log); } }
From source file:org.gcaldaemon.gui.Messages.java
public static final boolean setUserLocale(Locale locale) { try {/*from w w w . jav a 2s. co m*/ userResourceBundle = null; String programDir = System.getProperty("gcaldaemon.program.dir", "/Progra~1/GCALDaemon"); File langDir = new File(programDir, "lang"); if (!langDir.isDirectory()) { langDir.mkdir(); return false; } File msgFile = new File(langDir, "messages-" + locale.getLanguage().toLowerCase() + ".txt"); if (!msgFile.isFile()) { return false; } InputStream in = new BufferedInputStream(new FileInputStream(msgFile)); userResourceBundle = new PropertyResourceBundle(in); in.close(); userLocale = locale; Locale.setDefault(locale); return true; } catch (Exception ignored) { log.error("Unable to load messages!", ignored); } return false; }
From source file:org.squale.squaleweb.resources.WebMessages.java
/** * Retourne la chane de caractre identifie par la cl. * // ww w.j a v a2 s .com * @param pLocale locale * @param pKey nom de la cl. * @return la chane associe. */ public static String getString(Locale pLocale, String pKey) { String value = null; try { // On modifie la locale par dfaut pour rcuprer // notre fichier properties par dfaut (ApplicationResources.properties) dans le cas // o il n'y a pas de ressource pour la locale passe en paramtre Locale.setDefault(new Locale("")); ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_NAME, pLocale); value = bundle.getString(pKey); if (value == null) { value = DataBaseMessages.getMessage(pLocale, pKey); } } catch (MissingResourceException e) { value = DataBaseMessages.getMessage(pLocale, pKey); } return value; }
From source file:org.pdfsam.ui.dashboard.preference.PreferenceAppearencePaneTest.java
@Override protected Parent getRootNode() { Locale.setDefault(Locale.ENGLISH); PreferenceComboBox<LocaleKeyValueItem> localeCombo = new PreferenceComboBox<>(StringUserPreference.LOCALE, userContext);//from w w w . j a v a 2 s. c o m localeCombo.setId("localeCombo"); PreferenceComboBox<KeyStringValueItem<String>> themeCombo = new PreferenceComboBox<>( StringUserPreference.THEME, userContext); PreferenceComboBox<KeyStringValueItem<String>> startupModuleCombo = new PreferenceComboBox<>( StringUserPreference.STARTUP_MODULE, userContext); PreferenceAppearencePane victim = new PreferenceAppearencePane(localeCombo, themeCombo, startupModuleCombo); victim.setId("victim"); return victim; }
From source file:com.github.fielddb.storybook.ui.StoryBookSubExperiment.java
/** * Forces the locale for the duration of the app to the language needed for * that version of the Test//ww w . j a va2 s . c o m * * @param lang * @return */ public String forceLocale(String lang) { if (lang.equals(Locale.getDefault().getLanguage())) { this.language = Locale.getDefault(); return Locale.getDefault().getDisplayLanguage(); } Configuration config = this.getBaseContext().getResources().getConfiguration(); Locale locale = new Locale(lang); Locale.setDefault(locale); config.locale = locale; this.getBaseContext().getResources().updateConfiguration(config, this.getBaseContext().getResources().getDisplayMetrics()); this.language = Locale.getDefault(); return Locale.getDefault().getDisplayLanguage(); }
From source file:com.relicum.ipsum.Locale.LocaleManager.java
/** * Set new locale/*from w w w.j a va2 s. c o m*/ * * @param langCode the lang code * @param countryCode the country code */ public void setLocale(String langCode, String countryCode) { Locale.setDefault(new Locale(langCode, countryCode)); }
From source file:fitnesse.responders.files.FileResponderTest.java
@After public void tearDown() throws Exception { if (response != null) response.sendTo(new MockResponseSender()); SampleFileUtility.deleteSampleFiles(); Locale.setDefault(saveLocale); }
From source file:org.openoffice.plugin.core.model.UnoPackageTest.java
/** * Here we create a tmpdir with some files for testing. * * @throws IOException Signals that an I/O exception has occurred. */// w w w .ja va 2 s . co m @BeforeClass public static void setUpTmpDir() throws IOException { tmpDir = new File(System.getProperty("java.io.tmpdir", "/tmp"), "oxttest" + System.currentTimeMillis()); assertTrue("can't create " + tmpDir, tmpDir.mkdir()); assertTrue(tmpDir + " is not a directory", tmpDir.isDirectory()); for (int i = 0; i < filenames.length; i++) { addToTmpDir(filenames[i], filenames[i] + " created at " + new Date()); } log.info(tmpDir + " with " + filenames.length + " files created"); Locale.setDefault(Locale.ENGLISH); log.info("Locale=" + Locale.getDefault()); }
From source file:org.alfresco.error.AlfrescoRuntimeExceptionTest.java
@Override protected void setUp() throws Exception { // Re-set the current locale to be the default Locale.setDefault(Locale.ENGLISH); I18NUtil.setLocale(Locale.getDefault()); }
From source file:net.pms.test.RendererConfigurationTest.java
@Before public void setUp() { // Silence all log messages from the PMS code that is being tested LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); context.reset();/*from w w w. ja va2 s. co m*/ // Set locale to EN to ignore translations for renderers Locale.setDefault(Locale.ENGLISH); // Cases that are too generic should not match anything testCases.put("User-Agent: UPnP/1.0 DLNADOC/1.50", null); testCases.put("User-Agent: Unknown Renderer", null); testCases.put("X-Unknown-Header: Unknown Content", null); // AirPlayer: testCases.put("User-Agent: AirPlayer/1.0.09 CFNetwork/485.13.9 Darwin/11.0.0", "AirPlayer"); testCases.put("User-Agent: Lavf52.54.0", "AirPlayer"); // BraviaEX: testCases.put("X-AV-Client-Info: av=5.0; cn=\"Sony Corporation\"; mn=\"BRAVIA KDL-32CX520\"; mv=\"1.7\";", "Sony Bravia EX"); // DLinkDSM510: testCases.put("User-Agent: DLNADOC/1.50 INTEL_NMPR/2.1", "D-Link DSM-510"); // iPad-iPhone: testCases.put("User-Agent: 8player lite 2.2.3 (iPad; iPhone OS 5.0.1; nl_NL)", "iPad / iPhone"); testCases.put("User-Agent: yxplayer2%20lite/1.2.7 CFNetwork/485.13.9 Darwin/11.0.0", "iPad / iPhone"); testCases.put("User-Agent: MPlayer 1.0rc4-4.2.1", "iPad / iPhone"); testCases.put("User-Agent: NSPlayer/4.1.0.3856", "iPad / iPhone"); // Philips: testCases.put("User-Agent: Allegro-Software-WebClient/4.61 DLNADOC/1.00", "Philips Aurea"); // PhilipsPFL: testCases.put("User-Agent: Windows2000/0.0 UPnP/1.0 PhilipsIntelSDK/1.4 DLNADOC/1.50", "Philips TV"); // PS3: testCases.put("User-Agent: PLAYSTATION 3", "Playstation 3"); testCases.put( "X-AV-Client-Info: av=5.0; cn=\"Sony Computer Entertainment Inc.\"; mn=\"PLAYSTATION 3\"; mv=\"1.0\"", "Playstation 3"); // Realtek: // FIXME: Actual conflict here! Popcorn Hour is returned... //testCases.put("User-Agent: POSIX UPnP/1.0 Intel MicroStack/1.0.2718, RealtekMediaCenter, DLNADOC/1.50", "Realtek"); testCases.put("User-Agent: RealtekVOD neon/0.27.2", "Realtek"); // SamsungAllShare: testCases.put("User-Agent: SEC_HHP_[HT]D5500/1.0", "Samsung AllShare"); testCases.put("User-Agent: SEC_HHP_[TV]UE32D5000/1.0", "Samsung AllShare"); testCases.put("User-Agent: SEC_HHP_ Family TV/1.0", "Samsung AllShare"); testCases.put("User-Agent: SEC_HHP_[TV]PS51D6900/1.0", "Samsung AllShare"); testCases.put("User-Agent: DLNADOC/1.50 SEC_HHP_[TV]UE32D5000/1.0", "Samsung AllShare"); testCases.put("User-Agent: DLNADOC/1.50 SEC_HHP_[TV]UN55D6050/1.0", "Samsung AllShare"); testCases.put("User-Agent: DLNADOC/1.50 SEC_HHP_ Family TV/1.0", "Samsung AllShare"); // WDTVLive: testCases.put("User-Agent: INTEL_NMPR/2.1 DLNADOC/1.50 Intel MicroStack/1.0.1423", "WD TV Live"); // XBMC: testCases.put("User-Agent: XBMC/10.0 r35648 (Mac OS X; 11.2.0 x86_64; http://www.xbmc.org)", "XBMC"); testCases.put("User-Agent: Platinum/0.5.3.0, DLNADOC/1.50", "XBMC"); }