Re: Internationalizing an app

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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?


.



Relevant Pages

  • Re: Internationalizing an app
    ... you have the default values in your native language. ... Create a DLL project and load that DLL based on the locale where the user is running the software. ... CString GetResourceFilename ... The current plan involves creating a unicode xml file with a placeholder for all user interface elements, that the user can optionally load. ...
    (microsoft.public.vc.mfc)
  • Re: Query about CString, CXMLDOMDocument
    ... but as far as I know CString should be able to hold ... The dll then loads this XML file using CXMLDOMDocument class and converts ... loop during the concatenation process. ...
    (microsoft.public.vc.mfc)
  • Re: Query about CString, CXMLDOMDocument
    ... We want to revise the application so that we pass the data in form of XML as CString by concatenating the contents rather than a file and then use the loadXML method of the same CXMLDOMDocument class to load it, convert to Excel and then print it. ... If we use the XML file approach the size of the XML file was 7.8 MB and we were then trying to write the content of this 7.8MB file to a CString variable by concatenation and thats when it goes to an infinite loop. ...
    (microsoft.public.vc.mfc)