Hi,
Somehow I didn’t find any PIP yet for Internationalization. I think SWI
prolog has a messaging infrastructure, which can also generated messages
in different languages. Probably inspired or inherited by Quintus Prolog.
I did once some research and somehow saw something similar in Quintus
Prolog. It also inspired Pillow, a web library, where output was seen as
producing a message. Recently it occured to me more and more that it
would be usefull to have multiple languages bundled into a single app.
Internationalization and Localization
The idea is often abbreviated to i18n (where 18 stands for the
number of letters between the first i and the last n in the word
internationalization, a usage coined at Digital Equipment
Corporation in the 1970s or 1980s.
https://en.wikipedia.org/wiki/Internationalization_and_localization
In some of my Prolog systems I started providing i18n databases via
a multifile strings/3 predicate, using some ISO local identifier logic to
access facts from the strings/3 predicate, in a manner that Java accesses
resource bundles. But to access Prolog error texts, I went a step further
and started dynamically matching template strings from strings/3 and
supply it to format/3. So layering the matter on format/3. But sometimes
it makes sense to fetch a i18n as an atom or string instead of sending it
to a stream. So I complemented the predicate put_message/[2,3] by a
predicate get_message/[2,3], the former tolerates missing template strings
the later indicates missing template strings by a failure. Here is a use
case of get_message/[2,3] not really using the failure and success status,
but rather showing the reification in the last argument, GNU time -f inspired:
time(Goal) :-
get_message(time(fields), Format),
time(Goal, Format).
strings('time.fields', '', '% %t, %p, %l').
SWI Prolog probably can do that as well, if it would redirect the output
stream to atom(A) or string(S). But get_message/[2,3] does reification without
redirection, so there are no multithreading reentrance issues or whatever.
Compared to SWI-Prolog put_message/[2,3] has also a smaller and more
focused scope than print_message/2, since it doesn’t have a formal “level”
parameter, not dealing with “error”, “warning”, etc.. messages.
Bye
BTW: Having all the i18n data as strings is sometimes more user friendly.