【发布时间】:2011-05-17 22:15:11
【问题描述】:
我正在使用 Windows API,并且正在尝试使用多语言资源来加载特定于语言的菜单和内容。但是,出于某种原因,如果有美国英语替代品,Windows 绝对拒绝加载波斯尼亚语(拉丁语)资源。通过FindResourceEx 加载资源有效。我使用的是 XP SP3,并且在我的区域设置中设置了波斯尼亚语(拉丁语)。
main.c
#include <Windows.h>
#include "resource.h"
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PTSTR pCmdLine, int nCmdShow)
{
TCHAR string[64];
/* Message box properly outputs "This is German (DE)." here. */
SetThreadLocale(MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT));
LoadString(hInstance, TEST_STRING, string, sizeof(string)/sizeof(string[0]));
MessageBox(NULL, string, TEXT("Message"), MB_OK);
/* Message box outputs "This is English (US)." - WTF?! */
SetThreadLocale(MAKELCID(MAKELANGID(LANG_BOSNIAN, SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN), SORT_DEFAULT));
LoadString(hInstance, TEST_STRING, string, sizeof(string)/sizeof(string[0]));
MessageBox(NULL, string, TEXT("Message"), MB_OK);
return 0;
}
resources.rc
#include <windows.h>
#include "resource.h"
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
STRINGTABLE
{
TEST_STRING "This is English (US)."
}
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
STRINGTABLE
{
TEST_STRING "This is German (DE)."
}
LANGUAGE LANG_BOSNIAN, SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN
STRINGTABLE
{
TEST_STRING "This is Bosnian (Latin)."
}
LANGUAGE LANG_FRENCH, SUBLANG_FRENCH
STRINGTABLE
{
TEST_STRING "This is French (FR)."
}
resource.h
#define TEST_STRING 40000
【问题讨论】:
-
你确定要使用纯 c 吗?
-
足以说明我的问题。
标签: winapi resources localization internationalization