0
votes

In my MFC application,there are three resource files(.rc) for three different languages(jap,eng,russian) and one main.rc file which includes other three resource file.All resource files contains same resource string in different languages and they all includes same resource header resource.h. When user runs the application ,popup window will appear asking user to select one language.Based on the user selection application has to select appropriate rc from which it will load resources.

Is there any way by which when user select one language application will pick appropriate resource file.

2
The operating system already knows what language the user prefers. And he'll generally prefer to use the language bar if he likes to switch. If you want to force the selection for some reason instead of leaving it up to the user then use SetThreadPreferredUILanguages(). Use SetThreadUILanguage() on XP.Hans Passant

2 Answers

3
votes

In the MFC this is done via satellite DLLs.

Place each language RC in a separate DLL. Than upon load of the application load the specific language DLL and use AfxSetResourceHandle with this handle.

In this case resource are searched in this DLL.

0
votes

An alternative is to consider adding additional stringtables to your project.

More details are provided here:

http://www.dev102.com/2008/10/20/how-to-localize-your-application-using-string-tables/

Basically, you add an additional table and set the culture information in the resource editor. Then, you can specify that culture before getting the value.

The example provided is for C# but the principles are just the same.

A possible way forward if needed.