intra-mart Accel Platform / TERASOLUNA Global Framework Programming Guide

Version 2 2014-01-01

«  Date and Time Format Definition at Initial State   ::   Contents   ::   Utilize User Time Zone and Date and Time Format  »

Get Message in Multi-Language Form

Summary

This section describes how to get the multi-language messages using MessageManager, MessageSource, and tags.

Getting Message by MessageManager

Getting message by specifying message code

Message defined in the message property file is obtained from the language of current log-in user.
String exampleMsg = jp.co.intra_mart.foundation.security.message.MessageManager.getInstance().getMessage("I18N.MESSAGE.EXAMPLE");
Message will be automatically resolved as follows.
  1. Message of Account Context Language
  2. Message of Tenant Language
  3. Message of System Default Language
  4. Message of Message Property File with no Language ID
  5. Message meaning “undefined” in the User Language
If none of the ones listed above applies, character string [undefined] is returned.

Getting message by specifying message code and language

Message defined in the message property file is obtained from the message code and the specified language.
String exampleMsg = jp.co.intra_mart.foundation.security.message.MessageManager.getInstance().getMessage(Locale.ENGLISH, "I18N.MESSAGE.EXAMPLE");
Message is automatically resolved as follows.
  1. Message of the specified langauge
  2. Message of the Message Property File with no Language ID
If none of the ones listed above applies, character string [undefined] is returned.

Getting Message by Tags

Tags that support MessageManager are provided.
Its function is the same as MessageManager.

Getting message by specifying message code

<%@ taglib prefix="imarttag" uri="http://www.intra-mart.co.jp/taglib/core/standard" %>
<imarttag:message id="I18N.MESSAGE.EXAMPLE"></imarttag:message>

Getting message by specifying message code and language

<%@ taglib prefix="imarttag" uri="http://www.intra-mart.co.jp/taglib/core/standard" %>
<imarttag:message id="I18N.MESSAGE.EXAMPLE" locale="en"></imarttag:message>

Getting Message by MessageSource

MessageSource implementation class intramartMessageSource, which wraps MessageManager, is provided.
bean of IntramartMessageSource is registered to applicationContext-im_tgfw_common.xml.
<bean id="messageSource" class="jp.co.intra_mart.framework.extension.spring.message.IntramartMessageSource" />
Message is automatically resolved as follows.
  1. Message of the specified language
  2. Message of the message property file with no language ID
If none of the ones listed above applies, character string [undefined] is returned. NoSuchMessageException will not be thrown.

Getting Message by message tag of spring.tld

Message is obtained according to the messageSource which has been set.

«  Date and Time Format Definition at Initial State   ::   Contents   ::   Utilize User Time Zone and Date and Time Format  »