mirror of
				https://github.com/pbatard/rufus.git
				synced 2024-08-14 23:57:05 +00:00 
			
		
		
		
	[loc] set chkdsk and format output to use English locale
* Also fix percentage not being displayed when using slow format * Also use GetUserDefaultUILanguage() rather than GetUserDefaultLCID() to get the user preferred locale. * Closes #189
This commit is contained in:
		
							parent
							
								
									18c9df18b5
								
							
						
					
					
						commit
						897becd290
					
				
					 5 changed files with 63 additions and 13 deletions
				
			
		|  | @ -113,7 +113,7 @@ o Version 1.1.1 (2012.02.16): | |||
|     ISO image support (syslinux) - targeted at Linux installation ISOs | ||||
|     ISO fixes and UI improvements | ||||
| 
 | ||||
| o Version 1.1.0 Beta (2012.02.08): | ||||
| o Version 1.1.0 (2012.02.08): | ||||
|     ISO image support (NTFS, bootmgr only - targeted at Windows installation ISOs) | ||||
| 
 | ||||
| o Version 1.0.7 (2012.02.02): | ||||
|  |  | |||
							
								
								
									
										56
									
								
								src/format.c
									
										
									
									
									
								
							
							
						
						
									
										56
									
								
								src/format.c
									
										
									
									
									
								
							|  | @ -58,6 +58,45 @@ static int fs_index = 0; | |||
| BOOL force_large_fat32 = FALSE; | ||||
| static BOOL WritePBR(HANDLE hLogicalDrive); | ||||
| 
 | ||||
| /* 
 | ||||
|  * Convert the fmifs outputs messages (that use an OEM code page) to UTF-8 | ||||
|  */ | ||||
| static void OutputUTF8Message(const char* src) | ||||
| { | ||||
| 	int len; | ||||
| 	char *dst = NULL; | ||||
| 	wchar_t* wdst = NULL; | ||||
| 	PF_DECL(GetThreadUILanguage); | ||||
| 	PF_INIT_OR_OUT(GetThreadUILanguage, kernel32); | ||||
| 
 | ||||
| 	if (src == NULL) | ||||
| 		goto out; | ||||
| 	len = (int)safe_strlen(src); | ||||
| 	while ((len > 0) && ((src[len-1] == 0x0A) || (src[len-1] == 0x0D) || (src[len-1] == ' '))) | ||||
| 		len--; | ||||
| 	if (len == 0) | ||||
| 		goto out; | ||||
| 
 | ||||
| 	if (PRIMARYLANGID(pfGetThreadUILanguage()) != LANG_ENGLISH) { | ||||
| 		len = MultiByteToWideChar(CP_OEMCP, 0, src, len, NULL, 0); | ||||
| 		if (len == 0) | ||||
| 			goto out; | ||||
| 		wdst = (wchar_t*)calloc(len+1, sizeof(wchar_t)); | ||||
| 		if ((wdst == NULL) || (MultiByteToWideChar(CP_OEMCP, 0, src, len, wdst, len+1) == 0)) | ||||
| 			goto out; | ||||
| 		dst = wchar_to_utf8(wdst); | ||||
| 		if (dst == NULL) | ||||
| 			goto out; | ||||
| 		uprintf("%s", dst); | ||||
| 	} else { | ||||
| 		uprintf("%s", src); | ||||
| 	} | ||||
| 
 | ||||
| out: | ||||
| 	safe_free(dst); | ||||
| 	safe_free(wdst); | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * FormatEx callback. Return FALSE to halt operations | ||||
|  */ | ||||
|  | @ -70,7 +109,7 @@ static BOOLEAN __stdcall FormatExCallback(FILE_SYSTEM_CALLBACK_COMMAND Command, | |||
| 	switch(Command) { | ||||
| 	case FCC_PROGRESS: | ||||
| 		percent = (DWORD*)pData; | ||||
| 		PrintStatus(0, FALSE, MSG_217, *percent); | ||||
| 		PrintStatus(0, FALSE, MSG_217, 1.0f * (*percent)); | ||||
| 		UpdateProgress(OP_FORMAT, 1.0f * (*percent)); | ||||
| 		break; | ||||
| 	case FCC_STRUCTURE_PROGRESS:	// No progress on quick format
 | ||||
|  | @ -118,7 +157,7 @@ static BOOLEAN __stdcall FormatExCallback(FILE_SYSTEM_CALLBACK_COMMAND Command, | |||
| 		FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_LABEL_TOO_LONG; | ||||
| 		break; | ||||
| 	case FCC_OUTPUT: | ||||
| 		uprintf("%s\n", ((PTEXTOUTPUT)pData)->Output); | ||||
| 		OutputUTF8Message(((PTEXTOUTPUT)pData)->Output); | ||||
| 		break; | ||||
| 	case FCC_CLUSTER_SIZE_TOO_BIG: | ||||
| 	case FCC_CLUSTER_SIZE_TOO_SMALL: | ||||
|  | @ -183,8 +222,7 @@ static BOOLEAN __stdcall ChkdskCallback(FILE_SYSTEM_CALLBACK_COMMAND Command, DW | |||
| 		FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_DEVICE_IN_USE; | ||||
| 		break; | ||||
| 	case FCC_OUTPUT: | ||||
| 		// TODO: convert from sys CP to UTF-8
 | ||||
| 		uprintf("%s\n", ((PTEXTOUTPUT)pData)->Output); | ||||
| 		OutputUTF8Message(((PTEXTOUTPUT)pData)->Output); | ||||
| 		break; | ||||
| 	case FCC_NO_MEDIA_IN_DRIVE: | ||||
| 		uprintf("No media in drive\n"); | ||||
|  | @ -719,7 +757,6 @@ static BOOL CheckDisk(char DriveLetter) | |||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| // TODO: set locale to en-US
 | ||||
| 	pfChkdsk(wDriveRoot, wFSType, FALSE, FALSE, FALSE, FALSE, NULL, NULL, ChkdskCallback); | ||||
| 	if (!IS_ERROR(FormatStatus)) { | ||||
| 		uprintf("NTFS Fixup completed.\n"); | ||||
|  | @ -1192,6 +1229,10 @@ DWORD WINAPI FormatThread(LPVOID param) | |||
| 	char wim_image[] = "?:\\sources\\install.wim"; | ||||
| 	char efi_dst[] = "?:\\efi\\boot\\bootx64.efi"; | ||||
| 	FILE* log_fd; | ||||
| 	PF_DECL(GetThreadUILanguage); | ||||
| 	PF_DECL(SetThreadUILanguage); | ||||
| 	PF_INIT_OR_OUT(GetThreadUILanguage, kernel32); | ||||
| 	PF_INIT_OR_OUT(SetThreadUILanguage, kernel32); | ||||
| 
 | ||||
| 	fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); | ||||
| 	dt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType)); | ||||
|  | @ -1199,6 +1240,11 @@ DWORD WINAPI FormatThread(LPVOID param) | |||
| 	bt = GETBIOSTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme))); | ||||
| 	use_large_fat32 = (fs == FS_FAT32) && ((SelectedDrive.DiskSize > LARGE_FAT32_SIZE) || (force_large_fat32)); | ||||
| 
 | ||||
| 	// Try to ensure that all messages from Format and Checkdisk, which we report in the log, will be in English
 | ||||
| 	pfSetThreadUILanguage(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); | ||||
| 	if (PRIMARYLANGID(pfGetThreadUILanguage()) != LANG_ENGLISH) | ||||
| 		uprintf("Note: the formatting thread could not be set to English"); | ||||
| 
 | ||||
| 	PrintStatus(0, TRUE, MSG_225); | ||||
| 	hPhysicalDrive = GetPhysicalHandle(DriveIndex, TRUE, TRUE); | ||||
| 	if (hPhysicalDrive == INVALID_HANDLE_VALUE) { | ||||
|  |  | |||
|  | @ -154,3 +154,7 @@ typedef struct { | |||
| #define die(msg, err) do { uprintf(msg); \ | ||||
| 	FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|err; \ | ||||
| 	goto out; } while(0) | ||||
| 
 | ||||
| /* Locale */ | ||||
| typedef LANGID (WINAPI *SetThreadUILanguage_t)(LANGID LangId); | ||||
| typedef LANGID (WINAPI *GetThreadUILanguage_t)(void); | ||||
|  |  | |||
|  | @ -1372,7 +1372,7 @@ void InitDialog(HWND hDlg) | |||
| 		rufus_version[i] = (uint16_t)atoi(token); | ||||
| 	uprintf(APPLICATION_NAME " version %d.%d.%d.%d\n", rufus_version[0], rufus_version[1], rufus_version[2], rufus_version[3]); | ||||
| 	uprintf("Windows version: %s\n", WindowsVersionStr); | ||||
| 	uprintf("LCID: 0x%04X\n", GetUserDefaultLCID()); | ||||
| 	uprintf("LCID: 0x%04X\n", GetUserDefaultUILanguage()); | ||||
| 
 | ||||
| 	SetClusterSizeLabels(); | ||||
| 
 | ||||
|  | @ -1998,7 +1998,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine | |||
| #endif | ||||
| { | ||||
| 	const char* old_wait_option = "/W"; | ||||
| 	int i, opt, option_index = 0, argc = 0, si = 0, lcid = GetUserDefaultLCID(); | ||||
| 	int i, opt, option_index = 0, argc = 0, si = 0, lcid = GetUserDefaultUILanguage(); | ||||
| 	BOOL attached_console = FALSE, external_loc_file = FALSE; | ||||
| 	BYTE* loc_data; | ||||
| 	DWORD loc_size, Size; | ||||
|  |  | |||
							
								
								
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							|  | @ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL | |||
| IDD_DIALOG DIALOGEX 12, 12, 206, 329 | ||||
| STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU | ||||
| EXSTYLE WS_EX_APPWINDOW | ||||
| CAPTION "Rufus v1.4.2.358" | ||||
| CAPTION "Rufus v1.4.2.359" | ||||
| FONT 8, "MS Shell Dlg", 400, 0, 0x1 | ||||
| BEGIN | ||||
|     DEFPUSHBUTTON   "Start",IDC_START,94,291,50,14 | ||||
|  | @ -288,8 +288,8 @@ END | |||
| // | ||||
| 
 | ||||
| VS_VERSION_INFO VERSIONINFO | ||||
|  FILEVERSION 1,4,2,358 | ||||
|  PRODUCTVERSION 1,4,2,358 | ||||
|  FILEVERSION 1,4,2,359 | ||||
|  PRODUCTVERSION 1,4,2,359 | ||||
|  FILEFLAGSMASK 0x3fL | ||||
| #ifdef _DEBUG | ||||
|  FILEFLAGS 0x1L | ||||
|  | @ -306,13 +306,13 @@ BEGIN | |||
|         BEGIN | ||||
|             VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" | ||||
|             VALUE "FileDescription", "Rufus" | ||||
|             VALUE "FileVersion", "1.4.2.358" | ||||
|             VALUE "FileVersion", "1.4.2.359" | ||||
|             VALUE "InternalName", "Rufus" | ||||
|             VALUE "LegalCopyright", "© 2011-2013 Pete Batard (GPL v3)" | ||||
|             VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" | ||||
|             VALUE "OriginalFilename", "rufus.exe" | ||||
|             VALUE "ProductName", "Rufus" | ||||
|             VALUE "ProductVersion", "1.4.2.358" | ||||
|             VALUE "ProductVersion", "1.4.2.359" | ||||
|         END | ||||
|     END | ||||
|     BLOCK "VarFileInfo" | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue