Re: Internationalizing an app
- From: "Tom Serface" <tserface@xxxxxxx>
- Date: Sat, 2 Dec 2006 13:10:10 -0800
If you are using RC files and MFC this is the easiest way to do it:
http://msdn2.microsoft.com/en-gb/library/8fkteez0(VS.80).aspx
Basically, you have the default values in your native language (I use
English although you'd never know it from my posts at times). Then, you get
the translations done and a separate .RC file created for each. Create a
DLL project (according to the way described in the link) and load that DLL
based on the locale where the user is running the software. I use something
like:
//
// Creates a resource file name (for a DLL) given the locale id and a format
string.
//
CString GetResourceFilename(UINT nLID, LPCTSTR cFormat)
{
CString csHex, cs;
nLID = MAKELANGID(nLID&0xff, SUBLANG_DEFAULT);
csHex.Format(_T("%04x"), nLID);
cs.FormatMessage(cFormat,csHex);
return cs;
}
LCID lcid = ::GetThreadLocale();
lcid = LANGIDFROMLCID(lcid);
CString csResourceDLL;
csResourceDLL = GetResourceFilename(lcid, _T("MyApp%1.dll"));
lcid = MAKELANGID(lcid&0xff, SUBLANG_DEFAULT);
switch(lcid) {
case 0x0409:
LogEvent(VERSION_ENGLISH);
break;
case 0x0407:
LogEvent(VERSION_GERMAN);
break;
case 0x040a:
LogEvent(VERSION_SPANISH);
break;
case 0x040c:
LogEvent(VERSION_FRENCH);
break;
case 0x0410:
LogEvent(VERSION_ITALIAN);
break;
case 0x0411:
LogEvent(VERSION_JAPANESE);
break;
}
m_hInstResDLL = ::LoadLibrary(csResourceDLL);
if(m_hInstResDLL != NULL)
AfxSetResourceHandle(m_hInstResDLL);
else
LogEvent("Default to English");
HTH,
Tom
"flect" <flect@xxxxxxx> wrote in message
news:uSaMm%23kFHHA.1816@xxxxxxxxxxxxxxxxxxxxxxx
I have never before attempted to internationalize an application.
The current plan (which I frankly dreamed up) involves creating a unicode
xml file with a placeholder for all user interface elements, that the user
can optionally load. The idea being that a user can edit the xml file to
their tastes, regardless of language or region.
Is there a better/easier way?
.
- Follow-Ups:
- Re: Internationalizing an app
- From: flect
- Re: Internationalizing an app
- References:
- Internationalizing an app
- From: flect
- Internationalizing an app
- Prev by Date: Re: AfxMessageBox?
- Next by Date: Re: Internationalizing an app
- Previous by thread: Internationalizing an app
- Next by thread: Re: Internationalizing an app
- Index(es):
Relevant Pages
|