Files
bflows-bandi-be/src/main/java/net/gepafin/tendermanagement/config/Translator.java
2024-08-14 15:31:00 +05:30

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);
}
}