Skip navigation links

Imprint

The Message Compiler 2.2

The Message Compiler is a programming tool, used to internationalize applications, by compiling a message file, which contains message definitions in different languages, to several output files, like resource files, programming language specific class or header files with constant definitions for the message keys and HTML documentation files.

See: Description

Packages 
Package Description
messagecompiler
The Message Compiler is a programming tool, used to internationalize applications, by compiling a message file, which contains message definitions in different languages, to several output files, like resource files, programming language specific class or header files with constant definitions for the message keys and HTML documentation files.
The Message Compiler is a programming tool, used to internationalize applications, by compiling a message file, which contains message definitions in different languages, to several output files, like resource files, programming language specific class or header files with constant definitions for the message keys and HTML documentation files. It lies in the tradition of tools like the Open VMS Message Utility, the Microsoft Message Compiler (mc), which is available in Visual Studio or the Unix gencat utility. The Message Compiler uses output processors extending the class OutputProcessor to generate the output files. It may be extended by the user, implementing new output processors extending this class. The Message Compiler is a 100% pure Java program, so you need the Java Runtime Environment with the minimum version 1.5 to used it.

The advantage of using the Message Compiler is, that you can keep your localized text and messages in one source file and all files required for your programming environment are generated from this one source. Even when you use the same localized texts in different programming environments, you may generate the files for all your programming environments from one source file using the Message Compiler. Furthermore the programming language specific constants created for the message keys are off course a much safer way to access the messages in the resource files, than using plain strings.

Download Message Compiler

The Message Compiler

The Command Line

The Message Compiler may be started with the following command lines. The variable <classpath> has to be replaced by the installation directory of the Message Compiler.

 java -classpath <classpath> messagecompiler.MessageCompiler
 java -classpath <classpath> messagecompiler.MessageCompiler -help
 java -classpath <classpath> messagecompiler.MessageCompiler ?
These commands show the help text of the Message Compiler and all available output processors on the console.
 java -classpath <classpath> messagecompiler.MessageCompiler -version
This command shows the version of the Message Compiler and the version of all available output processors on the console.
 java -classpath <classpath> messagecompiler.MessageCompiler -locales
This command shows the locales, accepted by the Message Compiler as language in the message file, on the console.
 java -classpath <classpath> messagecompiler.MessageCompiler [-verbose] [-msgFileEncoding <encoding>] <message-file> [<output-processor> { <output-processor-options> }]...
This command compiles the message file and uses the specified output processors to produce the output files. The optional option -verbose causes the Message Compiler to print some log output on the console. The optional option -msgFileEncodingi> can be used to specify the encoding of the message source file. The default value is UTF-8. The output-processor-options are documented by the different output processor classes. Note, that the braces enclosing the options has to be preceded and followed by at least one blank! If no output processor is specified, no output files are created. Here a sample command line, which creates a Java enumeration class and Java resource files for each language specified in the message file:
 java -classpath  ~/tools/MessageCompiler messagecompiler.MessageCompiler ApplicationMessages.msf JavaResource { -fileName projectDir/msgcat/ApplicationMessages } JavaEnum { -enumName ApplicationMessageKey -dir projectDir/msgcat }

When an error occurs, the message compiler exits with the following status codes:

The Message File Syntax

The message file may contain option blocks for the different output processors, message definitions and comment lines. Although not absolutely required, the option blocks should appear before the message definitions in the file. Comment lines start with a hash (#) or exclamation mark (!) as first character in the line. Inside the text or documentation blocks of a message definition no comment lines are recognized. They are considered to be part of the message text or the message documentation.

Option blocks have the following syntax:

 .OPTION=<output-processor>
 <option>=<value>
 ...
 .END
The options for the output processors are documented by the classes implementing the output processors.

A message definition is started with the message key definition, an optional severity definition and several language blocks. It is terminated by the next message key definition or an option block. The usage of the severity is defined by the output processors. A message definition has the following syntax:

 .MESSAGEKEY=<message-key>
 .SEVERITY=SUCCESS | INFORMATION | WARNING | ERROR | FATAL
 <language-block>
 ...
The language block is started with the language definition and followed by a message text block and an optional documentation block. The language is specified with the string representation of a Locale, e.g. "en" for English or "en_US" for American English. The command line option -locales may be used to get a list of all valid locales. The message and documentation text blocks may contain several lines. The output processor decides, if the lines are concatenated to one line or if the line breaks are preserved. Note, that comment lines are not recognized in the message and documentation block. A language block has the following syntax:
 .LANGUAGE=<locale>
 .TEXT
 <message-text-line>
 ...
 .END
 .DOCUMENTATION
 <documentation-text-line>
 ...
 .END
A sample message definition looks like this:
 .MESSAGEKEY=MYAPP_EXC_IO_FILE_NOT_FOUND
 .SEVERITY=ERROR
 .LANGUAGE=en
 .TEXT
 The file {0} does not exist
 .END
 .DOCUMENTATION
 The specified file doesn't exist.
 .END
 .LANGUAGE=de
 .TEXT
 Die Datei {0} ist nicht vorhanden
 .END
 .DOCUMENTATION
 Die angegebene Datei ist nicht vorhanden.
 .END

The Output Processors

The Message Compiler package currently contains the following output processors:

See the documentation of the output processor classes for the specific command line options and the options in the option block.

Downloading and Installing the Message Compiler

The Message Compiler is contained in the ZIP archive MessageCompiler.zip, which can be downloaded from the following location:

Download Message Compiler

To install the Message Compiler just un-zip the archive into the installation directory of the Message Compiler. This installation directory contains now the following directories:

Extending the Message Compiler

The Message Compiler may be extended by the user adding additional output processors. An output processor must fulfill the following conditions to be recognized by the Message Compiler:

  1. It must be a concrete Java class extending the class OutputProcessor.
  2. It must be contained in the Java package messagecompiler.
  3. The class name must conform to the naming convention <output-processor>OutputProcessor.
  4. The class file must be placed in the directory messagecompiler under the installation directory of the Message Compiler. The Message Compiler scans this directory for files with the pattern *OutputProcessor.class and checks if this file contains a Java class fulfilling the other conditions.

Integrating the Message Compiler in a Java IDE

The ANT script MessageCompilerAntScript.xml in the directory scripts under the installation directory may be used to integrate the Message Compiler in the ANT script of your Java project. Java IDE's like Eclipse or JDeveloper support the integration of ANT scripts for external compilers.

Integrating the Message Compiler in Xcode

A custom build rule may be defined for a target in Xcode to integrate the Message Compiler in the build process for the target. The build rule process Source files with names matching can be used to define the message file to be compiled, a Custom script can be defined to invoke the Message Compiler and at least one output file must be specified, that the rule is invoked. The message file is matched with the absolute file path, so the pattern */MyMessageFile.msg may be used, to avoid specifying the absolute path.

Version:
2.2
Author:
Thomas Mayr, TMASoft
Skip navigation links

Imprint