Created
December 5, 2017 11:10
-
-
Save normal-carrot/c1cbca50202bfa3f16faa0c3e1ceadce to your computer and use it in GitHub Desktop.
Revisions
-
Alexander Kohonovsky created this gist
Dec 5, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ import org.springframework.context.MessageSource; import org.springframework.context.support.MessageSourceAccessor; import org.springframework.stereotype.Component; import java.util.Locale; /** * @author saniaky * @since 12/5/17 */ @Component public class Messages { private final MessageSourceAccessor accessor; public Messages(MessageSource messageSource) { this.accessor = new MessageSourceAccessor(messageSource, LocaleContextHolder.getLocale()); } public String get(String code) { return accessor.getMessage(code); } }