package com.xingxi.api.common;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.MessageSource;
import org.springframework.context.MessageSourceAware;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;


@Slf4j
@Component
public final class LocaleMessageUtil implements MessageSourceAware {
    private static MessageSource messageSource = null;
    @Override
    public void setMessageSource(MessageSource messageSource) {
        LocaleMessageUtil.messageSource = messageSource;
    }


    public static String getMessage(String message, Object[] args) {
        return messageSource.getMessage(message, args, LocaleContextHolder.getLocale());
    }

}
