Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using LoadResString with resource files 1

Status
Not open for further replies.

newprogrammer999

Programmer
Aug 28, 2002
26
IE
Hi all,
I'm just wondering if anyone can tell me how to use a resource file for multiple langauages. I have read tutorials on how to use them and can do it using a single string but i'm wondering how to have multiple langage strings, for example if i have:
ID English French
101 Hello Bonjour

what perameters do i put in to LoadResString so that it will display 'Bonjour'
Any help would be greatly appricated

benny

 
In the Resource Editor, you click the Edit String Tables icon and in the second window, the same icon adds a new String Table (column). Add one for each language.

Paul Bent
Northwind IT Systems
 
if benny does LoadResString(101) will he get Hello or Bonjour?
 
LoadResString(101) returns Hello
what I am wondering is how to return Bonjour? I have added a string table for French but I am unsure how to call it for the required value.
Any help on this is greatly appricated

benny
 
Sorry, I misunderstood. Each string table (language) corresponds to a LocaleID (country in regional settings). LoadResString gets the LocaleID from the local PC and the string from the corresponding language column in the res file. If there isn't a language in the res file for the LocaleID on which the app is running then the first (default) column is used. You would have to change your system settings to France to return "bonjour".

Paul Bent
Northwind IT Systems
 
Ah I see
So if i were to run my porgram on a machine with its settings in french then it would show 'Bonjour'.
That makes more sense alright.
Finally just one short question - I assume the exe would have to be created on the machine with its settings in french for the french values to be displayed? I mean I couldn't create an exe on my machine and then send it to my friend in france and it would show all the french values?

Thanks anyway

benny[cheers]
 
Yes, you can compile your exe on an English PC and run it on a system set to any of the languages in the res file. After compiling, you can change your own PC to France and test.

I've written a few apps for German clients. I put all the English strings in a res file, send them a doc listing the strings/purposes and ask them to fill in the German in the next col so I can put them in the res file. Apps compiled on my system run fine under German settings.

Paul Bent
Northwind IT Systems
 
You can also use the SetThreadLocale API to set your own thread to the locale ID you want to. Then the LoadString API loads the correct language from the resource, so I presume the LoadResString function from VB does the same. This way you won't have to change your OS settings to have another language in your app, but you can simply let the user select from within your app which language to use in the UI.
Greetings,
Rick
 
I think you'll have to do that yourself by using the resource API's, like EnumResourceNames.
Greetings,
Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top