Пример #1
0
 public ResourceBundleMessageSource getRes() {
   if (res == null) {
     res = new ResourceBundleMessageSource();
     res.setBasenames(new String[] {"res/messages"});
   }
   return res;
 }
Пример #2
0
 @Bean
 public MessageSource messageSource() {
   ResourceBundleMessageSource ms = new ResourceBundleMessageSource();
   ms.setBasenames("message.error");
   ms.setDefaultEncoding("UTF-8");
   return ms;
 }
 @Bean
 public MessageSource messageSource() {
   ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
   messageSource.setBasenames(
       getResourceBundleLocations().toArray(new String[getResourceBundleLocations().size()]));
   return messageSource;
 }
 /**
  * Bean koji sluzi da bi locirali properties datoteke za poruke.
  *
  * @return
  */
 @Bean
 public ResourceBundleMessageSource messageSource() {
   final ResourceBundleMessageSource source = new ResourceBundleMessageSource();
   String[] basenamesSpecific = {
     "properties.messages.common.messages", "properties.messages.app.application"
   };
   source.setBasenames(basenamesSpecific);
   source.setUseCodeAsDefaultMessage(true);
   source.setDefaultEncoding("UTF-8");
   return source;
 }
 @Override
 public void setBasenames(final String... basenames) {
   List<String> list = new LinkedList<String>();
   if (CollectionUtils.isEmpty(basenames)) return;
   for (String baseName : basenames) {
     if (StringUtils.isEmpty(baseName)) continue;
     String[] bases = StringUtils.split(baseName, ',');
     for (String base : bases) {
       list.add("classpath:i18n/" + base);
     }
   }
   String[] bases = new String[list.size()];
   list.toArray(bases);
   list.clear();
   list = null;
   super.setBasenames(bases);
 }
 /**
  * Set a single basename, following ResourceBundle conventions: It is a fully-qualified classname.
  * If it doesn't contain a package qualifier (such as org.mypackage), it will be resolved from the
  * classpath root.
  *
  * <p>Messages will normally be held in the /lib or /classes directory of a WAR. They can also be
  * held in Jars on the class path. For example, a Jar in an application's manifest classpath could
  * contain messages for the application.
  *
  * @param basename the single basename
  * @see #setBasenames
  * @see java.util.ResourceBundle
  */
 public void setBasename(String basename) {
   setBasenames(new String[] {basename});
 }
 // Provides internationalization of messages
 @Bean
 public ResourceBundleMessageSource messageSource() {
   ResourceBundleMessageSource source = new ResourceBundleMessageSource();
   source.setBasenames(new String[] {"i18n/message"});
   return source;
 }