Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am trying to implement string localization in the windows application (Console app ).

To achieve this i have done following.

I have added two resource files in the project namele. English.rc and Germany.rc

In English.rc
I have added a string table. Its language is set to English(United States)

In Germany.rc
I have added a string table. Its language is set to Germany(Germany)

In both string tables i have adde a string resource entry

For English.rc

C++
ID = IDS_STRING_Title
Value = 101 
Caption = EnglishCaption


For German.rc

C++
ID = IDS_STRING_Title
Value = 101 
Caption = GermanCaption



I have kept the value of the string resources in both rc files to 101.


I am trying to consume this string into the code as follows.

C++
#include "stdafx.h"
#include "windows.h"
#include "atlstr.h"
#include "resource1.h"
#include "resource.h"

int _tmain(int argc, _TCHAR* argv[])
{
	CString str( MAKEINTRESOURCE( IDS_STRING_Title ) ) ;
	
	
	return 0;
}




When i debug above application, str gets always loaded with the "EnglishCaption" text. \
When i change the regional settings to change the system locale to German(German) or change Display language of the system, it always shows "EnglishCaption" text only.

Why this happens. Why application does not pick up the string from the string table with German(Germany) language when i set the system locale to German(Germany). ???

Am I missing something ??
Posted
Updated 19-Nov-13 0:11am
v2

This wont work.

We using over years this solution

1. the primary language is in the original exe-modul
2. additional language resources are compiled in a dll
3. the rc-dll will handled

this article shows the way: Multiple language support for MFC applications with extension DLL[^]

Sledgehammer method: work with some projects settings and #define and so include only one language in a exe. Than you will have a exe for every language. ;-)

If you really will dig in the depths of "i18n" you can start here: http://msdn.microsoft.com/en-us/library/windows/desktop/dd318661(v=vs.85).aspx[^]
 
Share this answer
 
You can do the "satellite dll" thing or you can also have multiple string tables in one rc file and switch.

Call this function in your application startup (m_iLang would be LANG_GERMAN, LANG_ENGLISH, or whatever)

::SetThreadLocale(MAKELCID(MAKELANGID(m_iLangID, SUBLANG_DEFAULT), SORT_DEFAULT));


then all your calls to
CString::LoadString()
will load the correct language
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900