Example usage for org.springframework.context.support ResourceBundleMessageSource setDefaultEncoding

List of usage examples for org.springframework.context.support ResourceBundleMessageSource setDefaultEncoding

Introduction

In this page you can find the example usage for org.springframework.context.support ResourceBundleMessageSource setDefaultEncoding.

Prototype

public void setDefaultEncoding(@Nullable String defaultEncoding) 

Source Link

Document

Set the default charset to use for parsing properties files.

Usage

From source file:org.ng200.openolympus.Application.java

@Bean
public ResourceBundleMessageSource messageSource() {
    final ResourceBundleMessageSource source = new ResourceBundleMessageSource() {

        @Override/*ww w  .j a va  2  s .com*/
        protected MessageFormat resolveCode(final String code, final Locale locale) {
            final MessageFormat format = super.resolveCode(code, locale);
            ;
            if (format == null) {
                Application.this.reportMissingLocalisationKey(code);
            }
            return format;
        }

        @Override
        protected String resolveCodeWithoutArguments(final String code, final Locale locale) {
            final String string = super.resolveCodeWithoutArguments(code, locale);
            if (string == null) {
                Application.this.reportMissingLocalisationKey(code);
            }
            return string;
        }

    };
    source.setDefaultEncoding("UTF-8");
    source.setBasename("messages");
    return source;
}

From source file:org.springframework.boot.autoconfigure.MessageSourceAutoConfiguration.java

@Bean
public MessageSource messageSource() {
    ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
    if (StringUtils.hasText(this.basename)) {
        messageSource.setBasenames(commaDelimitedListToStringArray(trimAllWhitespace(this.basename)));
    }/*from   www.  ja va2 s  .co m*/
    messageSource.setDefaultEncoding(this.encoding);
    messageSource.setCacheSeconds(this.cacheSeconds);
    return messageSource;
}

From source file:org.springframework.ui.context.support.ResourceBundleThemeSource.java

/**
 * 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//  w  ww  .  j  a v  a 2  s .  c  om
 * @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;
}