From: Eli Zaretskii <eliz@gnu.org>
Subject: Re: National Language Support Functions
Date: Fri, 22 Dec 2006 14:14:42 +0200 [thread overview]
Message-ID: <uy7p0ktzh.fsf@gnu.org> (raw)
In-Reply-To: <458B2295.7010806@student.lu.se> (message from Lennart Borgman on Fri, 22 Dec 2006 01:11:01 +0100)
> Date: Fri, 22 Dec 2006 01:11:01 +0100
> From: Lennart Borgman <lennart.borgman.073@student.lu.se>
> 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 <windows.h>
> > #include <stdio.h>
> >
> > 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 <windows.h>
> #include <winnls.h>
> #include <windef.h>
> #include <tchar.h>
> #include <stdio.h>
>
> #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;
> }
>
>
next parent reply other threads:[~2006-12-22 12:14 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <458AB581.7090303@student.lu.se>
[not found] ` <458AF7AC.5030500@student.lu.se>
[not found] ` <umz5hlyrm.fsf@gnu.org>
[not found] ` <458B2295.7010806@student.lu.se>
2006-12-22 12:14 ` Eli Zaretskii [this message]
2006-12-22 12:35 ` National Language Support Functions Jason Rumney
2006-12-22 12:57 ` Jason Rumney
2006-12-22 15:43 ` Eli Zaretskii
2006-12-22 19:51 ` Lennart Borgman
2006-12-22 16:32 ` Benjamin Riefenstahl
2006-12-22 20:07 ` Eli Zaretskii
2006-12-23 0:54 ` Benjamin Riefenstahl
2006-12-25 6:17 ` Kenichi Handa
2006-12-25 20:47 ` Eli Zaretskii
2006-12-26 0:59 ` Kenichi Handa
2006-12-25 22:17 ` Jason Rumney
2006-12-28 13:03 ` Lennart Borgman (gmail)
2006-12-29 9:38 ` Eli Zaretskii
2006-12-29 15:48 ` Lennart Borgman (gmail)
2006-12-29 16:23 ` Jan Djärv
2006-12-29 16:45 ` Lennart Borgman (gmail)
2006-12-29 10:31 ` Jason Rumney
2006-12-29 15:39 ` Lennart Borgman (gmail)
2006-12-29 16:14 ` Jason Rumney
2006-12-29 16:32 ` Lennart Borgman (gmail)
2006-12-29 19:37 ` Juanma Barranquero
2006-12-29 19:50 ` Lennart Borgman
2006-12-29 20:29 ` Juanma Barranquero
2006-12-29 20:48 ` Lennart Borgman (gmail)
2006-12-29 21:23 ` Juanma Barranquero
2006-12-29 21:48 ` Lennart Borgman (gmail)
2006-12-29 22:03 ` Juanma Barranquero
2006-12-29 22:22 ` Lennart Borgman (gmail)
2006-12-29 23:51 ` Juanma Barranquero
2006-12-30 0:14 ` Lennart Borgman (gmail)
2006-12-30 0:32 ` Juanma Barranquero
2006-12-30 0:42 ` Lennart Borgman (gmail)
2006-12-30 1:10 ` Juanma Barranquero
2006-12-30 1:27 ` Lennart Borgman (gmail)
2006-12-30 15:39 ` Eli Zaretskii
2006-12-30 15:53 ` Lennart Borgman (gmail)
2006-12-30 16:38 ` Eli Zaretskii
2006-12-30 17:30 ` Lennart Borgman (gmail)
2006-12-31 0:35 ` Jason Rumney
2006-12-31 2:22 ` Lennart Borgman (gmail)
2006-12-30 14:33 ` Eli Zaretskii
2006-12-30 15:21 ` Lennart Borgman (gmail)
2006-12-30 16:33 ` Eli Zaretskii
2006-12-30 17:36 ` Lennart Borgman (gmail)
2006-12-30 6:24 ` Richard Stallman
2006-12-30 10:28 ` Lennart Borgman (gmail)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=uy7p0ktzh.fsf@gnu.org \
--to=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.