public String getMessage ( String code , Map < String , String > substitutes , boolean firstFindInMessageBundle , String defaultMessage ) { Locale locale = authContextHolder . getContext ( ) . getDetailsValue ( LANGUAGE ) . map ( Locale :: forLanguageTag ) . orElse ( LocaleContextHolder . getLocale ( ) ) ; String localizedMessage = getFromConfig ( code , locale ) . orElseGet ( ( ) -> { if ( firstFindInMessageBundle ) { return messageSource . getMessage ( code , null , defaultMessage , locale ) ; } else { return defaultMessage != null ? defaultMessage : messageSource . getMessage ( code , null , locale ) ; } } ) ; if ( MapUtils . isNotEmpty ( substitutes ) ) { localizedMessage = new StringSubstitutor ( substitutes ) . replace ( localizedMessage ) ; } return localizedMessage ; }
Finds localized message template by code and current locale from config . If not found it takes message from message bundle or from default message first depends on flag .