本文整理了Java中org.springframework.context.support.ResourceBundleMessageSource.setFallbackToSystemLocale
方法的一些代码示例,展示了ResourceBundleMessageSource.setFallbackToSystemLocale
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResourceBundleMessageSource.setFallbackToSystemLocale
方法的具体详情如下:
包路径:org.springframework.context.support.ResourceBundleMessageSource
类名称:ResourceBundleMessageSource
方法名:setFallbackToSystemLocale
暂无
代码示例来源:origin: spring-projects/spring-framework
/**
* Create a MessageSource for the given basename,
* to be used as MessageSource for the corresponding theme.
* <p>Default implementation creates a ResourceBundleMessageSource.
* for the given basename. A subclass could create a specifically
* configured ReloadableResourceBundleMessageSource, for example.
* @param basename the basename to create a MessageSource for
* @return the MessageSource
* @see org.springframework.context.support.ResourceBundleMessageSource
* @see org.springframework.context.support.ReloadableResourceBundleMessageSource
*/
protected MessageSource createMessageSource(String basename) {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename(basename);
if (this.defaultEncoding != null) {
messageSource.setDefaultEncoding(this.defaultEncoding);
}
if (this.fallbackToSystemLocale != null) {
messageSource.setFallbackToSystemLocale(this.fallbackToSystemLocale);
}
if (this.beanClassLoader != null) {
messageSource.setBeanClassLoader(this.beanClassLoader);
}
return messageSource;
}
代码示例来源:origin: org.springframework/spring-context
/**
* Create a MessageSource for the given basename,
* to be used as MessageSource for the corresponding theme.
* <p>Default implementation creates a ResourceBundleMessageSource.
* for the given basename. A subclass could create a specifically
* configured ReloadableResourceBundleMessageSource, for example.
* @param basename the basename to create a MessageSource for
* @return the MessageSource
* @see org.springframework.context.support.ResourceBundleMessageSource
* @see org.springframework.context.support.ReloadableResourceBundleMessageSource
*/
protected MessageSource createMessageSource(String basename) {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename(basename);
if (this.defaultEncoding != null) {
messageSource.setDefaultEncoding(this.defaultEncoding);
}
if (this.fallbackToSystemLocale != null) {
messageSource.setFallbackToSystemLocale(this.fallbackToSystemLocale);
}
if (this.beanClassLoader != null) {
messageSource.setBeanClassLoader(this.beanClassLoader);
}
return messageSource;
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testResourceBundleMessageSourceWithInappropriateDefaultCharset() {
ResourceBundleMessageSource ms = new ResourceBundleMessageSource();
ms.setBasename("org/springframework/context/support/messages");
ms.setDefaultEncoding("argh");
ms.setFallbackToSystemLocale(false);
try {
ms.getMessage("code1", null, Locale.ENGLISH);
fail("Should have thrown NoSuchMessageException");
}
catch (NoSuchMessageException ex) {
// expected
}
}
代码示例来源:origin: kaif-open/kaif
@PostConstruct
public void init() throws TemplateModelException {
configureFreeMarker();
// default is true, which fallback to system locale, so if
// system locale is jp. fallback bundle file will be messages_jp.properties, not
// messages.properties. This behavior is not what we want. so disable it.
messageSource.setFallbackToSystemLocale(false);
}
代码示例来源:origin: com.vmware.card-connectors/connectors-common
@Bean
public MessageSource messageSource() {
ResourceBundleMessageSource ret = new ResourceBundleMessageSource();
ret.setFallbackToSystemLocale(false);
ret.setBasename("cards/text");
return ret;
}
代码示例来源:origin: com.vmware.card-connectors/connectors-config
@Bean
public MessageSource messageSource() {
ResourceBundleMessageSource ret = new ResourceBundleMessageSource();
ret.setFallbackToSystemLocale(false);
ret.setBasename("cards/text");
return ret;
}
代码示例来源:origin: Evolveum/midpoint
private ResourceBundleMessageSource buildSource(String basename, ClassLoader classLoader) {
ResourceBundleMessageSource source = new CachedResourceBundleMessageSource();
source.setDefaultEncoding(StandardCharsets.UTF_8.name());
source.setFallbackToSystemLocale(false);
source.setBasename(basename);
if (classLoader == null) {
classLoader = LocalizationServiceImpl.class.getClassLoader();
}
source.setBundleClassLoader(classLoader);
return source;
}
代码示例来源:origin: metatron-app/metatron-discovery
/**
*
*/
@Bean
public MessageSource messageSource() {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasenames("messages/messages", "messages/metatron_security_messages");
messageSource.setFallbackToSystemLocale(false);
messageSource.setCacheSeconds(100000);
messageSource.setDefaultEncoding("UTF-8");
return messageSource;
}
代码示例来源:origin: stackoverflow.com
@Bean(name = "messageSource")
public MessageSource messageSource() {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename("/i18n/messages");
messageSource.setFallbackToSystemLocale(false);
messageSource.setCacheSeconds(0);
messageSource.setDefaultEncoding("UTF-8");
return messageSource;
}
代码示例来源:origin: kaif-open/kaif
@Before
public void mailSetup() {
configuration = new Configuration(Configuration.VERSION_2_3_21);
configuration.setDefaultEncoding("UTF-8");
configuration.setTemplateLoader(new ClassTemplateLoader(MailComposer.class, "/mail"));
//keep config same as application.yml and WebConfiguration.java
messageSource = new ResourceBundleMessageSource();
messageSource.setBasename("i18n/messages");
messageSource.setDefaultEncoding("UTF-8");
messageSource.setFallbackToSystemLocale(false);
}
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Create a MessageSource for the given basename,
* to be used as MessageSource for the corresponding theme.
* <p>Default implementation creates a ResourceBundleMessageSource.
* for the given basename. A subclass could create a specifically
* configured ReloadableResourceBundleMessageSource, for example.
* @param basename the basename to create a MessageSource for
* @return the MessageSource
* @see org.springframework.context.support.ResourceBundleMessageSource
* @see org.springframework.context.support.ReloadableResourceBundleMessageSource
*/
protected MessageSource createMessageSource(String basename) {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename(basename);
if (this.defaultEncoding != null) {
messageSource.setDefaultEncoding(this.defaultEncoding);
}
if (this.fallbackToSystemLocale != null) {
messageSource.setFallbackToSystemLocale(this.fallbackToSystemLocale);
}
if (this.beanClassLoader != null) {
messageSource.setBeanClassLoader(this.beanClassLoader);
}
return messageSource;
}
代码示例来源:origin: com.blossom-project/blossom-autoconfigure
@Bean
@Primary
public MessageSource messageSource( BlossomReloadableResourceBundleMessageSource parentMmessageSource) {
MessageSourceProperties properties = messageSourceProperties();
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
if (StringUtils.hasText(properties.getBasename())) {
messageSource.setBasenames(StringUtils.commaDelimitedListToStringArray(
StringUtils.trimAllWhitespace(properties.getBasename())));
}
if (properties.getEncoding() != null) {
messageSource.setDefaultEncoding(properties.getEncoding().name());
}
messageSource.setFallbackToSystemLocale(properties.isFallbackToSystemLocale());
Duration cacheDuration = properties.getCacheDuration();
messageSource.setCacheSeconds(
cacheDuration == null ? -1 : (int) cacheDuration.getSeconds());
messageSource.setAlwaysUseMessageFormat(properties.isAlwaysUseMessageFormat());
messageSource.setUseCodeAsDefaultMessage(properties.isUseCodeAsDefaultMessage());
messageSource.setParentMessageSource(parentMmessageSource);
return messageSource;
}
代码示例来源:origin: cn.bestwu.simpleframework/simpleframework-core
@Bean
public MessageSource messageSource() {
MessageSourceProperties properties = messageSourceProperties();
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
if (StringUtils.hasText(properties.getBasename())) {
messageSource.setBasenames(StringUtils.commaDelimitedListToStringArray(
StringUtils.trimAllWhitespace(properties.getBasename())));
}
if (properties.getEncoding() != null) {
messageSource.setDefaultEncoding(properties.getEncoding().name());
}
messageSource.setFallbackToSystemLocale(properties.isFallbackToSystemLocale());
Duration cacheDuration = properties.getCacheDuration();
if (cacheDuration != null) {
messageSource.setCacheMillis(cacheDuration.toMillis());
}
messageSource.setAlwaysUseMessageFormat(properties.isAlwaysUseMessageFormat());
messageSource.setUseCodeAsDefaultMessage(properties.isUseCodeAsDefaultMessage());
return messageSource;
}
代码示例来源:origin: cn.bestwu.simpleframework/simpleframework-web
@Bean
public MessageSource messageSource(ApplicationContext applicationContext) {
MessageSourceProperties properties = messageSourceProperties(applicationContext);
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
if (StringUtils.hasText(properties.getBasename())) {
messageSource.setBasenames(StringUtils.commaDelimitedListToStringArray(
StringUtils.trimAllWhitespace(properties.getBasename())));
}
if (properties.getEncoding() != null) {
messageSource.setDefaultEncoding(properties.getEncoding().name());
}
messageSource.setFallbackToSystemLocale(properties.isFallbackToSystemLocale());
Duration cacheDuration = properties.getCacheDuration();
if (cacheDuration != null) {
messageSource.setCacheMillis(cacheDuration.toMillis());
}
messageSource.setAlwaysUseMessageFormat(properties.isAlwaysUseMessageFormat());
messageSource.setUseCodeAsDefaultMessage(properties.isUseCodeAsDefaultMessage());
return messageSource;
}
内容来源于网络,如有侵权,请联系作者删除!