One way to localize Lisp programs is to implement an interface to
GNU gettext that maps English-langauge format string to localized
format strings. However, it's not clear how to handle plurals.
(The ~p directive seems pretty useless.)
Basically what we need are conditional formats:
~[tries~;try~;tries~]
The problem is that selection is done using simple indexing,
and what we need is a mapping from a (real) number to a selection
index - and this mapping is language-dependent (and sometimes
quite complex).
I have some ideas for how to do this, but I'm wondering if there
is any prior art.
My idea is that we can extend conditional formats e.g:
(format t ··@[······················@]" N)
This means that we use a locale-dependent mapping to map the value N
to an index I, and then select the corresponding "altI".
The locale-dependent mapping can be done using GNU gettext to
"translate" a magic string (say "LISP-PLURAL-CATEGORY"). E.g.:
scanf(ngettext("LISP-PLURAL-CATEGORY", "LISP-PLURAL-CATEGORY", N),
"%d", &I)
The default mapping (suitable for English) maps:
(if (= N 1) 0 1).
[The context is that I'm implementing localization support for Kawa.
While implementing plural handling isn't a priority, I would like to
have workable design.]
--
--Per Bothner
···@bothner.com http://per.bothner.com/