home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / os / mswindo / programm / misc / 4208 < prev    next >
Encoding:
Text File  |  1992-12-14  |  3.0 KB  |  82 lines

  1. Newsgroups: comp.os.ms-windows.programmer.misc
  2. From: chris@chrism.demon.co.uk (Chris Marriott)
  3. Path: sparky!uunet!pipex!demon!chrism.demon.co.uk!chris
  4. Subject: Re: Programming for foreign languages 
  5. Distribution: world
  6. References: <1992Dec12.185658.13375@serval.net.wsu.edu>
  7. Organization: None
  8. Reply-To: chris@chrism.demon.co.uk
  9. X-Mailer: Simple NEWS 1.90 (ka9q DIS 1.19)
  10. Lines: 67
  11. Date: Mon, 14 Dec 1992 18:44:39 +0000
  12. Message-ID: <724358679snz@chrism.demon.co.uk>
  13. Sender: usenet@demon.co.uk
  14.  
  15. In article <1992Dec12.185658.13375@serval.net.wsu.edu> rnelson@wsuaix.csc.wsu.edu writes:
  16.  
  17. >I have written several DOS apps I can compile versions for English, Spanish,
  18. >French and Italian (someday also Castilan, Swedish, Danish and German)
  19. >I am porting these to ms-windows and would like no know
  20. >what is the best way to support foreign languages under windows.
  21. >
  22. > [ stuff deleted]
  23. >
  24. >Does windows provide a facility for loading the strings for the language.
  25. >So far, all I have found in the Borland documentation is the function
  26. >which gets the language version of MS-Windows.
  27. >
  28.  
  29. This is very easy in Windows.  What you do is to put all the strings you
  30. want the user to see in a STRINGTABLE resource in your application's
  31. resource file, then load them with the "LoadString" function.
  32.  
  33. Eg, in the .rc file:
  34.  
  35.         STRINGTABLE
  36.         BEGIN
  37.             IDS_FILENOTFOUND,   "File not found"
  38.             IDS_LOADSIMFILE,    "Load simulation file"
  39.             etc.
  40.         END
  41.         
  42. (note - IDS_FILENOTFOUND, etc, are #defined constants)
  43.  
  44. Then, in the application:
  45.  
  46.         char szMessage[64];
  47.         LoadString( hInst, IDS_FILENOTFOUND, szMessage, 64 );
  48.         MessageBox( ..... );
  49.         etc.
  50.  
  51. >Also is there a way to access strings used by windows so I don't have to
  52. >duplicate translations for things like: ('file not found', 'unable to
  53. >open file', 'file','close','save', etc...
  54. >
  55.  
  56. Not that I'm aware of, no.
  57.  
  58. >What I was planning on doing was the following:
  59. >Keep a language file for each language.
  60. >The file will have a number and a string for each phrases, ie:
  61. >1  "File not found"
  62. >2  "Save simulation file"
  63. >       :
  64.  
  65. A good way to do this with Windows is to have a separate DLL for each
  66. language, containing all the strings resources for that language.
  67. When your application loads, look at the configuration file to decide
  68. which language you want to use, then load the appropriate DLL using
  69. the "LoadLibrary" function.  From there, everything is as above, except
  70. that in the "LoadString" function you use the library handle, as returned
  71. by "LoadLibrary", instead of the application instance handle.
  72.  
  73. Hope this information is of some use to you.
  74. -- 
  75. --------------------------------------------------------------------------
  76. | Chris Marriott                           | chris@chrism.demon.co.uk    |
  77. | Warrington, UK                           | BIX: cmarriott              |
  78. | (Still awaiting inspiration              | CIX: cmarriott              |
  79. |  for a witty .sig .... )                 | CompuServe: 100113,1140     |
  80. --------------------------------------------------------------------------
  81.  
  82.