https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8e48f8f2dd521a9e23ec6d9ed1c3d3abd8f19232

commit 8e48f8f2dd521a9e23ec6d9ed1c3d3abd8f19232
Author:     Bișoc George <[email protected]>
AuthorDate: Sat Oct 20 21:21:51 2018 +0200
Commit:     Hermès BÉLUSCA - MAÏTO <[email protected]>
CommitDate: Sat Oct 20 21:21:51 2018 +0200

    [CHKDSK] Implement localization support (#891)
    
    - Make the strings translatable.
    - Include the English translation within the main resource file.
    - Use ConResPrintf() and ConResPuts() for resource strings.
---
 base/system/chkdsk/chkdsk.c      | 40 ++++++++++++++++------------------------
 base/system/chkdsk/chkdsk.rc     |  9 +++++++++
 base/system/chkdsk/lang/en-US.rc | 31 +++++++++++++++++++++++++++++++
 base/system/chkdsk/resource.h    | 18 ++++++++++++++++++
 4 files changed, 74 insertions(+), 24 deletions(-)

diff --git a/base/system/chkdsk/chkdsk.c b/base/system/chkdsk/chkdsk.c
index 76dc975098..6fc25f7268 100644
--- a/base/system/chkdsk/chkdsk.c
+++ b/base/system/chkdsk/chkdsk.c
@@ -49,6 +49,9 @@
 
 #include <conutils.h>
 
+/* Resource header */
+#include "resource.h"
+
 #define NTOS_MODE_USER
 #include <ndk/ntndk.h>
 
@@ -85,9 +88,9 @@ PCHKDSK Chkdsk;
 // Takes the win32 error code and prints the text version.
 //
 //----------------------------------------------------------------------
-static VOID PrintWin32Error(LPWSTR Message, DWORD ErrorCode)
+static VOID PrintWin32Error(int Message, DWORD ErrorCode)
 {
-    ConPrintf(StdErr, L"%s: ", Message);
+    ConResPuts(StdErr, Message);
     ConMsgPuts(StdErr, FORMAT_MESSAGE_FROM_SYSTEM,
                NULL, ErrorCode, LANG_USER_DEFAULT);
     ConPuts(StdErr, L"\n");
@@ -123,14 +126,7 @@ CtrlCIntercept(DWORD dwCtrlType)
 static VOID
 Usage(PWCHAR ProgramName)
 {
-    ConPrintf(StdOut,
-        L"Usage: %s [drive:] [-F] [-V] [-R] [-C]\n\n"
-        L"[drive:]    Specifies the drive to check.\n"
-        L"-F          Fixes errors on the disk.\n"
-        L"-V          Displays the full path of every file on the disk.\n"
-        L"-R          Locates bad sectors and recovers readable information.\n"
-        L"-C          Checks the drive only if it is dirty.\n\n",
-        ProgramName);
+    ConResPrintf(StdOut, IDS_USAGE, ProgramName);
 }
 
 
@@ -261,7 +257,7 @@ ChkdskCallback(
             break;
 
         case VOLUMEINUSE:
-            ConPuts(StdOut, L"Volume is in use and cannot be locked\n");
+            ConResPuts(StdOut, IDS_VOLUME_IN_USE);
             Ret = FALSE;
             break;
 
@@ -299,7 +295,7 @@ ChkdskCallback(
 
         case PROGRESS:
             percent = (PDWORD)Argument;
-            ConPrintf(StdOut, L"%d percent completed.\r", *percent);
+            ConResPrintf(StdOut, IDS_PERCENT_COMPL, *percent);
             break;
 
         case OUTPUT:
@@ -311,7 +307,7 @@ ChkdskCallback(
             status = (PBOOLEAN)Argument;
             if (*status == FALSE)
             {
-                ConPuts(StdOut, L"Chkdsk was unable to complete 
successfully.\n\n");
+                ConResPuts(StdOut, IDS_CHKDSK_FAIL);
                 Error = TRUE;
             }
             break;
@@ -371,11 +367,7 @@ wmain(int argc, WCHAR *argv[])
     /* Initialize the Console Standard Streams */
     ConInitStdStreams();
 
-    ConPuts(StdOut,
-        L"\n"
-        L"Chkdskx v1.0.1 by Mark Russinovich\n"
-        L"Systems Internals - http://www.sysinternals.com\n";
-        L"ReactOS adaptation 1999 by Emanuele Aliberti\n\n");
+    ConResPuts(StdOut, IDS_ABOUT);
 
 #ifndef FMIFS_IMPORT_DLL
     //
@@ -383,7 +375,7 @@ wmain(int argc, WCHAR *argv[])
     //
     if (!LoadFMIFSEntryPoints())
     {
-        ConPuts(StdErr, L"Could not located FMIFS entry points.\n\n");
+        ConResPuts(StdErr, IDS_NO_ENTRY_POINT);
         return -1;
     }
 #endif
@@ -394,7 +386,7 @@ wmain(int argc, WCHAR *argv[])
     badArg = ParseCommandLine(argc, argv);
     if (badArg)
     {
-        ConPrintf(StdOut, L"Unknown argument: %s\n", argv[badArg]);
+        ConResPrintf(StdOut, IDS_BAD_ARGUMENT, argv[badArg]);
         Usage(argv[0]);
         return -1;
     }
@@ -406,7 +398,7 @@ wmain(int argc, WCHAR *argv[])
     {
         if (!GetCurrentDirectoryW(ARRAYSIZE(CurrentDirectory), 
CurrentDirectory))
         {
-            PrintWin32Error(L"Could not get current directory", 
GetLastError());
+            PrintWin32Error(IDS_NO_CURRENT_DIR, GetLastError());
             return -1;
         }
     }
@@ -431,7 +423,7 @@ wmain(int argc, WCHAR *argv[])
                                fileSystem,
                                ARRAYSIZE(fileSystem)))
     {
-        PrintWin32Error(L"Could not query volume", GetLastError());
+        PrintWin32Error(IDS_NO_QUERY_VOL, GetLastError());
         return -1;
     }
 
@@ -450,7 +442,7 @@ wmain(int argc, WCHAR *argv[])
                                    0);
         if (volumeHandle == INVALID_HANDLE_VALUE)
         {
-            ConPuts(StdErr, L"Chkdsk cannot run because the volume is in use 
by another process.\n\n");
+            ConResPuts(StdErr, IDS_VOLUME_IN_USE_PROC);
             return -1;
         }
         CloseHandle(volumeHandle);
@@ -464,7 +456,7 @@ wmain(int argc, WCHAR *argv[])
     //
     // Just do it
     //
-    ConPrintf(StdOut, L"The type of file system is %s.\n", fileSystem);
+    ConResPrintf(StdOut, IDS_FILE_SYSTEM, fileSystem);
     Chkdsk(Drive,
            fileSystem,
            FixErrors,
diff --git a/base/system/chkdsk/chkdsk.rc b/base/system/chkdsk/chkdsk.rc
index 17962ee7d2..412971c5e1 100644
--- a/base/system/chkdsk/chkdsk.rc
+++ b/base/system/chkdsk/chkdsk.rc
@@ -1,6 +1,15 @@
+#include <windef.h>
+#include "resource.h"
 
 #define REACTOS_STR_FILE_DESCRIPTION    "ReactOS Disk Checking Utility"
 #define REACTOS_STR_INTERNAL_NAME       "chkdsk"
 #define REACTOS_STR_ORIGINAL_FILENAME   "chkdsk.exe"
 #define REACTOS_STR_ORIGINAL_COPYRIGHT  "1998 Mark Russinovich"
 #include <reactos/version.rc>
+
+/* UTF-8 */
+#pragma code_page(65001)
+
+#ifdef LANGUAGE_EN_US
+    #include "lang/en-US.rc"
+#endif
diff --git a/base/system/chkdsk/lang/en-US.rc b/base/system/chkdsk/lang/en-US.rc
new file mode 100644
index 0000000000..c36ed8db41
--- /dev/null
+++ b/base/system/chkdsk/lang/en-US.rc
@@ -0,0 +1,31 @@
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+
+STRINGTABLE
+BEGIN
+    IDS_USAGE "\n\
+Usage: %s [drive:] [-F] [-V] [-R] [-C] \n\n\
+[drive:]    Specifies the drive to check.\n\
+-F          Fixes errors on the disk.\n\
+-V          Displays the full path of every file on the disk.\n\
+-R          Locates bad sectors and recovers readable information.\n\
+-C          Checks the drive only if it is dirty.\n\
+\n"
+
+    IDS_PERCENT_COMPL "%d percent completed.\r"
+    IDS_FILE_SYSTEM "The type of file system is %s.\n"
+    IDS_ABOUT "\n\
+Chkdskx v1.0.1 by Mark Russinovich\n\
+Systems Internals - http://www.sysinternals.com\n\
+ReactOS adaptation 1999 by Emanuele Aliberti\n\n"
+END
+
+STRINGTABLE
+BEGIN
+    IDS_VOLUME_IN_USE "Volume is in use and cannot be locked\n"
+    IDS_CHKDSK_FAIL "Chkdsk was unable to complete successfully.\n\n"
+    IDS_NO_ENTRY_POINT "Could not located FMIFS entry points.\n\n"
+    IDS_BAD_ARGUMENT "Unknown argument: %s\n"
+    IDS_NO_CURRENT_DIR "Could not get current directory. Error code: "
+    IDS_NO_QUERY_VOL "Could not query volume. Error code: "
+    IDS_VOLUME_IN_USE_PROC "Chkdsk cannot run because the volume is in use by 
another process.\n\n"
+END
diff --git a/base/system/chkdsk/resource.h b/base/system/chkdsk/resource.h
new file mode 100644
index 0000000000..a5597ddbeb
--- /dev/null
+++ b/base/system/chkdsk/resource.h
@@ -0,0 +1,18 @@
+/* General IDs */
+
+#define IDS_USAGE               101
+#define IDS_PERCENT_COMPL       102
+#define IDS_ABOUT               103
+#define IDS_FILE_SYSTEM         104
+
+/* Failure IDs */
+
+#define IDS_VOLUME_IN_USE       200
+#define IDS_CHKDSK_FAIL         201
+#define IDS_NO_ENTRY_POINT      202
+#define IDS_BAD_ARGUMENT        203
+#define IDS_NO_CURRENT_DIR      204
+#define IDS_NO_QUERY_VOL        205
+#define IDS_VOLUME_IN_USE_PROC  206
+
+/* EOF */

Reply via email to