List of usage examples for org.springframework.context.support ReloadableResourceBundleMessageSource setFallbackToSystemLocale
public void setFallbackToSystemLocale(boolean fallbackToSystemLocale)
From source file:config.web.i18nConfig.java
@Bean(name = "messageSource") public MessageSource provideMessageSource() { ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource(); messageSource.addBasenames("/WEB-INF/i18n/messages"); messageSource.setFallbackToSystemLocale(true); messageSource.setDefaultEncoding("UTF-8"); return messageSource; }
From source file:at.porscheinformatik.common.spring.web.extended.config.SpringWebExtendedConfig.java
@Bean public MessageSource messageSource() { ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource(); messageSource.setFallbackToSystemLocale(false); configurerConfig.configureMessageSource(messageSource); return messageSource; }
From source file:de.blizzy.documentr.context.ContextConfig.java
@Bean public MessageSource messageSource() { ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource(); messageSource.setFallbackToSystemLocale(false); messageSource.setCacheSeconds(10);//from w ww . ja v a 2 s .c o m messageSource.setBasenames(new String[] { "classpath:documentr_messages", "classpath:ValidationMessages" //$NON-NLS-1$ //$NON-NLS-2$ }); return messageSource; }
From source file:nu.yona.server.CoreConfiguration.java
/** * This bean tells the application which message bundle to use. * /*from ww w .j a v a 2 s. co m*/ * @return The message bundle source */ @Bean(name = "messageSource") public ReloadableResourceBundleMessageSource messageSource() { ReloadableResourceBundleMessageSource messageBundle = new ReloadableResourceBundleMessageSource(); messageBundle.setFallbackToSystemLocale(false); messageBundle.setBasename("classpath:messages/messages"); messageBundle.setDefaultEncoding("UTF-8"); return messageBundle; }
From source file:ru.mystamps.web.config.MvcConfig.java
@Override public Validator getValidator() { ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource(); messageSource.setBasename("classpath:ru/mystamps/i18n/ValidationMessages"); messageSource.setFallbackToSystemLocale(false); LocalValidatorFactoryBean factory = new LocalValidatorFactoryBean(); factory.setValidationMessageSource(messageSource); return factory; }
From source file:net.jawr.web.resource.bundle.locale.message.GrailsMessageBundleScriptCreator.java
public Reader createScript(Charset charset) { // Determine wether this is run-app or run-war style of runtime. boolean warDeployed = ((Boolean) this.servletContext.getAttribute(JawrConstant.GRAILS_WAR_DEPLOYED)) .booleanValue();/*from www .ja v a2 s. c om*/ // Spring message bundle object, the same used by grails. ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource(); messageSource.setFallbackToSystemLocale(false); Set<String> allPropertyNames = null; // Read the properties files to find out the available message keys. It is done differently // for run-app or run-war style of runtimes. if (warDeployed) { allPropertyNames = getPropertyNamesFromWar(); if (LOGGER.isDebugEnabled()) LOGGER.debug("found a total of " + allPropertyNames.size() + " distinct message keys."); messageSource.setResourceLoader(new ServletContextResourceLoader(this.servletContext)); messageSource.setBasename(PROPERTIES_DIR + configParam.substring(configParam.lastIndexOf('.') + 1)); } else { ResourceBundle bundle; if (null != locale) bundle = ResourceBundle.getBundle(configParam, locale); else bundle = ResourceBundle.getBundle(configParam); allPropertyNames = new HashSet<String>(); Enumeration<String> keys = bundle.getKeys(); while (keys.hasMoreElements()) allPropertyNames.add(keys.nextElement()); String basename = "file:./" + configParam.replaceAll("\\.", "/"); messageSource.setBasename(basename); } // Pass all messages to a properties file. Properties props = new Properties(); for (Iterator<String> it = allPropertyNames.iterator(); it.hasNext();) { String key = it.next(); if (matchesFilter(key)) { try { // Use the property encoding of the file String msg = new String( messageSource.getMessage(key, new Object[0], locale).getBytes(CHARSET_ISO_8859_1), charset.displayName()); props.put(key, msg); } catch (NoSuchMessageException e) { // This is expected, so it's OK to have an empty catch block. if (LOGGER.isDebugEnabled()) LOGGER.debug("Message key [" + key + "] not found."); } catch (UnsupportedEncodingException e) { LOGGER.warn("Unable to convert value of message bundle associated to key '" + key + "' because the charset is unknown"); } } } return doCreateScript(props); }
From source file:io.lavagna.config.PersistenceAndServiceConfig.java
@Bean public MessageSource messageSource() { ReloadableResourceBundleMessageSource source = new ReloadableResourceBundleMessageSource(); source.setBasename("classpath:/io/lavagna/i18n/messages"); source.setUseCodeAsDefaultMessage(true); source.setFallbackToSystemLocale(false); return source; }
From source file:com.isalnikov.config.web.WebConfig.java
@Bean public MessageSource messageSource() { ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource(); messageSource.setUseCodeAsDefaultMessage(true); messageSource.setDefaultEncoding("UTF-8"); messageSource.setBasenames("classpath:message"); messageSource.setCacheSeconds(5);/*from www .j a v a 2s. co m*/ messageSource.setFallbackToSystemLocale(false);// ??? return messageSource; }
From source file:it.f2informatica.webapp.WebApplicationConfig.java
@Bean public ReloadableResourceBundleMessageSource messageSource() { ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource(); messageSource.setBasenames(basenames()); messageSource.setDefaultEncoding("UTF-8"); messageSource.setCacheSeconds(1);/* www .ja va 2 s. com*/ messageSource.setFallbackToSystemLocale(false); return messageSource; }
From source file:org.lightadmin.core.config.context.LightAdminContextConfiguration.java
@Bean public MessageSource messageSource() { ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource(); messageSource.setBasename("classpath:messages"); messageSource.setDefaultEncoding("UTF-8"); messageSource.setCacheSeconds(0);// www . j a va 2 s .com messageSource.setFallbackToSystemLocale(false); return messageSource; }