Adds support for useCodeAsDefaultMessage

See gh-10466
This commit is contained in:
Kedar Joshi
2017-10-02 16:05:15 +05:30
committed by Stephane Nicoll
parent 9102eb32d1
commit a68ec76bb6
3 changed files with 35 additions and 0 deletions

View File

@@ -75,6 +75,7 @@ public class MessageSourceAutoConfiguration {
messageSource.setFallbackToSystemLocale(properties.isFallbackToSystemLocale());
messageSource.setCacheSeconds(properties.getCacheSeconds());
messageSource.setAlwaysUseMessageFormat(properties.isAlwaysUseMessageFormat());
messageSource.setUseCodeAsDefaultMessage(properties.isUseCodeAsDefaultMessage());
return messageSource;
}

View File

@@ -22,6 +22,7 @@ import java.nio.charset.Charset;
* Configuration properties for Message Source.
*
* @author Stephane Nicoll
* @author Kedar Joshi
* @since 2.0.0
*/
public class MessageSourceProperties {
@@ -57,6 +58,11 @@ public class MessageSourceProperties {
*/
private boolean alwaysUseMessageFormat = false;
/**
* Set whether to use the message code as default message instead of throwing a NoSuchMessageException.
*/
private boolean useCodeAsDefaultMessage = false;
public String getBasename() {
return this.basename;
}
@@ -97,4 +103,11 @@ public class MessageSourceProperties {
this.alwaysUseMessageFormat = alwaysUseMessageFormat;
}
public boolean isUseCodeAsDefaultMessage() {
return this.useCodeAsDefaultMessage;
}
public void setUseCodeAsDefaultMessage(final boolean useCodeAsDefaultMessage) {
this.useCodeAsDefaultMessage = useCodeAsDefaultMessage;
}
}