This is a cache of http://dbflute.seasar.org/ja/manual/function/helper/saflute/i18n.html. It is a snapshot of the page at 2024-11-13T00:22:21.671+0000.
SAFluteの国際化対応 (i18n) | DBFlute

SAFluteの国際化対応 (i18n)

SAFluteの特徴の一つです。

国際化対応の概要

様々なアプリの要件に合わせた Locale と Timezone の管理ができるようになっています。

TODO jflute 書き途中

AssistantDirector で Provider 実装

UserLocaleProcessProvider

以下のインターフェースを実装して、AssistantDirector にて登録をします。

UserLocaleProcessProviderインターフェース @Java
/**
 * The provider of user locale process for current request.
 * @author jflute
 */
public interface UserLocaleProcessProvider {

    /**
     * Does it accept cookie locale? (prevails over session)
     * @return The determination, true or false.
     */
    boolean isAcceptCookieLocale();

    /**
     * Find business locale. (prevails over cookie)
     * @param executeMeta The meta of action execution which you can get the calling method. (NotNull)
     * @param requestManager The manager of request to find your locale. (NotNull)
     * @return The found locale by your business rule. (NullAllowed: if null, not found)
     */
    Locale findBusinessLocale(ActionExecuteMeta executeMeta, RequestManager requestManager);

    /**
     * Get the requested locale. (for when not found in session or cookie)
     * @param requestManager The manager of request to find your time-zone. (NotNull)
     * @return The locale as default by your business rule. (NullAllowed: if null, requested client locale)
     */
    Locale getRequestedLocale(RequestManager requestManager);

    /**
     * Get the fall-back locale. (for no locale everywhere)
     * @return The fixed instance of locale, might be cached. (NullAllowed: if null, server locale)
     */
    Locale getFallbackLocale();
}

UserTimeZoneProcessProvider

以下のインターフェースを実装して、AssistantDirector にて登録をします。

UserTimeZoneProcessProviderインターフェース @Java
/**
 * The provider of user time-zone process for current request.
 * @author jflute
 */
public interface UserTimeZoneProcessProvider {

    /**
     * Does it use time-zone handling? 
* The time-zone handling is option (not related to Struts) so you need to choose. * @return The determination, true or false. */ boolean isUseTimeZoneHandling(); /** * Does it accept cookie time-zone? (prevails over session) * @return The determination, true or false. */ boolean isAcceptCookieTimeZone(); /** * Find business time-zone. (prevails over cookie) * @param executeMeta The meta of action execution which you can get the calling method. (NotNull) * @param requestManager The manager of request to find your time-zone. (NotNull) * @return The found time-zone by your business rule. (NullAllowed: if null, not found) */ TimeZone findBusinessTimeZone(ActionExecuteMeta executeMeta, RequestManager requestManager); /** * Get the requested time-zone. (for when not found in session or cookie)
* Unfortunately we cannot get time-zone from request, provider needs to provide the default time-zone * @param requestManager The manager of request to find your time-zone. (NotNull) * @return The time-zone as default by your business rule. (NotNull) */ TimeZone getRequestedTimeZone(RequestManager requestManager); /** * Get the fall-back time-zone. (for no time-zone everywhere) * @return The fixed instance of time-zone, might be cached. (NullAllowed: if null, server time-zone) */ TimeZone getFallbackTimeZone(); }