| Interface | Description |
|---|---|
| MessageInfoProvider |
A provider of meta-information for a message collection.
|
| Messages |
The internationalization constants used by this package.
|
| Class | Description |
|---|---|
| ContainerClassInfo |
Holder of meta-information about a message container class, such as
Messages. |
| I18NMessageInfo |
Holder of meta-information about an internationalized message.
|
| MessageComparator |
A comparator of two message meta-information holders.
|
| MessageInfo |
Holder of meta-information about a generic message.
|
| MessageInfoPair |
Holder of dual meta-information about a message.
|
| PropertiesFileInfo |
Holder of meta-information about a properties file that maps
message keys to message text.
|
| PropertyMessageInfo |
Holder of meta-information about a message stored in a properties
file.
|
Message localization tools.
Message localization (L10N) is the process by which message keys
are mapped to message text, as outlined in the org.marketcetera.util.log package. The tools in this package assist
in that effort.
MessageInfo and its subclasses
I18NMessageInfo and PropertiesFileInfo represent
meta-information derived from analyzing the representation of a single
message in either a typical Message container class or inside a
properties file.
ContainerClassInfo and PropertiesFileInfo perform the analysis
and encapsulate all meta-information for a container class or
properties file. They both implement the MessageInfoProvider interface, which
defines a generic provider of a message meta-information
collection.
MessageComparator compares any
two collections of message meta-information. Part of the comparison
result is expressed as a collection of MessageInfoPair instances, containing
messages that have the same key in both source and destination, but
differ in their parameter counts.
Additional tools can be built using the above classes as building blocks; such tools include translation tools (via automatic translation or a GUI-assisted manual process).
The message comparator lends itself to use within unit tests, to ensure each Message container class matches its associated fallback properties file. Here is the unit test template to accomplish this task:
package mypackage;
import org.junit.Test;
import org.marketcetera.util.l10n.MessageComparator;
import org.marketcetera.util.test.TestCaseBase;
import static org.junit.Assert.*;
public class MessagesTest
extends TestCaseBase
{
@Test
public void messagesMatch()
throws Exception
{
MessageComparator comparator=new MessageComparator(Messages.class);
assertTrue(comparator.getDifferences(),comparator.isMatch());
}
}
In order to ensure support for specific locales, it is also reasonable
to add to the body of messagesMatch() the following lines
(also remember to import java.util.Locale):
comparator=new MessageComparator(Messages.class,Locale.FRENCH); assertTrue(comparator.getDifferences(),comparator.isMatch());
Copyright © 2015. All Rights Reserved.