Beispiel #1
0
__private_extern__ CFArrayRef CFLocaleWindowsGetInstalledLocales(void)
{
    CFArrayRef WindowsLocales;
    EnumSystemLocales((LOCALE_ENUMPROC)WindowsLocaleEnumProc, LCID_INSTALLED);
    WindowsLocales = CFArrayCreate(kCFAllocatorSystemDefault, (const void**)s_WindowsInstalledLocales, s_num_installed_localesI, &kCFTypeArrayCallBacks);
    return (WindowsLocales);
}
Beispiel #2
0
INT_PTR CALLBACK
AddDlgProc(HWND hDlg,
           UINT message,
           WPARAM wParam,
           LPARAM lParam)
{
    UNREFERENCED_PARAMETER(lParam);

    switch (message)
    {
        case WM_INITDIALOG:
        {
            hLangList = GetDlgItem(hDlg, IDC_INPUT_LANG_COMBO);
            hLayoutList = GetDlgItem(hDlg, IDC_KEYBOARD_LO_COMBO);
            EnumSystemLocales(LanguagesEnumProc, LCID_INSTALLED);
            CreateKeyboardLayoutList(hLayoutList);
        }
        break;

        case WM_COMMAND:
        {
            switch (LOWORD(wParam))
            {
                case IDC_INPUT_LANG_COMBO:
                {
                    if (HIWORD(wParam) == CBN_SELCHANGE)
                    {
                        SelectLayoutByLang();
                    }
                }
                break;

                case IDOK:
                {
                    AddNewLayout(hDlg);
                    EndDialog(hDlg, LOWORD(wParam));
                }
                break;

                case IDCANCEL:
                {
                    EndDialog(hDlg, LOWORD(wParam));
                }
            }
        }
        break;

        case WM_DESTROY:
        {
            INT iCount;

            for(iCount = SendMessage(hLayoutList, CB_GETCOUNT, 0, 0); --iCount >= 0;)
                HeapFree(hProcessHeap, 0, (LPVOID)SendMessage(hLayoutList, CB_GETITEMDATA, iCount, 0));
        }
        break;
    }

    return FALSE;
}
QList<KeyboardLayout::LanguageInfo> KeyboardLayout::languages()
{
    if (langList.isEmpty()) {
        EnumSystemLocales(&KeyboardLayout::enumLocalesCallback, LCID_INSTALLED);
        //EnumLanguageGroupLocales(&KeyboardLayout::enumLanguageGroupLocalesProc );
        qSort(langList);
    }
    return langList;
}
Beispiel #4
0
/*
 * Function: nl_locale_id_lookup
 *
 * Description:
 *   A private helper function; it wraps a call to the `EnumSystemLocales' API,
 *   to make an `nl_locale_lookup' callback, ensuring that the `nl_locale_id'
 *   global variable is set to `LCID_UNKNOWN', in the event that the requested
 *   LCID lookup is unresolved.
 *
 * Usage:
 *   nl_locale_id_lookup( void )
 *
 * Inputs:
 *   None.
 *
 * Global Input References:
 *   nl_env_name (char **)  list of locale specification components to match
 *
 * Returns:
 *   Global variable `nl_locale_id' set to the LCID for the locale which
 *   matches `nl_env_name', if any, or to `LCID_UNKNOWN' otherwise; this
 *   also becomes the function return value.
 */
static
LCID nl_locale_id_lookup()
{
    /* Initialise the global return value repository for a failed lookup,
     * before handing the request to `nl_locale_lookup', via `EnumSystemLocales.
     */
    nl_locale_id = LCID_UNKNOWN;
    EnumSystemLocales( nl_locale_lookup, LCID_SUPPORTED );
    /*
     * Retrieve the eventual return value from the global repository.
     */
    return nl_locale_id;
}
Beispiel #5
0
BOOL
IsSortPageNeeded(LCID lcid)
{
    /* Handle special case for Spanish (Spain) */
    if (lcid == MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH), SORT_DEFAULT) ||
        lcid == MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_MODERN), SORT_DEFAULT))
        return TRUE;

    userLcid = lcid;
    bSortPage = FALSE;

    EnumSystemLocales(SortTestEnumProc, LCID_ALTERNATE_SORTS);

    return bSortPage;
}
Beispiel #6
0
void GetDictsInfo(LIST<Dictionary> &dicts)
{
	tmp_dicts = &dicts;
	EnumSystemLocales(EnumLocalesProc, LCID_SUPPORTED);

	// Try to get name from DB
	for(int i = 0; i < dicts.getCount(); i++)
	{
		Dictionary *dict = dicts[i];
		
		if (dict->full_name[0] == _T('\0'))
		{
			DBVARIANT dbv;
#ifdef UNICODE
			char lang[128];
			WideCharToMultiByte(CP_ACP, 0, dict->language, -1, lang, sizeof(lang), NULL, NULL);
			if (!DBGetContactSettingTString(NULL, MODULE_NAME, lang, &dbv))
#else
			if (!DBGetContactSettingTString(NULL, MODULE_NAME, dict->language, &dbv))
#endif
			{
				lstrcpyn(dict->localized_name, dbv.ptszVal, MAX_REGS(dict->localized_name));
				DBFreeVariant(&dbv);
			}

			if (dict->localized_name[0] == _T('\0'))
			{
				for(size_t j = 0; j < MAX_REGS(aditionalLanguages); j+=2)
				{
					if (lstrcmp(aditionalLanguages[j], dict->language) == 0)
					{
						lstrcpyn(dict->localized_name, aditionalLanguages[j+1], MAX_REGS(dict->localized_name));
						break;
					}
				}
			}

			if (dict->localized_name[0] != _T('\0'))
			{
				mir_sntprintf(dict->full_name, MAX_REGS(dict->full_name), _T("%s [%s]"), dict->localized_name, dict->language);
			}
			else
			{
				lstrcpyn(dict->full_name, dict->language, MAX_REGS(dict->full_name));
			}
		}
	}
}
Beispiel #7
0
static VOID
CreateLanguagesList(HWND hwnd)
{
    TCHAR langSel[255];

    hList = hwnd;
    bSpain = FALSE;
    EnumSystemLocales(LocalesEnumProc, LCID_SUPPORTED);

    /* Select current locale */
    /* or should it be System and not user? */
    GetLocaleInfo(GetUserDefaultLCID(), LOCALE_SLANGUAGE, langSel, sizeof(langSel)/sizeof(TCHAR));

    SendMessage(hList,
                CB_SELECTSTRING,
                -1,
                (LPARAM)langSel);
}
Beispiel #8
0
// CSetDialogs2 message handlers
BOOL CSetDialogs3::OnInitDialog()
{
	ISettingsPropPage::OnInitDialog();

	AddTrueFalseToComboBox(m_cWarnNoSignedOffBy);

	m_langCombo.AddString(_T(""));
	m_langCombo.SetItemData(0, (DWORD_PTR)-2);
	m_langCombo.AddString(_T("(auto)")); // do not translate, the order matters!
	m_langCombo.SetItemData(1, 0);
	m_langCombo.AddString(_T("(disable)")); // do not translate, the order matters!
	m_langCombo.SetItemData(2, (DWORD_PTR)-1);
	// fill the combo box with all available languages
	EnumSystemLocales(EnumLocalesProc, LCID_SUPPORTED);

	m_tooltips.Create(this);

	InitGitSettings(this, true, &m_tooltips);

	UpdateData(FALSE);
	return TRUE;
}
Beispiel #9
0
static void
setup_config (void)
{
  const char *coding_name;
  const char *cp;
  char *end;
  int slen;
  Lisp_Object coding_system;
  Lisp_Object dos_coding_system;

  CHECK_SYMBOL (Vselection_coding_system);

  coding_system = NILP (Vnext_selection_coding_system) ?
    Vselection_coding_system : Vnext_selection_coding_system;

  dos_coding_system = validate_coding_system (coding_system);
  if (NILP (dos_coding_system))
    Fsignal (Qerror,
	     list2 (build_string ("Coding system is invalid or doesn't have "
				  "an eol variant for dos line ends"),
		    coding_system));

  /* Check if we have it cached */
  if (!NILP (cfg_coding_system)
      && EQ (cfg_coding_system, dos_coding_system))
    return;
  cfg_coding_system = dos_coding_system;

  /* Set some sensible fallbacks */
  cfg_codepage = ANSICP;
  cfg_lcid = LOCALE_NEUTRAL;
  cfg_clipboard_type = CF_TEXT;

  /* Interpret the coding system symbol name */
  coding_name = SSDATA (SYMBOL_NAME (cfg_coding_system));

  /* "(.*-)?utf-16.*" -> CF_UNICODETEXT */
  cp = strstr (coding_name, "utf-16");
  if (cp != NULL && (cp == coding_name || cp[-1] == '-'))
    {
      cfg_clipboard_type = CF_UNICODETEXT;
      return;
    }

  /* "cp[0-9]+.*" or "windows-[0-9]+.*" -> CF_TEXT or CF_OEMTEXT */
  slen = strlen (coding_name);
  if (slen >= 4 && coding_name[0] == 'c' && coding_name[1] == 'p')
    cp = coding_name + 2;
  else if (slen >= 10 && memcmp (coding_name, "windows-", 8) == 0)
    cp = coding_name + 8;
  else
    return;

  end = (char*)cp;
  cfg_codepage = strtol (cp, &end, 10);

  /* Error return from strtol() or number of digits < 2 -> Restore the
     default and drop it. */
  if (cfg_codepage == 0 || (end-cp) < 2 )
    {
      cfg_codepage = ANSICP;
      return;
    }

  /* Is it the currently active system default? */
  if (cfg_codepage == ANSICP)
    {
      /* cfg_clipboard_type = CF_TEXT; */
      return;
    }
  if (cfg_codepage == OEMCP)
    {
      cfg_clipboard_type = CF_OEMTEXT;
      return;
    }

  /* Else determine a suitable locale the hard way. */
  EnumSystemLocales (enum_locale_callback, LCID_INSTALLED);
}
Beispiel #10
0
///////////////////////////////////////////////////////////////////////////////////////////
//    Function:        NLSDlgProc
//
//    Description:    Message-processing function for text tab
//
//    Comments:        
//
///////////////////////////////////////////////////////////////////////////////////////////
INT_PTR CALLBACK NLSDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    BOOL bProcessedMsg = TRUE;
    
    switch(uMsg)
    {
        case WM_INITDIALOG:
        {
            LVCOLUMN    lvcCol = {0};
            UINT        lcid = 0;
            LVFINDINFO  lvInfo = {0};
            int         iItem = 0;

            // load our own icon
            SendMessage(GetParent(hDlg), WM_SETICON, ICON_BIG, (LPARAM) (LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_MAINICON))));

            // Create our list column  for the listview control
            g_hwndList = GetDlgItem(hDlg, IDC_LV_LCID);
            g_hDlg = hDlg;

            lvcCol.mask = LVCF_TEXT;
            LoadString(g_hRes, STR_LANGID, g_tcsTemp, MAX_STR);
            lvcCol.pszText = g_tcsTemp;
            ListView_InsertColumn(g_hwndList, COLUMN_LANGID, (LV_COLUMN *)&lvcCol);

            LoadString(g_hRes, STR_LANG, g_tcsTemp, MAX_STR);
            lvcCol.pszText = g_tcsTemp;
            ListView_InsertColumn(g_hwndList, COLUMN_LANGUAGE, (LV_COLUMN *)&lvcCol);

            LoadString(g_hRes, STR_NLANG, g_tcsTemp, MAX_STR);
            lvcCol.pszText = g_tcsTemp;
            ListView_InsertColumn(g_hwndList, COLUMN_NATIVELANG, (LV_COLUMN *)&lvcCol);

            LoadString(g_hRes, STR_NCOUNTRY, g_tcsTemp, MAX_STR);
            lvcCol.pszText = g_tcsTemp;
            ListView_InsertColumn(g_hwndList, COLUMN_NATIVECOUNTRYREGION, (LV_COLUMN *)&lvcCol);

            LoadString(g_hRes, STR_ACP, g_tcsTemp, MAX_STR);
            lvcCol.pszText = g_tcsTemp;
            ListView_InsertColumn(g_hwndList, COLUMN_ACP, (LV_COLUMN *)&lvcCol);

            LoadString(g_hRes, STR_OEMCP, g_tcsTemp, MAX_STR);
            lvcCol.pszText = g_tcsTemp;
            ListView_InsertColumn(g_hwndList, COLUMN_OEMCP, (LV_COLUMN *)&lvcCol);

            // fill out our listview control with available locales (supported ones).
            EnumSystemLocales(EnumLocalesProc, LCID_SUPPORTED);

            // Initialize formatting fields related to the selected locale in the listview
            InitNLSFields(hDlg, LOCALE_USER_DEFAULT);

            // Set the column width of the listview control.
            ListView_SetColumnWidth(g_hwndList, COLUMN_LANGID, LVSCW_AUTOSIZE_USEHEADER);
            ListView_SetColumnWidth(g_hwndList, COLUMN_LANGUAGE, LVSCW_AUTOSIZE_USEHEADER);
            ListView_SetColumnWidth(g_hwndList, COLUMN_NATIVELANG, LVSCW_AUTOSIZE_USEHEADER);
            ListView_SetColumnWidth(g_hwndList, COLUMN_NATIVECOUNTRYREGION, LVSCW_AUTOSIZE_USEHEADER);
            ListView_SetColumnWidth(g_hwndList, COLUMN_ACP, LVSCW_AUTOSIZE_USEHEADER);
            ListView_SetColumnWidth(g_hwndList, COLUMN_OEMCP, LVSCW_AUTOSIZE_USEHEADER);

            // Find user's current locale and select that item in the listview control.
            lcid = GetUserDefaultLCID();
            
            // Our list has all the LCIDs in 4 digits (0409) whereas GetUserDefaultLCID returs (409).
            if (lcid < 0x1000)
            {
                _sntprintf(g_tcsTemp,MAX_STR,TEXT("0%x"), lcid);
            }
            else
            {
                _sntprintf(g_tcsTemp,MAX_STR,TEXT("%x"), lcid);
            }

            lvInfo.flags = LVFI_STRING;
            lvInfo.psz = g_tcsTemp;

            iItem = ListView_FindItem(g_hwndList, 0, &lvInfo);
            ListView_SetItemState (g_hwndList, iItem, LVIS_FOCUSED | LVIS_SELECTED, 0x000F);
            ListView_EnsureVisible(g_hwndList, iItem, FALSE);

            // Set some of the extended styles of our list view (cool reports ;-)
            ListView_SetExtendedListViewStyle(g_hwndList, LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP | LVS_EX_GRIDLINES | LVS_EX_TWOCLICKACTIVATE);
        }
        break;

        case WM_NOTIFY:
            switch (((NMHDR *)lParam)->code)
            {
                case LVN_COLUMNCLICK:
                    {
                        NM_LISTVIEW nmv;
                        static int iLastSort = COLUMN_LANGID;
                        LPARAM lSortParam = -1;
                        LVFINDINFO lvInfo;
                        int         iItem;

                        // When a column is clicked we need to redo our sorting of preview table.

                        nmv = *(const NM_LISTVIEW *) lParam;

                        // We don't sort for native language and native country name (avoid confusion).
                        if ((nmv.iSubItem == COLUMN_NATIVELANG) || (nmv.iSubItem == COLUMN_NATIVECOUNTRYREGION))
                        {
                            break;
                        }

                        // If our last sorting was on a different column, we need to do more
                        // than simply reverting our sorting.
                        // Because of listview sorting limitations, we need to redo our list...
                        if (iLastSort != nmv.iSubItem)
                        {
                            // The list view sorting is based on a q-sort, we need to redo our list!
                            ListView_DeleteAllItems(g_hwndList);
                            g_iCounter  = 0;
                            EnumSystemLocales(EnumLocalesProc, LCID_SUPPORTED);

                            // Make sure the last selection remains active after sorting...
                            if (g_iCurLocale < 0x1000)
                            {
                                _sntprintf(g_tcsTemp,MAX_STR,TEXT("0%x"), g_iCurLocale);
                            }
                            else
                            {
                                _sntprintf(g_tcsTemp,MAX_STR,TEXT("%x"), g_iCurLocale);
                            }

                            lvInfo.flags = LVFI_STRING;
                            lvInfo.psz = g_tcsTemp;
                            iItem = ListView_FindItem(g_hwndList, 0, &lvInfo);
                            ListView_SetItemState (g_hwndList, iItem, LVIS_FOCUSED | LVIS_SELECTED, 0x000F);

                            // Update our flag for the last column sorted and set the sorting flag
                            iLastSort = nmv.iSubItem;
                            lSortParam = iLastSort;
                        }

                        // Do the actual sorting...
                        ListView_SortItems(g_hwndList, (PFNLVCOMPARE)CompareFunc, lSortParam);

                        // Make sure our selection is visible after the sorting!
                        ListView_EnsureVisible(g_hwndList, ListView_GetSelectionMark(g_hwndList), FALSE);
                    }
                    break;

                case LVN_ITEMCHANGED:   /* fall-through */
                case LVN_ITEMACTIVATE:
                    {
                        LPNM_LISTVIEW lpnmlv = (LPNM_LISTVIEW)lParam;
                        static    int iItem;
                        LVITEM    lvItem = {0};

                        // Item selection has been changed.
                        // Find the new langId and update our formatting fields...
                        if (iItem != lpnmlv->iItem)
                        {
                            iItem = lpnmlv->iItem;

                            lvItem.mask = LVIF_TEXT;
                            lvItem.iItem = iItem;
                            lvItem.pszText = g_tcsTemp;
                            lvItem.cchTextMax  = STR_LEN;
                            ListView_GetItem(g_hwndList, &lvItem);                                                    
                            g_iCurLocale = iConvertStrToInt(lvItem.pszText);
                            InitNLSFields(hDlg, g_iCurLocale);
                        }

                        // Show advanced data on the selected locale...
                        if (((NMHDR *)lParam)->code == LVN_ITEMACTIVATE)
                        {
                           bProcessedMsg = (DialogBox(g_hRes, MAKEINTRESOURCE(DLG_LCID), hDlg, LcidDlgProc) != -1);
                        }
                    }
                    break;
                }
                break;

                case WM_COMMAND:
                    switch(LOWORD(wParam))
                    {
                        case IDCANCEL: /* fall-through*/
                        case IDOK:
                            break;

                        case IDC_TIMEFORMAT:
                            {
                                if(HIWORD(wParam) == CBN_SELCHANGE)
                                {
                                    // Time formating selection has been changed.
                                    // Re-edit time
                                    HWND    hList = NULL;
                                    LRESULT index = 0;
                                    TCHAR    tcTemp[MAX_STR];

                                    hList = GetDlgItem(hDlg, IDC_TIMEFORMAT);

                                    if(NULL == hList)
                                    {
                                        bProcessedMsg = FALSE;
                                        break;
                                    }

                                    index = SendMessage(hList, CB_GETCURSEL, 0, 0);
                                    SendMessage(hList, CB_GETLBTEXT, index, (LPARAM) g_tcsTemp);
                                    GetTimeFormat(g_iCurLocale, 0, NULL, g_tcsTemp, tcTemp, MAX_STR);
                                    SetWindowText(GetDlgItem(hDlg, IDC_TIMESAMPLE), tcTemp);
                                }
                            }
                            break;

                        case IDC_SDATEFORMAT:
                            {
                                if(HIWORD(wParam) == CBN_SELCHANGE)
                                {
                                    // short date formating selection has been changed.
                                    // Re-edit short date
                                    HWND    hList = NULL;
                                    LRESULT index = 0;
                                    TCHAR    tcTemp[MAX_STR];

                                    hList = GetDlgItem(hDlg, IDC_SDATEFORMAT);
                                    
                                    if(NULL == hList)
                                    {
                                        bProcessedMsg = FALSE;
                                        break;
                                    }
                                    index = SendMessage(hList, CB_GETCURSEL, 0, 0);
                                    SendMessage(hList, CB_GETLBTEXT, index, (LPARAM) g_tcsTemp);
                                    GetDateFormat(g_iCurLocale, 0, NULL, g_tcsTemp, tcTemp, MAX_STR);
                                    SetWindowText(GetDlgItem(hDlg, IDC_SDATESAMPLE), tcTemp);
                                }
                            }
                            break;

                        case IDC_LDATEFORMAT:
                            {
                                if(HIWORD(wParam) == CBN_SELCHANGE)
                                {
                                    // long date formating selection has been changed.
                                    // Re-edit long date
                                    HWND    hList = NULL;
                                    LRESULT index = 0;
                                    TCHAR    tcTemp[MAX_STR];

                                    hList = GetDlgItem(hDlg, IDC_LDATEFORMAT);
                                    
                                    if(NULL == hList)
                                    {
                                        bProcessedMsg = FALSE;
                                        break;
                                    }

                                    index = SendMessage(hList, CB_GETCURSEL, 0, 0);
                                    SendMessage(hList, CB_GETLBTEXT, index, (LPARAM) g_tcsTemp);
                                    GetDateFormat(g_iCurLocale, 0, NULL, g_tcsTemp, tcTemp, MAX_STR);
                                    SetWindowText(GetDlgItem(hDlg, IDC_LDATESAMPLE), tcTemp);
                                }
                            }
                            break;
                    }
                    break;

        default:
            bProcessedMsg = FALSE;
    }
    
    return bProcessedMsg;
}
Beispiel #11
0
static VOID
CreateSortList(HWND hwnd, LCID lcid)
{
    TCHAR lang[255];
    INT index;

    hWndSortList = hwnd;

    /* Handle special case for Spainish (Spain) */
    if (lcid == MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH), SORT_DEFAULT) ||
        lcid == MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_MODERN), SORT_DEFAULT))
    {
        /* Add traditional sorting */
        GetLocaleInfo(MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH),
                      LOCALE_SSORTNAME, lang, sizeof(lang)/sizeof(TCHAR));

        index = SendMessage(hwnd,
                            CB_ADDSTRING,
                            0,
                           (LPARAM)lang);

        SendMessage(hwnd,
                    CB_SETITEMDATA,
                    index,
                    (LPARAM)MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH));

        /* Add modern sorting */
        GetLocaleInfo(MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_MODERN),
                      LOCALE_SSORTNAME, lang, sizeof(lang)/sizeof(TCHAR));

        index = SendMessage(hwnd,
                            CB_ADDSTRING,
                            0,
                           (LPARAM)lang);

        SendMessage(hwnd,
                    CB_SETITEMDATA,
                    index,
                    (LPARAM)MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_MODERN));
    }
    else
    {
        userLcid = lcid;

        GetLocaleInfo(lcid & 0xFFFF, LOCALE_SSORTNAME, lang, sizeof(lang)/sizeof(TCHAR));

        index = SendMessage(hWndSortList,
                            CB_ADDSTRING,
                            0,
                            (LPARAM)lang);

        SendMessage(hWndSortList,
                    CB_SETITEMDATA,
                    index,
                    (LPARAM)lcid & 0xFFFF);

        EnumSystemLocales(SortEnumProc, LCID_ALTERNATE_SORTS);
    }

    /* Select current locale */
    /* or should it be System and not user? */
    GetLocaleInfo(lcid, LOCALE_SSORTNAME, lang, sizeof(lang));

    SendMessage(hwnd,
                CB_SELECTSTRING,
                -1,
                (LPARAM)lang);
}