From: feit@ERA.COM (Mark Feit)
Subject: Re: Multi-language application questions
Organization: Engineering Research Associates, Vienna, VA
Date: Thu, 9 Apr 1992 14:28:52 GMT

On comp.windows.x.motif, swalker@BBN.COM (Susan Walker) posts:
 > I am in the process of modifying an existing application so the text
 > strings can be translated into German and French. The application uses
 > UIL for it's dialog boxes.  It currently has all text string resources
 > directly embedded throughout the UIL code.

Ouch...  A situation that should be avoided at all costs.  Read on...

 > Can any one help me out on these questions?

Yes, but let me answer them out of order since it'll make more sense
that way.

 > 2) I can think of 2 ways to extract the text from the UIL code.  Is
 > there any advantage of one way over another?
 >
 > method #1 - 
 > 	   File 1:  frenchstuff.msg which contains...
 >		[VALUE]
 > 	   File 2:  mybox.uil which contains...
 > 
 > method # 2 -
 > 	   File 1:  frenchstuff.msg which contains...
 >		[EXPORTED MESSAGE]
 > 	   File 2:  mybox.uil which contains...

If you're committed to entirely using UIL, the latter is probably
better, since your finished application will be able to have one
language-independent UID that imports the language-specific values
from the correct UID depending on the setting of $LANG.  (Slang?)

But there's a better way...  Read on some more...

 > 3a) Ideally I would like to have multiple languages available with
 > minimal duplication of files.  Is it possible to have 1 set of UIL
 > files for my dialog boxes and multiple sets of UIL files (1 set per
 > language) for the text strings and have the correct text strings
 > loaded at runtime?  I know about using $LANG, but how do I compile the
 > UIL files so that I have 1 set of language independent UID files?
 > 
 > 3b) I would rather not have to use lots of MrMFetchliteral calls all
 > over the place.  Is this the only way?

No, thank goodness.  MRM is bulky and sluggish enough without having
to do the extra FetchLiterals.

I have a large application in which I use UIL and the widget-number
method of maintaining widget IDs used in MotifBurger.  Instead of
having to modify both C and UIL include files each time I add or
delete a widge, I wrote a set of AWK scripts that generate them for me
and have the dependencies in my makefile to rebuild the UIL and some C
modules when those headers change.  [If I find the time, I'll clean up
the scripts and post them...  They're quite handy.]  This becomes
time-consuming whenever someone upstairs wants to change the wording
in some of the dialog boxes and buttons.  So I took anything in my UIL
that could be safely moved to the app-defaults file and built a
(large) app-defaults file containing all of the messages,
accelerators, colors, etc.  Not only did this add convenience, it
shrunk my UIDs as well.  Despite what OSF's books would lead you to
believe, this is actually the preferred method for setting widget
resources because it allows you maximum leeway in customization
without the need to have the program's original source.

Fortunately for you, the internationalization features that work for
UIDs work for app-defaults (at least as of R4, anyhow).  According to
O'Reilly, the suggested order for reading the resources is:

	1.	/usr/lib/X11/$LANG/app-defaults/class
	   else	/usr/lib/X11/app-defaults/class

	2.	$XUSERFILESEARCHPATH/class
	   else	$XAPPLRESDIR/$LANG/class
	   else	$XAPPLRESDIR/class
	   else $HOME/$LANG/class
	   else	$HOME/class

	3.	RESOURCE_MANAGER property
	   else	$HOME/.Xdefaults

	4.	$XENVIRONMENT
	   else	$HOME/.xdefaults-hostname

	5.	Command line options

So if you make sure your users set $LANG to their language and
$XUSERFILESEARCHPATH to wherever the app-defaults are usually kept,
you'll be able to put all of the language-dependent resources in the
language directory and all of the language-independent in the "main"
defaults directory.  The resource manager will merge them together
automagically as it follows the path outlines above.

 > 1) Are there any guidelines about keyboard accelerators and keyboard
 > mnemonics for languages other than English?

Other languages can be a little sticky since you run the risk of
having words that begin with accents.  Never having seen a foreign
keyboard in the flesh, I can't say if it's convenient to use accented
letters as accelerators or mnemonics.

 > Do I use the same English
 > characters even though they may not make sense in another language?

No; you're better off taking the extra time to tweak everything to
make it work...  Not doing so might tee off some of your foreign
users.  (Americans are famous for being a little language-arrogant,
and I don't see any reason for stoking the fire any more than we
already have.)

Hope this was of some help.
						- Mark

 ................................. .................................
: Mark A. Feit, Software Engineer : Internet: feit@era.com          :
: Engineering Research Associates : USENET: ...!uunet!era!feit      :
 ................................. .................................
 "Software development is 10% science, 25% ingenuity and 65% getting
	       the ingenuity to work with the science."

Newsgroups: comp.windows.x.motif