0

We have our spring application set up to support both English and Spanish, using <spring:message code="something"/>, with all of the values stored in a database table as opposed to in a messages.properties.

This works fine, except when there doesn't happen to be a value in the database for a specific code for the given language. When that happens, the text that's displayed is the code.

We would like to default to the English text if it can't find the Spanish one. Is there a way to do this with the spring framework?

reallynice
  • 1,289
  • 2
  • 21
  • 41
Jesse Jashinsky
  • 10,313
  • 6
  • 38
  • 63

2 Answers2

3

Yes, you can. Just add a text field.

http://docs.spring.io/spring/docs/1.1.5/taglib/tag/MessageTag.html

Text

Default text to output when a message for the given code could not be found. If both text and code are not set, the tag will output null.

Community
  • 1
  • 1
Dan
  • 1,179
  • 2
  • 10
  • 18
0

You can enable defaulting to a locale with a combination of configurations. For instance the following could be a starting point:

  • the message source must be configured with useCodeAsDefaultMessage as false;
  • you must set the Default locale to English;
  • fallbackToSystemLocale must be set to true.
reallynice
  • 1,289
  • 2
  • 21
  • 41