Article View: comp.os.ms-windows.programmer.misc
Article #1756Re: Programming for foreign languages
From: Chris Marriott
Date: Mon, 14 Dec 1992 18:44
Date: Mon, 14 Dec 1992 18:44
67 lines
3194 bytes
3194 bytes
In article <1992Dec12.185658.13375@serval.net.wsu.edu> rnelson@wsuaix.csc.wsu.edu writes:
>I have written several DOS apps I can compile versions for English, Spanish,
>French and Italian (someday also Castilan, Swedish, Danish and German)
>I am porting these to ms-windows and would like no know
>what is the best way to support foreign languages under windows.
>
> [ stuff deleted]
>
>Does windows provide a facility for loading the strings for the language.
>So far, all I have found in the Borland documentation is the function
>which gets the language version of MS-Windows.
>
This is very easy in Windows. What you do is to put all the strings you
want the user to see in a STRINGTABLE resource in your application's
resource file, then load them with the "LoadString" function.
Eg, in the .rc file:
STRINGTABLE
BEGIN
IDS_FILENOTFOUND, "File not found"
IDS_LOADSIMFILE, "Load simulation file"
etc.
END
(note - IDS_FILENOTFOUND, etc, are #defined constants)
Then, in the application:
char szMessage[64];
LoadString( hInst, IDS_FILENOTFOUND, szMessage, 64 );
MessageBox( ..... );
etc.
>Also is there a way to access strings used by windows so I don't have to
>duplicate translations for things like: ('file not found', 'unable to
>open file', 'file','close','save', etc...
>
Not that I'm aware of, no.
>What I was planning on doing was the following:
>Keep a language file for each language.
>The file will have a number and a string for each phrases, ie:
>1 "File not found"
>2 "Save simulation file"
> :
A good way to do this with Windows is to have a separate DLL for each
language, containing all the strings resources for that language.
When your application loads, look at the configuration file to decide
which language you want to use, then load the appropriate DLL using
the "LoadLibrary" function. From there, everything is as above, except
that in the "LoadString" function you use the library handle, as returned
by "LoadLibrary", instead of the application instance handle.
Hope this information is of some use to you.
--
--------------------------------------------------------------------------
| Chris Marriott | chris@chrism.demon.co.uk |
| Warrington, UK | BIX: cmarriott |
| (Still awaiting inspiration | CIX: cmarriott |
| for a witty .sig .... ) | CompuServe: 100113,1140 |
--------------------------------------------------------------------------
Technical Details
Message-ID:
<724358679snz@chrism.demon.co.uk>Path:
arc1-ca.pugleaf.net!sparky!uunet!pipex!demon!chrism.demon.co.uk!chrisReferences:
<1992Dec12.185658.13375@serval.net.wsu.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.os.ms-windows.programmer.misc From: chris@chrism.demon.co.uk (Chris Marriott) Path: arc1-ca.pugleaf.net!sparky!uunet!pipex!demon!chrism.demon.co.uk!chris Subject: Re: Programming for foreign languages Distribution: world References: <1992Dec12.185658.13375@serval.net.wsu.edu> Organization: None Reply-To: chris@chrism.demon.co.uk X-Mailer: Simple NEWS 1.90 (ka9q DIS 1.19) Lines: 67 Date: Mon, 14 Dec 1992 18:44:39 +0000 Message-ID: <724358679snz@chrism.demon.co.uk> Sender: usenet@demon.co.uk