sji18n Get sji18n at SourceForge.net. Fast, secure and Free Open Source software downloads

Introduction

This project aims to provide an easy to use yet powerful JavaTM internationalization facade with a pluggable resource lookup and loading mechanism.

The reason to support a pluggable localization framework is to make internationalization independent of the actual format and whereabouts of the localization resources and to allow to plug in the desired localization framework at deploy time.

Features

  • Internationalization api with a pluggable localization resource lookup mechanism.
  • Supports renaming (often hard-coded) resource names at deploy time.
  • Supports setting a different locale for logging messages and application objects.
  • Supports dynamic locale switching by notifying interested listeners of locale changes.
  • Supports multiple locale contexts within a single runtime.

Sample code

Typical use of the sji18n api is illustrated in the following example:

package some.pckg;
import sji18n.I18n;

public class SomeClass {
    private static final Logger LOGGER = Logger.getLogger("some.pckg.SomeClass");
    private static final I18n I18N = new I18n("SomeResource");

    public void someMethod() {
        ...
        try {
            showUserMessageWithIcon(new ImageIcon(I18N.getImage("someImage")),
                                    I18N.getMessage("someMessage", var1, var2));
            ...
            LOGGER.log(Level.INFO, I18N.getLogMessage("onSomeSuccess", var3));
        } catch (Exception e) {
            LOGGER.log(Level.WARNING, I18N.getLogString("onSomeError"), e);
        }
    }
}

Implementation notes

sji18n defines an L10nResourceFactory interface and uses an implementation to find and load actual localization resources. The actual L10nResourceFactory implementation used is set at the I18n class's initialization. System property sji18n.L10nResourceFactory, if set, must contain the fully qualified class name of the implementation to load. Failing to load the class specified in this system property will cause the I18n class's initialization to fail.
If system property sji18n.L10nResourceFactory is not set, I18n will look for a L10nResourceFactory service provider (see ServiceLoader for more info on how to set up a service provider).

Setting system property sji18n.resource.name.map (since version 1.1) allows to refer to a file in which resource names are mapped to other resource names. This allows to change the actual (and often hard-coded) resource names used to construct I18n instances at deploy time. For more details about this feature, please refer to the api documentation of I18n.

Requires at least java 1.6 and a L10nResourceFactory provider, no other external libraries are required.

L10nResourceFactory implementations