mirror of
https://github.com/pbatard/rufus.git
synced 2025-05-19 17:35:10 -04:00
[loc] add localization support
* This is a merge up to commit bd319269aa
of the localization branch
* Also fixes Clang warnings
This commit is contained in:
parent
cf3964c8a3
commit
df06727416
26 changed files with 3024 additions and 491 deletions
95
src/stdio.c
95
src/stdio.c
|
@ -31,6 +31,7 @@
|
|||
#include "msapi_utf8.h"
|
||||
#include "rufus.h"
|
||||
#include "resource.h"
|
||||
#include "localization.h"
|
||||
|
||||
/*
|
||||
* Globals
|
||||
|
@ -40,7 +41,8 @@ HWND hStatus;
|
|||
#ifdef RUFUS_DEBUG
|
||||
void _uprintf(const char *format, ...)
|
||||
{
|
||||
char buf[4096], *p = buf;
|
||||
static char buf[4096];
|
||||
char* p = buf;
|
||||
va_list args;
|
||||
int n;
|
||||
|
||||
|
@ -50,7 +52,7 @@ void _uprintf(const char *format, ...)
|
|||
|
||||
p += (n < 0)?sizeof(buf)-3:n;
|
||||
|
||||
while((p>buf) && (isspace((unsigned char)p[-1])))
|
||||
while((p>buf) && (isspaceU(p[-1])))
|
||||
*--p = '\0';
|
||||
|
||||
*p++ = '\r';
|
||||
|
@ -145,23 +147,11 @@ static void CALLBACK PrintStatusTimeout(HWND hwnd, UINT uMsg, UINT_PTR idEvent,
|
|||
KillTimer(hMainDialog, TID_MESSAGE);
|
||||
}
|
||||
|
||||
void PrintStatus(unsigned int duration, BOOL debug, const char *format, ...)
|
||||
void PrintStatus(unsigned int duration, BOOL debug, const char* message)
|
||||
{
|
||||
char *p = szStatusMessage;
|
||||
va_list args;
|
||||
int n;
|
||||
|
||||
va_start(args, format);
|
||||
n = safe_vsnprintf(p, sizeof(szStatusMessage)-1, format, args); // room for NUL
|
||||
va_end(args);
|
||||
|
||||
p += (n < 0)?sizeof(szStatusMessage)-1:n;
|
||||
|
||||
while((p>szStatusMessage) && (isspace(p[-1])))
|
||||
*--p = '\0';
|
||||
|
||||
*p = '\0';
|
||||
|
||||
if (message == NULL)
|
||||
return;
|
||||
safe_strcpy(szStatusMessage, sizeof(szStatusMessage), message);
|
||||
if (debug)
|
||||
uprintf("%s\n", szStatusMessage);
|
||||
|
||||
|
@ -192,17 +182,16 @@ char* GuidToString(const GUID* guid)
|
|||
char* SizeToHumanReadable(LARGE_INTEGER size)
|
||||
{
|
||||
int suffix = 0;
|
||||
static char str_size[24];
|
||||
const char* sizes[] = { "", "KB", "MB", "GB", "TB" };
|
||||
static char str_size[32];
|
||||
double hr_size = (double)size.QuadPart;
|
||||
while ((suffix < ARRAYSIZE(sizes)) && (hr_size >= 1024.0)) {
|
||||
while ((suffix < MAX_SIZE_SUFFIXES) && (hr_size >= 1024.0)) {
|
||||
hr_size /= 1024.0;
|
||||
suffix++;
|
||||
}
|
||||
if (suffix == 0) {
|
||||
safe_sprintf(str_size, sizeof(str_size), "%d bytes", (int)hr_size);
|
||||
safe_sprintf(str_size, sizeof(str_size), "%d %s", (int)hr_size, lmprintf(MSG_020));
|
||||
} else {
|
||||
safe_sprintf(str_size, sizeof(str_size), "%0.1f %s", hr_size, sizes[suffix]);
|
||||
safe_sprintf(str_size, sizeof(str_size), "%0.1f %s", hr_size, lmprintf(MSG_020 + suffix));
|
||||
}
|
||||
return str_size;
|
||||
}
|
||||
|
@ -210,7 +199,7 @@ char* SizeToHumanReadable(LARGE_INTEGER size)
|
|||
const char* StrError(DWORD error_code)
|
||||
{
|
||||
if ( (!IS_ERROR(error_code)) || (SCODE_CODE(error_code) == ERROR_SUCCESS)) {
|
||||
return "Success";
|
||||
return lmprintf(MSG_044);
|
||||
}
|
||||
if (SCODE_FACILITY(error_code) != FACILITY_STORAGE) {
|
||||
uprintf("StrError: non storage - %08X (%X)\n", error_code, SCODE_FACILITY(error_code));
|
||||
|
@ -219,63 +208,61 @@ const char* StrError(DWORD error_code)
|
|||
}
|
||||
switch (SCODE_CODE(error_code)) {
|
||||
case ERROR_GEN_FAILURE:
|
||||
return "Undetermined error while formatting.";
|
||||
return lmprintf(MSG_051);
|
||||
case ERROR_INCOMPATIBLE_FS:
|
||||
return "Cannot use the selected file system for this media.";
|
||||
return lmprintf(MSG_052);
|
||||
case ERROR_ACCESS_DENIED:
|
||||
return "Access to the device is denied.";
|
||||
return lmprintf(MSG_053);
|
||||
case ERROR_WRITE_PROTECT:
|
||||
return "Media is write protected.";
|
||||
return lmprintf(MSG_054);
|
||||
case ERROR_DEVICE_IN_USE:
|
||||
return "The device is in use by another process. "
|
||||
"Please close any other process that may be accessing the device.";
|
||||
return lmprintf(MSG_055);
|
||||
case ERROR_CANT_QUICK_FORMAT:
|
||||
return "Quick format is not available for this device.";
|
||||
return lmprintf(MSG_056);
|
||||
case ERROR_LABEL_TOO_LONG:
|
||||
return "The volume label is invalid.";
|
||||
return lmprintf(MSG_057);
|
||||
case ERROR_INVALID_HANDLE:
|
||||
return "The device handle is invalid.";
|
||||
return lmprintf(MSG_058);
|
||||
case ERROR_INVALID_CLUSTER_SIZE:
|
||||
return "The selected cluster size is not valid for this device.";
|
||||
return lmprintf(MSG_059);
|
||||
case ERROR_INVALID_VOLUME_SIZE:
|
||||
return "The volume size is invalid.";
|
||||
return lmprintf(MSG_060);
|
||||
case ERROR_NO_MEDIA_IN_DRIVE:
|
||||
return "Please insert a media in drive.";
|
||||
return lmprintf(MSG_061);
|
||||
case ERROR_NOT_SUPPORTED:
|
||||
return "An unsupported command was received.";
|
||||
return lmprintf(MSG_062);
|
||||
case ERROR_NOT_ENOUGH_MEMORY:
|
||||
return "Memory allocation error.";
|
||||
return lmprintf(MSG_063);
|
||||
case ERROR_READ_FAULT:
|
||||
return "Read error.";
|
||||
return lmprintf(MSG_064);
|
||||
case ERROR_WRITE_FAULT:
|
||||
return "Write error.";
|
||||
return lmprintf(MSG_065);
|
||||
case ERROR_INSTALL_FAILURE:
|
||||
return "Installation failure";
|
||||
return lmprintf(MSG_066);
|
||||
case ERROR_OPEN_FAILED:
|
||||
return "Could not open media. It may be in use by another process. "
|
||||
"Please re-plug the media and try again.";
|
||||
return lmprintf(MSG_067);
|
||||
case ERROR_PARTITION_FAILURE:
|
||||
return "Error while partitioning drive.";
|
||||
return lmprintf(MSG_068);
|
||||
case ERROR_CANNOT_COPY:
|
||||
return "Could not copy files to target drive.";
|
||||
return lmprintf(MSG_069);
|
||||
case ERROR_CANCELLED:
|
||||
return "Cancelled by user.";
|
||||
return lmprintf(MSG_070);
|
||||
case ERROR_CANT_START_THREAD:
|
||||
return "Unable to create formatting thread.";
|
||||
return lmprintf(MSG_071);
|
||||
case ERROR_BADBLOCKS_FAILURE:
|
||||
return "Bad blocks check didn't complete.";
|
||||
return lmprintf(MSG_072);
|
||||
case ERROR_ISO_SCAN:
|
||||
return "ISO image scan failure.";
|
||||
return lmprintf(MSG_073);
|
||||
case ERROR_ISO_EXTRACT:
|
||||
return "ISO image extraction failure.";
|
||||
return lmprintf(MSG_074);
|
||||
case ERROR_CANT_REMOUNT_VOLUME:
|
||||
return "Unable to remount volume.";
|
||||
return lmprintf(MSG_075);
|
||||
case ERROR_CANT_PATCH:
|
||||
return "Unable to patch/setup files for boot.";
|
||||
return lmprintf(MSG_076);
|
||||
case ERROR_CANT_ASSIGN_LETTER:
|
||||
return "Unable to assign a drive letter.";
|
||||
return lmprintf(MSG_077);
|
||||
case ERROR_CANT_MOUNT_VOLUME:
|
||||
return "Can't mount GUID volume.";
|
||||
return lmprintf(MSG_078);
|
||||
default:
|
||||
uprintf("Unknown error: %08X\n", error_code);
|
||||
SetLastError(error_code);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue