List of usage examples for org.springframework.context.i18n LocaleContextHolder setLocale
public static void setLocale(@Nullable Locale locale)
From source file:com.db2eshop.launcher.Launcher.java
/** * <p>main.</p>/*from www. j av a2 s.co m*/ * * @param args an array of {@link java.lang.String} objects. */ public static void main(String[] args) { LocaleContextHolder.setLocale(Locale.US); }
From source file:org.pgptool.gui.app.EntryPoint.java
public static void main(String[] args) { DOMConfigurator.configure(EntryPoint.class.getClassLoader().getResource("pgptool-gui-log4j.xml")); log.info("EntryPoint first scream"); SplashScreenView splashScreenView = null; try {//from w w w.ja v a2 s. c om args = OsNativeApiResolver.resolve().getCommandLineArguments(args); if (!isContinueStartupSequence(args)) { System.exit(0); return; } UiUtils.setLookAndFeel(); splashScreenView = new SplashScreenView(); SwingPmSettings.setBindingContextFactory(new BindingContextFactoryImpl()); // Startup application context String[] contextPaths = new String[] { "app-context.xml" }; currentApplicationContext = new ClassPathXmlApplicationContext(contextPaths); log.debug("App context loaded"); LocaleContextHolder.setLocale(new Locale(System.getProperty("user.language"))); currentApplicationContext.registerShutdownHook(); log.debug("Shutdown hook registered"); // Now startup application logic EntryPoint entryPoint = currentApplicationContext.getBean(EntryPoint.class); log.debug("EntryPoint bean resolved"); prefetchKeys(); splashScreenView.close(); splashScreenView = null; entryPoint.startUp(args); rootPmStatic = entryPoint.getRootPm(); log.debug("RootPM bean resolved"); processPendingArgsIfAny(rootPmStatic); } catch (Throwable t) { log.error("Failed to startup application", t); reportAppInitFailureMessageToUser(t); // throw new RuntimeException("Application failed to start", t); System.exit(-1); } finally { if (splashScreenView != null) { splashScreenView.close(); splashScreenView = null; } } }
From source file:nu.yona.server.test.util.BaseSpringIntegrationTest.java
@BeforeClass public static void setUpForAll() { LocaleContextHolder.setLocale(Translator.EN_US_LOCALE); }
From source file:nu.yona.server.batch.quartz.jobs.PinResetConfirmationCodeSenderQuartzJob.java
@Override public void execute(JobExecutionContext context) { JobDataMap jobData = context.getMergedJobDataMap(); LocaleContextHolder.setLocale(getLocale(jobData)); pinResetRequestService.sendPinResetConfirmationCode(getUserId(jobData)); }
From source file:com.inkubator.sms.gateway.util.SpringSecurityContextListenerFix.java
@Override public void requestInitialized(ServletRequestEvent requestEvent) { super.requestInitialized(requestEvent); HttpServletRequest request = (HttpServletRequest) requestEvent.getServletRequest(); HttpSession sesion = request.getSession(false); Locale idioma;/*w w w . j av a 2 s . c o m*/ if (sesion != null) { // System.out.println(sesion.getAttribute(HRMConstant.BAHASA_ACTIVE).toString()); if (sesion.getAttribute(SMSGATEWAY.BAHASA_ACTIVE) != null) { idioma = new Locale(sesion.getAttribute(SMSGATEWAY.BAHASA_ACTIVE).toString()); } else { idioma = new Locale("in"); } LocaleContextHolder.setLocale(idioma); } else { idioma = new Locale("in"); LocaleContextHolder.setLocale(idioma); } }
From source file:org.openhie.openempi.util.ConvertUtilTest.java
public void testGetInternationalDatePattern() { LocaleContextHolder.setLocale(new Locale("nl")); assertEquals("dd-MMM-yyyy", DateUtil.getDatePattern()); LocaleContextHolder.setLocale(Locale.FRANCE); assertEquals("dd/MM/yyyy", DateUtil.getDatePattern()); LocaleContextHolder.setLocale(Locale.GERMANY); assertEquals("dd.MM.yyyy", DateUtil.getDatePattern()); // non-existant bundle should default to default locale LocaleContextHolder.setLocale(new Locale("fi")); String fiPattern = DateUtil.getDatePattern(); LocaleContextHolder.setLocale(Locale.getDefault()); String defaultPattern = DateUtil.getDatePattern(); assertEquals(defaultPattern, fiPattern); }
From source file:fi.helsinki.opintoni.util.CoursePageUriBuilderTest.java
@Test public void thatEnglishUrisAreLocalized() { LocaleContextHolder.setLocale(new Locale("en")); CoursePageCourseImplementation coursePage = createCoursePage(); assertThat(coursePageUriBuilder.getLocalizedUri(coursePage)).isEqualTo("http://courses.helsinki.fi/123"); }
From source file:nu.yona.server.exceptions.MainContext.java
@BeforeClass public static void setUp() { originalLocale = LocaleContextHolder.getLocale(); LocaleContextHolder.setLocale(Translator.EN_US_LOCALE); }
From source file:org.springsource.restbucks.payment.web.MoneySerializationTest.java
@Before public void setUp() { this.mapper = new ObjectMapper(); this.mapper.registerModules(JacksonTestUtils.getModules()); LocaleContextHolder.setLocale(Locale.ROOT); }
From source file:org.cloudfoundry.identity.uaa.web.ForwardAwareInternalResourceViewResolverTests.java
@Before public void start() { ServletRequestAttributes attributes = new ServletRequestAttributes(request); LocaleContextHolder.setLocale(request.getLocale()); RequestContextHolder.setRequestAttributes(attributes); }