Example #1
0
/***
*BOOL match_ctry_lang - match country with language
*
*Purpose:
*       ensure language and country match, choose proper values for language
*  and country when matching, country ids converted to proper language id
*
*Entry:
*       pwCtry - pointer to country id to match and set
*       pwLang - pointer to language id to match and set
*
*Exit:
*
*Exceptions:
*
*******************************************************************************/
static BOOL match_ctry_lang(WORD *pwCtry, WORD *pwLang)
{
        UINT i;
        WORD wCtry = *pwCtry;
        WORD wLang = *pwLang;
        WORD wLangT;

        /* only use base 10 two least significant digits */
        wCtry = wCtry % 100;

        if (wCtry > MAX_CTRY_NUM)
            return FALSE;

        /* see if any of the sublanguages for this country match*/
        for (i = 0; i < MAX_LANG_PER_CTRY; i++)
        {
            if (!(wLangT = __rgrgwlang[wCtry][i]))
                break;
            if (PRIMARYLANGID(wLangT) == PRIMARYLANGID(wLang))
            {
                /* they match*/
                if (!SUBLANGID(wLang))
                    /* don't override sublanguage*/
                    *pwLang = wLangT;
                    *pwCtry = wLangT;
            return TRUE;
            }
        }
        /* get the default language for this country*/
        if (!(*pwCtry = __rgrgwlang[wCtry][0]))
            /* bad country number*/
            return FALSE;
        return TRUE;
}
int set_lang(void)
{
	unsigned int lang_usr,lang_sys,id;

	id=GetSystemDefaultLangID();
	lang_sys=PRIMARYLANGID(id);
	id=GetUserDefaultLangID();
	lang_usr=PRIMARYLANGID(id);
	if(lang_usr!=lang_sys) {
		printf("warning: user language differs from system language\r\n\r\n");
		printf("1. system : ");print_lang(lang_sys);
		printf("2. user   : "******"Select(1-2): ");
		id=getch();
	if(id!=49&&id!=50) {
		printf("wrong choice '%c', leaving.\r\n",id);
		exit(0);
		}
	if(id==49) {
		printf("system language\r\n");
		return lang_sys;
		}
	else
		printf("user language\r\n");
	}
	return lang_usr;
}
Example #3
0
void strSetCurKeyboard(void)
{
    udword keyboard;

    if (keyboard = GetKeyboardLayout(0))
    {
        if (PRIMARYLANGID(keyboard)==LANG_ENGLISH)
        {
            strCurKeyboardLanguage = languageEnglish;
        }
        else if (PRIMARYLANGID(keyboard)==LANG_FRENCH)
        {
            strCurKeyboardLanguage = languageFrench;
        }
        else if (PRIMARYLANGID(keyboard)==LANG_GERMAN)
        {
            strCurKeyboardLanguage = languageGerman;
        }
        else if (PRIMARYLANGID(keyboard)==LANG_SPANISH)
        {
            strCurKeyboardLanguage = languageSpanish;
        }
        else if (PRIMARYLANGID(keyboard)==LANG_ITALIAN)
        {
            strCurKeyboardLanguage = languageItalian;
        }
    }
    else
        strCurKeyboardLanguage = languageEnglish;
}
Example #4
0
language_c::language_c(char * setupLang, SystemDefault_c * SystemDefault) : collection_c() {
  current = -1;
  langDir = new char[MAX_PATH];
  strcpy(langDir,SystemDefault->PrgPath);
  strcat(langDir,"lang\\");
  char * SerPath = new char[MAX_PATH];
  strcpy(SerPath,langDir);
  strcat(SerPath,"*.xml");
  WIN32_FIND_DATA FindFileData;
  HANDLE hFind;
  hFind = FindFirstFile(SerPath, &FindFileData);
  if (hFind != INVALID_HANDLE_VALUE) {
    LoadLanguageFile(FindFileData.cFileName);
    while (FindNextFile(hFind,&FindFileData )) {
      LoadLanguageFile(FindFileData.cFileName);
    }
    FindClose(hFind);
  }
  delete[] SerPath;
//////////////////////////////
// Detect Systemdefault
//////////////////////////////
//  setup = aSetup;
  int ConfigLang = hexToInt(setupLang);
  current = getLangID(ConfigLang);
  if (current == -1) {
    int UserLang = GetUserDefaultUILanguage();
    if (current == -1) {current = getLangID(UserLang);}
    if (current == -1) {current = getLangIDMain(PRIMARYLANGID(UserLang));}
    int SysLang = GetSystemDefaultUILanguage();
    if (current == -1) {current = getLangID(SysLang);}
    if (current == -1) {current = getLangIDMain(PRIMARYLANGID(SysLang));}
  }
}
Example #5
0
void GHOST_ImeWin32::CreateImeWindow(HWND window_handle)
{
	/**
	 * When a user disables TSF (Text Service Framework) and CUAS (Cicero
	 * Unaware Application Support), Chinese IMEs somehow ignore function calls
	 * to ::ImmSetCandidateWindow(), i.e. they do not move their candidate
	 * window to the position given as its parameters, and use the position
	 * of the current system caret instead, i.e. it uses ::GetCaretPos() to
	 * retrieve the position of their IME candidate window.
	 * Therefore, we create a temporary system caret for Chinese IMEs and use
	 * it during this input context.
	 * Since some third-party Japanese IME also uses ::GetCaretPos() to determine
	 * their window position, we also create a caret for Japanese IMEs.
	 */
	if (PRIMARYLANGID(input_language_id_) == LANG_CHINESE ||
		PRIMARYLANGID(input_language_id_) == LANG_JAPANESE) {
		if (!system_caret_) {
			if (::CreateCaret(window_handle, NULL, 1, 1)) {
				system_caret_ = true;
			}
		}
	}
	/* Restore the positions of the IME windows. */
	UpdateImeWindow(window_handle);
}
Example #6
0
bool Translations::SetLanguage(LanguageResource languageResource, bool showErrorMsg /*= true*/)
{
    HMODULE hMod = nullptr;
    bool success = false;

    // Note that all messages should stay in English in that method!

    // Try to load the resource dll if any
    if (languageResource.dllPath) {
        hMod = LoadLibrary(languageResource.dllPath);
        if (hMod == nullptr) { // The dll failed to load for some reason
            if (showErrorMsg) {
                MessageBox(nullptr, _T("Error loading the chosen language.\n\nPlease reinstall MPC-HC."),
                           _T("MPC-HC"), MB_ICONWARNING | MB_OK);
            }
        } else { // Check if the version of the resource dll is correct
            CString strSatVersion = FileVersionInfo::GetFileVersionStr(languageResource.dllPath);
            CString strNeededVersion;
            strNeededVersion.Format(_T("%u.%u.%u.0"), VersionInfo::GetMajorNumber(), VersionInfo::GetMinorNumber(), VersionInfo::GetPatchNumber());

            if (strSatVersion == strNeededVersion) {
                success = true;
            } else { // The version wasn't correct
                if (showErrorMsg) {
                    int sel = MessageBox(nullptr, _T("Your language pack will not work with this version.\n\nDo you want to visit the download page to get a full package including the translations?"),
                                         _T("MPC-HC"), MB_ICONWARNING | MB_YESNO);
                    if (sel == IDYES) {
                        ShellExecute(nullptr, _T("open"), DOWNLOAD_URL, nullptr, nullptr, SW_SHOWDEFAULT);
                    }
                }
                // Free the loaded resource dll
                FreeLibrary(hMod);
                hMod = nullptr;
            }
        }
    }

    // In case no dll was loaded, load the English translation from the executable
    if (hMod == nullptr) {
        hMod = AfxGetApp()->m_hInstance;
        // If a resource dll was supposed to be loaded we had an error
        success = (languageResource.dllPath == nullptr);
    }
    // In case a dll was loaded, check if some special action is needed
    else if (PRIMARYLANGID(languageResource.localeID) == LANG_ARABIC || PRIMARYLANGID(languageResource.localeID) == LANG_HEBREW) {
        // Hebrew needs the RTL flag.
        SetProcessDefaultLayout(LAYOUT_RTL);
        SetWindowsHookEx(WH_CBT, RTLWindowsLayoutCbtFilterHook, nullptr, GetCurrentThreadId());
    }

    // Free the old resource if it was a dll
    if (AfxGetResourceHandle() != AfxGetApp()->m_hInstance) {
        FreeLibrary(AfxGetResourceHandle());
    }
    // Set the new resource
    AfxSetResourceHandle(hMod);

    return success;
}
Example #7
0
void GHOST_ImeWin32::MoveImeWindow(HWND window_handle, HIMC imm_context)
{
	int x = caret_rect_.m_l;
	int y = caret_rect_.m_t;
	const int kCaretMargin = 1;
	/**
	 * As written in a comment in GHOST_ImeWin32::CreateImeWindow(),
	 * Chinese IMEs ignore function calls to ::ImmSetCandidateWindow()
	 * when a user disables TSF (Text Service Framework) and CUAS (Cicero
	 * Unaware Application Support).
	 * On the other hand, when a user enables TSF and CUAS, Chinese IMEs
	 * ignore the position of the current system caret and uses the
	 * parameters given to ::ImmSetCandidateWindow() with its 'dwStyle'
	 * parameter CFS_CANDIDATEPOS.
	 * Therefore, we do not only call ::ImmSetCandidateWindow() but also
	 * set the positions of the temporary system caret if it exists.
	 */
	CANDIDATEFORM candidate_position = { 0, CFS_CANDIDATEPOS, { x, y },
	{ 0, 0, 0, 0 } };
	::ImmSetCandidateWindow(imm_context, &candidate_position);
	if (system_caret_) {
		switch (PRIMARYLANGID(input_language_id_)) {
		case LANG_JAPANESE:
			::SetCaretPos(x, y + caret_rect_.getHeight());
			break;
		default:
			::SetCaretPos(x, y);
			break;
		}
	}
	if (PRIMARYLANGID(input_language_id_) == LANG_KOREAN) {
		/**
		 * Chinese IMEs and Japanese IMEs require the upper-left corner of
		 * the caret to move the position of their candidate windows.
		 * On the other hand, Korean IMEs require the lower-left corner of the
		 * caret to move their candidate windows.
		 */
		y += kCaretMargin;
	}
	/**
	 * Japanese IMEs and Korean IMEs also use the rectangle given to
	 * ::ImmSetCandidateWindow() with its 'dwStyle' parameter CFS_EXCLUDE
	 * to move their candidate windows when a user disables TSF and CUAS.
	 * Therefore, we also set this parameter here.
	 */
	CANDIDATEFORM exclude_rectangle = { 0, CFS_EXCLUDE, { x, y },
	{ x, y, x + caret_rect_.getWidth(), y + caret_rect_.getHeight() } };
	::ImmSetCandidateWindow(imm_context, &exclude_rectangle);
}
Example #8
0
/// <summary>
/// Loads the satellite DLL for the specified language from subdirectories
/// named with decimal LCID.
/// </summary>
/// <param name="langDesired">Desired language.</param>
/// <param name="lpszBaseDir">Directory with all the language subdirectories.</param>
/// <param name="lpszSatName">Name of the satellite DLL.</param>
/// <returns>Handle to the satellite DLL.</returns>
HMODULE LoadSatelliteDLL(LANGID langDesired, LPCTSTR lpszBaseDir, LPCTSTR lpszSatName)
{
    TCHAR szSatellitePath[MAX_PATH];
    TCHAR szBuffer[12];
    HMODULE hMod;

    // check string lengths
    if (lstrlen(lpszBaseDir) + lstrlen(lpszSatName) + 15 <= MAX_PATH)
    {
        // try to load the library with the fully specified language
        _itot(langDesired, szBuffer, 10);
        wsprintf(szSatellitePath, _T("%s\\%s\\%s"), lpszBaseDir, szBuffer, lpszSatName);
        hMod = LoadLibrary(szSatellitePath);
        if (NULL != hMod)
        {
            return hMod;
        }
        else
        {
            // no luck, try the primary language ID
            langDesired = PRIMARYLANGID(langDesired);
            _itot(langDesired, szBuffer, 10);
            wsprintf(szSatellitePath, _T("%s\\%s\\%s"), lpszBaseDir, szBuffer, lpszSatName);
            hMod = LoadLibrary(szSatellitePath);
            if (NULL != hMod)
            {
                return hMod;
            }
        }
    }

    return NULL;
}
Example #9
0
void InitCommon(PLUGINDATA *pd)
{
  bInitCommon=TRUE;
  hInstanceDLL=pd->hInstanceDLL;
  hMainWnd=pd->hMainWnd;
  hWndEdit=pd->hWndEdit;
  bOldWindows=pd->bOldWindows;
  bAkelEdit=pd->bAkelEdit;
  nMDI=pd->nMDI;
  wLangModule=PRIMARYLANGID(pd->wLangModule);
  hPopupEdit=GetSubMenu(pd->hPopupMenu, MENU_POPUP_EDIT);

  //Initialize WideFunc.h header
  WideInitialize();

  //Plugin name
  {
    int i;

    for (i=0; pd->wszFunction[i] != L':'; ++i)
      wszPluginName[i]=pd->wszFunction[i];
    wszPluginName[i]=L'\0';
  }
  xprintfW(wszPluginTitle, GetLangStringW(wLangModule, STRID_PLUGIN), wszPluginName);
  xstrcpynW(wszCaptureSeparator, L"\n------------------------------------------------------------\n", MAX_PATH);
  ReadOptions(OF_ALL);
}
Example #10
0
static HRESULT lcid_to_rfc1766(LCID lcid, WCHAR *rfc1766, INT len)
{
    WCHAR buffer[6 /* MAX_RFC1766_NAME */];
    INT n = GetLocaleInfoW(lcid, LOCALE_SISO639LANGNAME, buffer, ARRAY_SIZE(buffer));
    INT i;

    if (n)
    {
        i = PRIMARYLANGID(lcid);
        if ((((i == LANG_ENGLISH) || (i == LANG_CHINESE) || (i == LANG_ARABIC)) &&
            (SUBLANGID(lcid) == SUBLANG_DEFAULT)) ||
            (SUBLANGID(lcid) > SUBLANG_DEFAULT)) {

            buffer[n - 1] = '-';
            i = GetLocaleInfoW(lcid, LOCALE_SISO3166CTRYNAME, buffer + n, ARRAY_SIZE(buffer) - n);
            if (!i)
                buffer[n - 1] = '\0';
        }
        else
            i = 0;

        LCMapStringW(LOCALE_USER_DEFAULT, LCMAP_LOWERCASE, buffer, n + i, rfc1766, len);
        return ((n + i) > len) ? E_INVALIDARG : S_OK;
    }
    return E_FAIL;
}
Example #11
0
LANGID TaLocale_GuessBestLangID (LANGID lang)
{
   switch (PRIMARYLANGID(lang))
      {
      case LANG_KOREAN:
         return MAKELANGID(LANG_KOREAN,SUBLANG_KOREAN);

      case LANG_JAPANESE:
         return MAKELANGID(LANG_JAPANESE,SUBLANG_DEFAULT);

      case LANG_ENGLISH:
         return MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US);

      case LANG_CHINESE:
         if (SUBLANGID(lang) != SUBLANG_CHINESE_TRADITIONAL)
            return MAKELANGID(LANG_CHINESE,SUBLANG_CHINESE_SIMPLIFIED);

      case LANG_GERMAN:
         return MAKELANGID(LANG_GERMAN,SUBLANG_GERMAN);

      case LANG_SPANISH:
         return MAKELANGID(LANG_SPANISH,SUBLANG_SPANISH);

      case LANG_PORTUGUESE:
         return MAKELANGID(LANG_PORTUGUESE,SUBLANG_PORTUGUESE_BRAZILIAN);
      }

   return lang;
}
HINSTANCE CMyAxLocCtrl::GetLocalizedResourceHandle(LCID lcid)
{
    LPCTSTR lpszResDll;
    HINSTANCE hResHandle = NULL;
    switch (PRIMARYLANGID(lcid))
    {
    case LANG_ENGLISH:
        lpszResDll = _T("myctlen.dll");
        break;

    case LANG_FRENCH:
        lpszResDll = _T("myctlfr.dll");
        break;

    case LANG_GERMAN:
        lpszResDll = _T("myctlde.dll");
        break;

    case 0:
    default:
        lpszResDll = NULL;
    }

    if (lpszResDll != NULL)
        hResHandle = LoadLibrary(lpszResDll);
    #ifndef _WIN32
        if(hResHandle <= HINSTANCE_ERROR)
           hResHandle = NULL;
    #endif

    return hResHandle;
}
Example #13
0
static BOOL
FillLangListProc(UNUSED HANDLE module, UNUSED PTSTR type, UNUSED PTSTR stringId, WORD langId, LONG_PTR lParam)
{
    langProcData *data = (langProcData*) lParam;

    int index = ComboBox_AddString(data->languages, LangListEntry(IDS_LANGUAGE_NAME, langId));
    ComboBox_SetItemData(data->languages, index, langId);

    /* Select this item if it is the currently displayed language */
    if (langId == data->language
    ||  (PRIMARYLANGID(langId) == PRIMARYLANGID(data->language)
     && ComboBox_GetCurSel(data->languages) == CB_ERR) )
        ComboBox_SetCurSel(data->languages, index);

    return TRUE;
}
/*
 * binary-search our list of LANGID values.  If we don't find the 
 * one we're looking for, mask out the country code and try again 
 * with just the primary language ID
 */
static int
getLocaleEntryIndex(LANGID langID)
{
    int index = -1;
    int tries = 0;
    do {
	int lo, hi, mid;
	lo = 0;
	hi = sizeof(langIDMap) / sizeof(LANGIDtoLocale);
	while (index == -1 && lo < hi) {
	    mid = (lo + hi) / 2;
	    if (langIDMap[mid].langID == langID) {
		index = mid;
	    } else if (langIDMap[mid].langID > langID) {
		hi = mid;
	    } else {
		lo = mid + 1;
	    }
	}
	langID = PRIMARYLANGID(langID);
	++tries;
    } while (index == -1 && tries < 2);

    return index;
}
Example #15
0
static const int lcid_to_fl(LCID lcid, FL_Locale *rtn)
{
	LANGID langid       = LANGIDFROMLCID(lcid);
	LANGID primary_lang = PRIMARYLANGID(langid);
	LANGID sub_lang     = SUBLANGID(langid);
	int    i;

	// try to find an exact primary/sublanguage combo that we know about
	for (i = 0; i < num_both_to_code; ++i)
	{
		if (both_to_code[i].id == langid)
		{
			accumulate_locstring(both_to_code[i].code, rtn);
			return 1;
		}
	}
	// fallback to just checking the primary language id
	for (i = 0; i < num_primary_to_code; ++i)
	{
		if (primary_to_code[i].id == primary_lang)
		{
			accumulate_locstring(primary_to_code[i].code, rtn);
			return 1;
		}
	}
	return 0;
}
Example #16
0
void ASLocalizer::setLanguageFromLCID(size_t lcid)
// Windows get the language to use from the user locale.
// NOTE: GetUserDefaultLocaleName() gets nearly the same name as Linux.
//       But it needs Windows Vista or higher.
//       Same with LCIDToLocaleName().
{
	m_lcid = lcid;
	m_langID = "en";	// default to english

	size_t lang = PRIMARYLANGID(LANGIDFROMLCID(m_lcid));
	size_t sublang = SUBLANGID(LANGIDFROMLCID(m_lcid));
	// find language in the wlc table
	size_t count = sizeof(wlc) / sizeof(wlc[0]);
	for (size_t i = 0; i < count; i++)
	{
		if (wlc[i].winLang == lang)
		{
			m_langID = wlc[i].canonicalLang;
			break;
		}
	}
	if (m_langID == "zh")
	{
		if (sublang == SUBLANG_CHINESE_SIMPLIFIED || sublang == SUBLANG_CHINESE_SINGAPORE)
			m_subLangID = "CHS";
		else
			m_subLangID = "CHT";	// default
	}
	setTranslationClass();
}
Example #17
0
/**********************************************************************
 *	    PE_FindResourceExW
 *
 * FindResourceExA/W does search in the following order:
 * 1. Exact specified language
 * 2. Language with neutral sublanguage
 * 3. Neutral language with neutral sublanguage
 * 4. Neutral language with default sublanguage
 */
HRSRC PE_FindResourceExW( HMODULE hmod, LPCWSTR name, LPCWSTR type, WORD lang )
{
    const IMAGE_RESOURCE_DIRECTORY *resdirptr = get_resdir(hmod);
    const void *root;
    HRSRC result;

    if (!resdirptr) return 0;

    root = resdirptr;
    if (!(resdirptr = find_entry_by_nameW(resdirptr, type, root))) return 0;
    if (!(resdirptr = find_entry_by_nameW(resdirptr, name, root))) return 0;

    /* 1. Exact specified language */
    if ((result = (HRSRC)find_entry_by_id( resdirptr, lang, root ))) goto found;

    /* 2. Language with neutral sublanguage */
    lang = MAKELANGID(PRIMARYLANGID(lang), SUBLANG_NEUTRAL);
    if ((result = (HRSRC)find_entry_by_id( resdirptr, lang, root ))) goto found;

    /* 3. Neutral language with neutral sublanguage */
    lang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL);
    if ((result = (HRSRC)find_entry_by_id( resdirptr, lang, root ))) goto found;

    /* 4. Neutral language with default sublanguage */
    lang = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
    result = (HRSRC)find_entry_by_id( resdirptr, lang, root );

 found:
    return result;
}
Example #18
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) {
	hInst = hInstance;
	
	HiconDLG = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON2), IMAGE_ICON, 128, 128, 0);

	hMainDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_MAINDLG), (HWND)NULL, MainDlgProc);
	if(!hMainDlg) return false;
	
	HICON HiconDLGico = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
	SetClassLong(hMainDlg, GCL_HICON, (LONG) HiconDLGico);

	// Переводит диалоговое окно на русский если язык операционной системы русский
	if (PRIMARYLANGID(GetUserDefaultLangID()) == LANG_RUSSIAN){
		SetWindowText(hMainDlg, Utf8_to_cp1251("Metin2 лаунчер").c_str());
		SetDlgItemText(hMainDlg, IDC_BUTTON, Utf8_to_cp1251("Запуск").c_str());
		SetDlgItemText(hMainDlg, IDC_BUTTON2, Utf8_to_cp1251("Запуск с AntiDDoS").c_str());
		SetDlgItemText(hMainDlg, IDC_BUTTON3, Utf8_to_cp1251("Запуск прокси сервера").c_str());
	}
	
	MSG msg;
	while (GetMessage(&msg, NULL, NULL, NULL)) {
		if (!IsWindow(hMainDlg) || !IsDialogMessage(hMainDlg, &msg)) {
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}	// if (!IsWindow(hMainDlg) || !IsDialogMessage(hMainDlg, &msg))
	}	// while (GetMessage(&msg, NULL, NULL, NULL))
	
	return true;
	DestroyIcon(HiconDLGico);
	DestroyIcon(HiconDLG);
}
Example #19
0
File: input.c Project: mikekap/wine
/***********************************************************************
 *		GetKeyboardLayoutList (USER32.@)
 *
 * Return number of values available if either input parm is
 *  0, per MS documentation.
 */
UINT WINAPI GetKeyboardLayoutList(INT nBuff, HKL *layouts)
{
    HKEY hKeyKeyboard;
    DWORD rc;
    INT count = 0;
    ULONG_PTR baselayout;
    LANGID langid;
    static const WCHAR szKeyboardReg[] = {'S','y','s','t','e','m','\\','C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\','C','o','n','t','r','o','l','\\','K','e','y','b','o','a','r','d',' ','L','a','y','o','u','t','s',0};

    TRACE_(keyboard)("(%d,%p)\n",nBuff,layouts);

    baselayout = GetUserDefaultLCID();
    langid = PRIMARYLANGID(LANGIDFROMLCID(baselayout));
    if (langid == LANG_CHINESE || langid == LANG_JAPANESE || langid == LANG_KOREAN)
        baselayout |= 0xe001 << 16; /* IME */
    else
        baselayout |= baselayout << 16;

    /* Enumerate the Registry */
    rc = RegOpenKeyW(HKEY_LOCAL_MACHINE,szKeyboardReg,&hKeyKeyboard);
    if (rc == ERROR_SUCCESS)
    {
        do {
            WCHAR szKeyName[9];
            HKL layout;
            rc = RegEnumKeyW(hKeyKeyboard, count, szKeyName, 9);
            if (rc == ERROR_SUCCESS)
            {
                layout = (HKL)strtoulW(szKeyName,NULL,16);
                if (baselayout != 0 && layout == (HKL)baselayout)
                    baselayout = 0; /* found in the registry do not add again */
                if (nBuff && layouts)
                {
                    if (count >= nBuff ) break;
                    layouts[count] = layout;
                }
                count ++;
            }
        } while (rc == ERROR_SUCCESS);
        RegCloseKey(hKeyKeyboard);
    }

    /* make sure our base layout is on the list */
    if (baselayout != 0)
    {
        if (nBuff && layouts)
        {
            if (count < nBuff)
            {
                layouts[count] = (HKL)baselayout;
                count++;
            }
        }
        else
            count++;
    }

    return count;
}
Example #20
0
static WORD 
pdhservice_get_system_primary_lang_id(void)
{
   LANGID lang_id = GetSystemDefaultUILanguage();
   WORD prim_lang_id = PRIMARYLANGID(lang_id);

   return prim_lang_id;
}
// Test whether the language represented by this locale identifier is a
//  right-to-left language, using bit 123 of the Unicode subset bitfield in
//  the LOCALESIGNATURE
// See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/unicode_63ub.asp
bool nsBidiKeyboard::IsRTLLanguage(HKL aLocale)
{
  LOCALESIGNATURE localesig;
  return (::GetLocaleInfoW(PRIMARYLANGID((DWORD_PTR)aLocale),
                           LOCALE_FONTSIGNATURE,
                           (LPWSTR)&localesig,
                           (sizeof(localesig)/sizeof(WCHAR))) &&
          (localesig.lsUsb[3] & 0x08000000));
}
Example #22
0
CMediaInfoDlg::CMediaInfoDlg()
{
	LANGID   _SysLangId   =   GetSystemDefaultLangID();

	if(PRIMARYLANGID(_SysLangId)   ==   LANG_CHINESE) {
		if(SUBLANGID(_SysLangId)   ==   SUBLANG_CHINESE_SIMPLIFIED)
			codepage = 936;		//Simplified Chinese GBK
		else if(SUBLANGID(_SysLangId)   ==   SUBLANG_CHINESE_TRADITIONAL)
			codepage = 950;		//Traditional Chinese Big5
		else if(SUBLANGID(_SysLangId)   ==   SUBLANG_CHINESE_HONGKONG)
			codepage = 950;		//Traditional Chinese Big5
	} else if(PRIMARYLANGID(_SysLangId)   ==   LANG_JAPANESE)
		codepage = 932;			//Japanese Shift-JIS
	else if(PRIMARYLANGID(_SysLangId)   ==   LANG_KOREAN)
		codepage = 949;			//Korean

	m_wndListCtrl.RegisterClass();
}
Example #23
0
// FindLocaleDirectory:  Search the provided path for one of the expected code page subdirectories
// Returns empty string on failure, or the full path to the c:\my\directory\1033\myrcfile.dll
static MyString FindLocaleDirectory(const MyString &path, const MyString &dllName)
{
    // We'll be checking for 3 different locales:  The user's default locale
    // The user's primary language locale, and english (in that order)
    const LCID lcidUser = MAKELCID(GetUserDefaultUILanguage(), SORT_DEFAULT);
    LCID rglcid[3] = {lcidUser, MAKELCID(MAKELANGID(PRIMARYLANGID(lcidUser), SUBLANG_DEFAULT), SORTIDFROMLCID(lcidUser)), ENGLISH_LCID};

    for (int i = 0; i < _countof(rglcid); i++)
    {
        LCID lcid = rglcid[i];
        // Turn the LCID into a string
        wchar_t wzNumBuf[12];
        _itow_s(lcid, wzNumBuf, _countof(wzNumBuf), 10);
        MyString localePath = MakePath(path, wzNumBuf, dllName);

        // Check to see if the file exists
        if (FileExists(localePath))
        {
            // make sure the console can support a codepage for this language.
            UINT ConsoleCP = GetConsoleOutputCP();
            
            // Dev10 #843375: For a GUI application, GetConsoleOutputCP returns 0
            // If that's the case, we don't care about capabilities of the console, 
            // since we're not outputting to the console, anyway...
            if ( ConsoleCP != 0 && lcid != ENGLISH_LCID )
            {
                LANGID LanguageID = MAKELANGID( lcid, SUBLANGID(lcid) );
                // we know the console cannot support arabic or hebrew (right to left scripts?)
                if( PRIMARYLANGID(LanguageID) == LANG_ARABIC || PRIMARYLANGID(LanguageID) == LANG_HEBREW )
                    continue;

                UINT LangOEMCodepage = GetCodePage(LanguageID, LOCALE_IDEFAULTCODEPAGE);
                UINT LangANSICodepage = GetCodePage(LanguageID, LOCALE_IDEFAULTANSICODEPAGE);

                // We can only support it if the console's code page is UTF8, OEM, or ANSI
                if( ConsoleCP != CP_UTF8 && ConsoleCP != LangOEMCodepage && ConsoleCP != LangANSICodepage )
                    continue;
            }

            return localePath;
        }
    }
    return W("");
}
Example #24
0
/* Returns true if the user interface is in English. Note that this does not
 * presume of the formatting of dates, numbers, etc.
 */
static BOOL is_lang_english(void)
{
    static HMODULE hkernel32 = NULL;
    static LANGID (WINAPI *pGetThreadUILanguage)(void) = NULL;
    static LANGID (WINAPI *pGetUserDefaultUILanguage)(void) = NULL;

    if (!hkernel32)
    {
        hkernel32 = GetModuleHandleA("kernel32.dll");
        pGetThreadUILanguage = (void*)GetProcAddress(hkernel32, "GetThreadUILanguage");
        pGetUserDefaultUILanguage = (void*)GetProcAddress(hkernel32, "GetUserDefaultUILanguage");
    }
    if (pGetThreadUILanguage)
        return PRIMARYLANGID(pGetThreadUILanguage()) == LANG_ENGLISH;
    if (pGetUserDefaultUILanguage)
        return PRIMARYLANGID(pGetUserDefaultUILanguage()) == LANG_ENGLISH;

    return PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH;
}
Example #25
0
//---------------------------------------------------------------------------------------
void GetLangTLA(TCHAR szLang[], int nSize)
{
   short nLangID = GetUserDefaultLangID();
   short nPrimaryLangID = PRIMARYLANGID(nLangID);

   if(nPrimaryLangID == LANG_ENGLISH)
      _tcsncpy_s(szLang, nSize, _T("ENU"), _TRUNCATE);
   else
      _tcsncpy_s(szLang, nSize, _T("ENU"), _TRUNCATE);
}
/* OnInitDone
 * ----------------------------------------------------------------------------
 */
void CFolderDialog::OnInitDone()
{
    HideControl(stc2);
    HideControl(cmb1);

    CWnd* pFD = GetParent();

    LCID lcid = GetSystemDefaultLCID();

    switch(PRIMARYLANGID(LANGIDFROMLCID(lcid)))
    {
    default:
    case LANG_ENGLISH:
        SetControlText(stc3, "Folder:");
        SetControlText(IDOK, "&Select");
        pFD->SetWindowText("Select Folder");
        break;

    case LANG_GERMAN:
        SetControlText(stc3, "Verzeichnis:");
        SetControlText(IDOK, "&Auswahl");
        pFD->SetWindowText("Verzeichnis auswählen");
        break;
    }

    SetControlText(edt1, m_sSelPath);

    CRect rStatic;
    pFD->GetDlgItem(stc3)->GetWindowRect(rStatic);
    pFD->ScreenToClient(rStatic);
    rStatic.right -= 10;
    pFD->GetDlgItem(stc3)->SetWindowPos(0, 0, 0, rStatic.Width(), rStatic.Height(), SWP_NOMOVE | SWP_NOZORDER);

    CRect rectCancel;
    pFD->GetDlgItem(IDCANCEL)->GetWindowRect(rectCancel);
    pFD->ScreenToClient(rectCancel);

    CRect rectOK;
    pFD->GetDlgItem(IDOK)->GetWindowRect(rectOK);
    pFD->ScreenToClient(rectOK);
    pFD->GetDlgItem(IDOK)->SetWindowPos(0,rectCancel.left - rectOK.Width() - 4, rectCancel.top, 0,0, SWP_NOZORDER | SWP_NOSIZE);

    CRect rList;
    pFD->GetDlgItem(lst1)->GetWindowRect(rList);
    pFD->ScreenToClient(rList);

    CRect rEdit;
    pFD->GetDlgItem(edt1)->GetWindowRect(rEdit);
    pFD->ScreenToClient(rEdit);
    rEdit.left = rStatic.right + 10;
    pFD->GetDlgItem(edt1)->SetWindowPos(0, rEdit.left, rEdit.top, rList.right - rEdit.left, rEdit.Height(), SWP_NOZORDER);

    m_fpWndProcDiag = (WNDPROC)SetWindowLong(pFD->m_hWnd, GWL_WNDPROC, (long)WindowProcDiag);
    m_fpWndProcEdit = (WNDPROC)SetWindowLong(pFD->GetDlgItem(edt1)->m_hWnd, GWL_WNDPROC, (long)WindowProcEdit);
}
Example #27
0
//! note: this function can be extended to include other exotic cases as they arise.
// This function was added in response to bug [#25715]
GHOST_TKey GHOST_SystemWin32::processSpecialKey(GHOST_IWindow *window, short vKey, short scanCode) const
{
	GHOST_TKey key = GHOST_kKeyUnknown;
	switch (PRIMARYLANGID(m_langId)) {
		case LANG_FRENCH:
			if (vKey == VK_OEM_8) key = GHOST_kKeyF13;  // oem key; used purely for shortcuts .
			break;
	}

	return key;
}
Example #28
0
//! note: this function can be extended to include other exotic cases as they arise.
// This function was added in response to bug [#25715]
GHOST_TKey GHOST_SystemWin32::processSpecialKey(GHOST_IWindow *window, WPARAM wParam, LPARAM lParam) const
{
	GHOST_TKey key = GHOST_kKeyUnknown;
	switch(PRIMARYLANGID(m_langId)) {
		case LANG_FRENCH:
			if(wParam==VK_OEM_8) key = GHOST_kKey1; // on 'normal' shift + 1 to create '!' we also get GHOST_kKey1. ASCII will be '!'.
			break;
	}

	return key;
}
Example #29
0
//+---------------------------------------------------------------------------
//  COMPLEXSCRIPT
//  Function:       IsBidiLCID(lcid)
//
//  Returns:        True iff lcid is a right to left locale.
//
//----------------------------------------------------------------------------
BOOL IsBidiLCID(LCID lcid)
{
    switch(PRIMARYLANGID(LANGIDFROMLCID(lcid)))
    {
    case LANG_ARABIC:
    case LANG_FARSI:
    case LANG_HEBREW:
        return TRUE;
    }

    return FALSE;
}
Example #30
0
//+---------------------------------------------------------------------------
//
//  Function:       IsFarEastLCID(lcid)
//
//  Returns:        True iff lcid is a Far East locale.
//
//----------------------------------------------------------------------------
BOOL IsFarEastLCID(LCID lcid)
{
    switch(PRIMARYLANGID(LANGIDFROMLCID(lcid)))
    {
    case LANG_CHINESE:
    case LANG_JAPANESE:
    case LANG_KOREAN:
        return TRUE;
    }

    return FALSE;
}