From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.pretest.bugs,gmane.emacs.devel Subject: Re: National Language Support Functions Date: Fri, 22 Dec 2006 14:14:42 +0200 Message-ID: References: <458AB581.7090303@student.lu.se> <458AF7AC.5030500@student.lu.se> <458B2295.7010806@student.lu.se> Reply-To: Eli Zaretskii NNTP-Posting-Host: dough.gmane.org X-Trace: sea.gmane.org 1166789708 24731 80.91.229.10 (22 Dec 2006 12:15:08 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 22 Dec 2006 12:15:08 +0000 (UTC) Original-X-From: emacs-pretest-bug-bounces+gebp-emacs-pretest-bug=gmane.org@gnu.org Fri Dec 22 13:15:06 2006 Return-path: Envelope-to: gebp-emacs-pretest-bug@gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by dough.gmane.org with esmtp (Exim 4.50) id 1GxjIh-0005Yc-EN for gebp-emacs-pretest-bug@gmane.org; Fri, 22 Dec 2006 13:14:59 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GxjIg-0001AP-Qa for gebp-emacs-pretest-bug@gmane.org; Fri, 22 Dec 2006 07:14:58 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GxjIX-00019C-IB for emacs-pretest-bug@gnu.org; Fri, 22 Dec 2006 07:14:49 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GxjIW-00018w-UM for emacs-pretest-bug@gnu.org; Fri, 22 Dec 2006 07:14:49 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GxjIW-00018t-Pf; Fri, 22 Dec 2006 07:14:48 -0500 Original-Received: from [192.114.186.66] (helo=romy.inter.net.il) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GxjIW-0001X4-1J; Fri, 22 Dec 2006 07:14:48 -0500 Original-Received: from HOME-C4E4A596F7 (IGLD-84-229-216-239.inter.net.il [84.229.216.239]) by romy.inter.net.il (MOS 3.7.3-GA) with ESMTP id GPK78022 (AUTH halo1); Fri, 22 Dec 2006 14:14:38 +0200 (IST) Original-To: emacs-pretest-bug@gnu.org, emacs-devel@gnu.org In-reply-to: <458B2295.7010806@student.lu.se> (message from Lennart Borgman on Fri, 22 Dec 2006 01:11:01 +0100) X-BeenThere: emacs-pretest-bug@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for CVS Emacs." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-pretest-bug-bounces+gebp-emacs-pretest-bug=gmane.org@gnu.org Errors-To: emacs-pretest-bug-bounces+gebp-emacs-pretest-bug=gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.pretest.bugs:16048 gmane.emacs.devel:64104 Archived-At: > Date: Fri, 22 Dec 2006 01:11:01 +0100 > From: Lennart Borgman > CC: jasonr@gnu.org Could people who have access to MS-Windows please try these two programs and report the results? It is important to describe the full details about your regional and international settings (found in Control Panel) on each machine where you test this. Thanks in advance. > Eli Zaretskii wrote: > > On my system, it returns Hebrew as the system default, and US English > > as the user default, which is exactly how I configured this system. > > So Emacs does the right thing for me. > > > > #include > > #include > > > > int main (void) > > { > > LANGID lsys = GetSystemDefaultLangID (); > > LANGID lusr = GetUserDefaultLangID (); > > > > printf ("SYS: 0x%x, USR: 0x%x\n", lsys, lusr); > > > > return 0; > > } > > > > I think the tests above are not the correct tests for the UI language. > > I searched a bit to find out again how to test this. It turns out to be > a bit complicated if one wants to support different versions of Windows. > I suggest that we only support later versions and then use > GetUserDefaultUILanguage and dito System variant. Here is some code to test: > > #include > #include > #include > #include > #include > > #define TRACE(s, l) (fprintf(stdout, s, l)) > > int main (void) > { > LANGID lsys = GetSystemDefaultLangID (); > LANGID lusr = GetUserDefaultLangID (); > > printf ("LangID = SYS: 0x%x, USR: 0x%x\n", lsys, lusr); > > LCID lcidsys = GetSystemDefaultLCID (); > LCID lcidusr = GetUserDefaultLCID (); > > printf ("LCID = SYS: 0x%x, USR: 0x%x\n", lcidsys, lcidusr); > > //WINBASEAPI LANGID WINAPI GetSystemDefaultUILanguage(void); > //WINBASEAPI LANGID WINAPI GetUserDefaultUILanguage(void); > //LANGID luisys = GetSystemDefaultUILanguage(); > //LANGID luiusr = GetUserDefaultUILanguage (); > > //printf ("UILang = SYS: 0x%x, USR: 0x%x\n", luisys, luiusr); > > { > LANGID langid = 0; > int nPrimaryLang = 0; > int nSubLang = 0; > LCID lcid = 0; > typedef LANGID (WINAPI * PFNGETUSERDEFAULTUILANGUAGE) > ( > void); > PFNGETUSERDEFAULTUILANGUAGE pfnGetUserDefaultUILanguage; > typedef LANGID (WINAPI * PFNGETSYSTEMDEFAULTUILANGUAGE) > ( > void); > PFNGETSYSTEMDEFAULTUILANGUAGE pfnGetSystemDefaultUILanguage; > HINSTANCE hKernel32; > > hKernel32 = GetModuleHandle(_T("kernel32.dll")); > pfnGetUserDefaultUILanguage = > (PFNGETUSERDEFAULTUILANGUAGE)GetProcAddress(hKernel32,"GetUserDefaultUILanguage"); > if(pfnGetUserDefaultUILanguage != NULL) > { > langid = pfnGetUserDefaultUILanguage(); > TRACE(_T("GetUserDefaultUILanguage() = %04X\n"), langid ); > > pfnGetSystemDefaultUILanguage = > (PFNGETSYSTEMDEFAULTUILANGUAGE)GetProcAddress(hKernel32,"GetSystemDefaultUILanguage"); > //ASSERT( pfnGetSystemDefaultUILanguage != NULL ); > > langid = pfnGetSystemDefaultUILanguage(); > TRACE(_T("GetSystemDefaultUILanguage = %04X\n"), langid ); > } > else > { > // We're not on an MUI-capable system. > if (GetVersion()&0x80000000) > { > // We're on Windows 9x, so look > // in the registry for the UI language > HKEY hKey = NULL; > LONG nResult = RegOpenKeyEx(HKEY_CURRENT_USER, > _T( "Control Panel\\Desktop\\ResourceLocale" ), > 0, KEY_READ, &hKey); > if (nResult == ERROR_SUCCESS) > { > DWORD dwType; > TCHAR szValue[16]; > ULONG nBytes = sizeof( szValue ); > nResult = RegQueryValueEx(hKey, NULL, NULL, &dwType, > (LPBYTE) szValue, &nBytes ); > if ((nResult == ERROR_SUCCESS) && (dwType == REG_SZ)) > { > DWORD dwLangID; > int nFields = _stscanf( szValue, _T( "%x" ), &dwLangID ); > if( nFields == 1 ) > { > langid = (LANGID) dwLangID; > TRACE(_T("Win 9x registry language = %04X\n"), langid ); > } > } > RegCloseKey(hKey); > } > } > else > { > // We're on NT 4. The UI language > // is the same as the language of the > // version resource in ntdll.dll > /* HMODULE hNTDLL = GetModuleHandle( _T( "ntdll.dll" ) ); */ > /* if (hNTDLL != NULL) */ > /* { */ > /* langid = 0; */ > /* EnumResourceLanguages( hNTDLL, RT_VERSION, MAKEINTRESOURCE( 1 ), */ > /* _AfxEnumResLangProc, */ > /* reinterpret_cast< LONG_PTR >( &langid ) ); */ > /* if (langid != 0) */ > /* { */ > /* AddLangId( langid ); */ > /* TRACE(_T("CMultiLanguage::DetectUILanguage() NT1st/2nd = %04X\n"), langid ); */ > /* } */ > /* } */ > } > } > > > } > return 0; > } > >