25 lines
781 B
Java
25 lines
781 B
Java
package net.gepafin.tendermanagement.config;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.context.i18n.LocaleContextHolder;
|
|
import org.springframework.context.support.ResourceBundleMessageSource;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import java.util.Locale;
|
|
|
|
@Component
|
|
public class Translator {
|
|
|
|
private static ResourceBundleMessageSource messageSource;
|
|
|
|
@Autowired
|
|
Translator(ResourceBundleMessageSource messageSource) {
|
|
Translator.messageSource = messageSource;
|
|
}
|
|
|
|
public static String toLocale(String msgCode) {
|
|
// LocaleContextHolder.setDefaultLocale(Locale.ITALIAN);
|
|
Locale locale = LocaleContextHolder.getLocale();
|
|
return messageSource.getMessage(msgCode, null, locale);
|
|
}
|
|
} |