James Carlson wrote:
> Roland Mainz writes:
> > - Think about localising the script (e.g. $"mymessage", not the
> > /usr/bin/gettext thing).
> 
> I don't follow that part.  gettext(1) is _the_ supported l10n
> mechanism on Solaris.

ksh93 (and bash) provide another way via $"mymessage", e.g. all string
literals which are in double quotes with a '$' in front of the quotes
are localiseable strings. If a matching catalog file exists and the
locale is not "C" (or a l10n locale alias for "C" like "POSIX") then
ksh93 tries to lookup these strings in the l10n catalog (catalogs can be
generated via "shcomp -D scriptname" or "ksh93 -D scriptname").

> Why would we want to be incompatible with ourselves by using something
> else?

The underlying library calls are AFAIK identical to those used by
/usr/bin/gettext and therefore this is IMO "compatible". The only
difference is that this is a much easier way to implement localisation
than /usr/bin/gettext and does not suffer from the limitations of
/usr/bin/gettext either (e.g. the current usage of /usr/bin/gettext in
the Solaris scripts to cache the localised output strings and then print
them later breaks at the moment where LC_MESSAGES differs from other
LC_* variables or if scripts switch between locales during data
processing. The only "correct" usage would be to invoke /usr/bin/gettext
each time when a message needs to be printed (which this is horrible
slow and still tricky to get "right")).

The only "incompatibility" to /usr/bin/gettext is that /usr/bin/gettext
accepts an optional "text domain" while ksh93/bash use the script's
basename (ARGV0) to lookup the catalog, however that is on the ToDo list
for ksh93t- to add a ${.sh.msgcat.name} variable to define an explicit
catalog name which overrides ARGV0 (for Solaris the "workaround" would
be to link things from
"/usr/lib/locale/de_DE.UTF-8/LC_MESSAGES/SUNW_OST_OSCMD.mo"
"/usr/lib/locale/de_DE.UTF-8/LC_MESSAGES/myscript" (assuming the script
is called "myscript" and ${LC_MESSAGES} is set to "de_DE.UTF-8")) or
wait until ksh93t- lands in Solaris.

BTW: Another "nice" feature is that you can put the extended "getopts"
strings into $"..." and therefore get localised manual pages for
"myscript --man" for free (assuming a matching l10n catalog exists for
"myscript" for the locale specified by ${LC_MESSAGES} and the script
uses the "getopts" builtin provided by ksh93).

----

Bye,
Roland

P.S.: BTW: The $"..." literals are a very likely canidate for the next
POSIX shell standard as there seems to be a consens and functionally
identical implementations for the major POSIX-like shells (e.g. bash,
ksh93 etc.), e.g. this isn't some "obscure flavor of the day" ksh93
feature...

-- 
  __ .  . __
 (o.\ \/ /.o) [EMAIL PROTECTED]
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 7950090
 (;O/ \/ \O;)
_______________________________________________
tools-discuss mailing list
tools-discuss@opensolaris.org

Reply via email to