This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Structuring the manual for a language front end.


Back in The Dark Ages, we built a fairly large system that
required multi-lingual message capabilities. We dealt with some
of the same problems that come here -- word order differences,
formatting differences, etc., across languages. From what I've
seen so far, it looks like gcc is part way there, although
I might be behind the times here.

The approach we took was more or less as follows:

a. Each distinct message to be issued had a serial number assigned
  to it, basically an enumerated type. For example MSG1234 might
  report a segmentation fault.

b. A macro was used to generate all error messages; the variable parts
   of the message were parameterized. Thus file name error might be
   reported as: MSG (MSG1234,time,file_name,function_name,howmany)

c. A locale-like specifier allowed the user to select a natural
   language for error reporting.

d. Each supported language had a library of message texts, with one
   entry for each message. A typical entry in English for MSG1234
   might be:
        "File %s2 not found in function %s3. There have been %d4 of
         these errors on: %s1."
   The % strings defined both the parameter number to be inserted
   there as well as giving an indication of the type of formatting
   to be performed. The formatting style can be locale-ized,
   and the numeric specification allows for differences in word
   order for different languages.

This scheme permits easy extension to other languages, but does not
directly support fancier facilities, such as different wording for
parameters that can be singular or plural. It's main advantage is
that the program doesn't have to take any action to deal with
different languages.

We also generated the "Messages and Codes" manuals automatically from
the message databases.

Bob

Robert Bernecky                  Snake Island Research Inc.
bernecky@acm.org                 18 Fifth Street, Ward's Island
+1 416 203 0854                  Toronto, Ontario M5J 2B9 Canada
http://www.snakeisland.com



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]