Each grammar rule in
QU_messages.pl defines the generation of a
message term from an internal form. For example, in (A) the text that
needs to be translated is the quoted text inside the list
Type error. The rest of the rule does not need to be changed.
generate_message(type_error(Goal,ArgNo,TypeName,Culprit)) --> (A) ['Type error'-], head(Goal,ArgNo), type(TypeName,Culprit), goal(Goal).
The general form of text components in a list is (B), where
control-string and arg-list are valid for a call such as (C) to the
format/2 as exemplified in (D).
control-string-arg list (B)
| ?- format(control-string, arg-list). (C)
| ?- format('Type error', ). (D) Type error yes
In example (E), when the message is printed, the List
will be inserted in place of the ~q. The ~q means that the List will
be printed as if by the built-in predicate
writeq/1. See the
format/[2,3] for full details of what a
control-string can do.
typename(one_of(List)) --> ['a member of the set ~q'-[List]]. (E)
In addition to text components of the form (F), it is also possible to have text components of the form (G), which cause a newline to be output.
control-string-arg list (F) nl (G)
The format option
~n should not be used in control
strings: any required newlines should be specified with the
components. For example, the list in (H) contains two text
components; in general, a number of text components can be collected
into a single list like this, or they can appear in separate lists, as
advice(invalid_argument,Type,X) --> (H) ['Invalid argument to ~w, ~q was ignored.'-[Type,X],nl]. advice(invalid_argument,Type,X) --> (I) ['Invalid argument to ~w, ~q was ignored.'-[Type,X]], [nl].
All (complete) messages must end with an
In addition to translating messages, it is also possible to change the
characters that Prolog will accept when it requires input from the
user. This is done by modifying the definition of
query_abbreviation/2 at the end of
QU_messages.pl. For example, (J)
means that when the Prolog system wants a yes-or-no answer it expects
the first character typed to be a
y or a
n and the case does not
matter. Since "yes" in French is "oui" a French translator might
change this to (K).
query_abbreviation(yes_or_no,[yes-"yY",no-"nN"]). (J) query_abbreviation(yes_or_no,[yes-"oO",no-"nN"]). (K)