- allow translation of strings in usetup
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Fri, 8 Feb 2008 04:14:09 +0000 (04:14 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Fri, 8 Feb 2008 04:14:09 +0000 (04:14 +0000)
- so far most strings are still hardcoded, but the needed functionality is in place

svn path=/trunk/; revision=32204

reactos/base/setup/usetup/interface/usetup.c
reactos/base/setup/usetup/lang/de-DE.h
reactos/base/setup/usetup/lang/en-US.h
reactos/base/setup/usetup/mui.c
reactos/base/setup/usetup/mui.h

index 47f1339..1c95254 100644 (file)
@@ -1370,11 +1370,11 @@ SelectPartitionPage(PINPUT_RECORD Ir)
         if (PartitionList->CurrentPartition == NULL ||
             PartitionList->CurrentPartition->Unpartitioned == TRUE)
         {
-            CONSOLE_SetStatusText ("   ENTER = Install   C = Create Partition   F3 = Quit");
+            CONSOLE_SetStatusText (MUIGetString(STRING_INSTALLCREATEPARTITION));
         }
         else
         {
-            CONSOLE_SetStatusText ("   ENTER = Install   D = Delete Partition   F3 = Quit");
+            CONSOLE_SetStatusText (MUIGetString(STRING_INSTALLDELETEPARTITION));
         }
 
         CONSOLE_ConInKey(Ir);
@@ -1495,7 +1495,7 @@ ShowPartitionSizeInputBox(SHORT Left,
     /* Print message */
     coPos.X = Left + 2;
     coPos.Y = Top + 2;
-    strcpy (Buffer, "Size of new partition:");
+    strcpy (Buffer, MUIGetString(STRING_PARTITIONSIZE));
     iLeft = coPos.X + strlen (Buffer) + 1;
     iTop = coPos.Y;
 
@@ -1604,9 +1604,9 @@ CreatePartitionPage (PINPUT_RECORD Ir)
     DiskEntry = PartitionList->CurrentDisk;
     PartEntry = PartitionList->CurrentPartition;
 
-    CONSOLE_SetStatusText ("   Please wait...");
+    CONSOLE_SetStatusText (MUIGetString(STRING_PLEASEWAIT));
 
-    CONSOLE_SetTextXY (6, 8, "You have chosen to create a new partition on");
+    CONSOLE_SetTextXY (6, 8, MUIGetString(STRING_CHOOSENEWPARTITION));
 
 #if 0
     if (DiskEntry->DiskSize >= 0x280000000ULL) /* 10 GB */
@@ -1656,7 +1656,7 @@ CreatePartitionPage (PINPUT_RECORD Ir)
                          PartitionList->CurrentPartition->UnpartitionedLength / (1024*1024));
 #endif
 
-    CONSOLE_SetStatusText ("   ENTER = Create Partition   ESC = Cancel   F3 = Quit");
+    CONSOLE_SetStatusText (MUIGetString(STRING_CREATEPARTITION));
 
     PartEntry = PartitionList->CurrentPartition;
     while (TRUE)
@@ -2785,7 +2785,7 @@ PrepareCopyPageInfFile(HINF InfFile,
         {
             MUIDisplayError(ERROR_TXTSETUP_SECTION, Ir, POPUP_WAIT_ENTER);
         }
-        
+
         return FALSE;
     }
 
@@ -2979,7 +2979,7 @@ FileCopyCallback(PVOID Context,
 
         case SPFILENOTIFY_STARTCOPY:
             /* Display copy message */
-            CONSOLE_SetStatusText("                                                   \xB3 Copying file: %S", (PWSTR)Param1);
+            CONSOLE_SetStatusText(MUIGetString(STRING_COPYING), (PWSTR)Param1);
             SetupUpdateMemoryInfo(CopyContext, FALSE);
             break;
 
@@ -3015,7 +3015,7 @@ FileCopyPage(PINPUT_RECORD Ir)
                                                 10,
                                                 24,
                                                 TRUE,
-                                                "Setup is copying files...");
+                                                MUIGetString(STRING_SETUPCOPYINGFILES));
 
     /* Create the paged pool progress bar */
     CopyContext.MemoryBars[0] = CreateProgressBar(13,
@@ -3025,7 +3025,7 @@ FileCopyPage(PINPUT_RECORD Ir)
                                                   10,
                                                   44,
                                                   FALSE,
-                                                  "Paged Memory");
+                                                  MUIGetString(STRING_PAGEDMEM));
 
     /* Create the non paged pool progress bar */
     CopyContext.MemoryBars[1] = CreateProgressBar(28,
@@ -3035,7 +3035,7 @@ FileCopyPage(PINPUT_RECORD Ir)
                                                   24,
                                                   44,
                                                   FALSE,
-                                                  "Nonpaged Memory");
+                                                  MUIGetString(STRING_NONPAGEDMEM));
 
     /* Create the global memory progress bar */
     CopyContext.MemoryBars[2] = CreateProgressBar(43,
@@ -3045,7 +3045,7 @@ FileCopyPage(PINPUT_RECORD Ir)
                                                   40,
                                                   44,
                                                   FALSE,
-                                                  "Free Memory");
+                                                  MUIGetString(STRING_FREEMEM));
 
     /* Do the file copying */
     SetupCommitFileQueueW(NULL,
index 89de3c2..7f06372 100644 (file)
@@ -1574,4 +1574,31 @@ MUI_PAGE deDEPages[] =
     }
 };
 
+MUI_STRING deDEStrings[] =
+{
+    {STRING_INSTALLCREATEPARTITION,
+     "   ENTER = Installieren   C = Partition erstellen  F3 = Beenden"},
+    {STRING_INSTALLDELETEPARTITION,
+     "   ENTER = Installieren   D = Partition löschen    F3 = Beenden"},
+    {STRING_PARTITIONSIZE,
+     "Größe der neuen Partition:"},
+    {STRING_PLEASEWAIT,
+     "   Bitte warten..."},
+    {STRING_CHOOSENEWPARTITION,
+     "Sie haben beschlossen eine neue Partition zu erstellen auf"},
+    {STRING_CREATEPARTITION,
+     "   ENTER = Partition erstelln   ESC = Abbruch   F3 = Beenden"},
+    {STRING_COPYING,
+     "                                                   \xB3 Kopiere Datei: %S"},
+    {STRING_SETUPCOPYINGFILES,
+     "Setup kopiert Dateien..."},
+    {STRING_PAGEDMEM,
+     "Paged Memory"},
+    {STRING_NONPAGEDMEM,
+     "Nonpaged Memory"},
+    {STRING_FREEMEM,
+     "Free Memory"},
+    {0, 0}
+};
+
 #endif
index 24f8d81..e7a6b64 100644 (file)
@@ -1568,4 +1568,31 @@ MUI_PAGE enUSPages[] =
     }
 };
 
+MUI_STRING enUSStrings[] =
+{
+    {STRING_INSTALLCREATEPARTITION,
+     "   ENTER = Install   C = Create Partition   F3 = Quit"},
+    {STRING_INSTALLDELETEPARTITION,
+     "   ENTER = Install   D = Delete Partition   F3 = Quit"},
+    {STRING_PARTITIONSIZE,
+     "Size of new partition:"},
+    {STRING_PLEASEWAIT,
+     "   Please wait..."},
+    {STRING_CHOOSENEWPARTITION,
+     "You have chosen to create a new partition on"},
+    {STRING_CREATEPARTITION,
+     "   ENTER = Create Partition   ESC = Cancel   F3 = Quit"},
+    {STRING_COPYING,
+     "                                                   \xB3 Copying file: %S"},
+    {STRING_SETUPCOPYINGFILES,
+     "Setup is copying files..."},
+    {STRING_PAGEDMEM,
+     "Paged Memory"},
+    {STRING_NONPAGEDMEM,
+     "Nonpaged Memory"},
+    {STRING_FREEMEM,
+     "Free Memory"},
+    {0, 0}
+};
+
 #endif
index dfc057a..a80a181 100644 (file)
@@ -21,7 +21,7 @@
  * PROJECT:         ReactOS text-mode setup
  * FILE:            subsys/system/usetup/mui.c
  * PURPOSE:         Text-mode setup
- * PROGRAMMER:      
+ * PROGRAMMER:
  */
 
 #include "usetup.h"
 static const MUI_LANGUAGE LanguageList[] =
 {
   /* Lang ID,   DefKbdLayout,ANSI CP, OEM CP, MAC CP,   Language Name,    page strgs,error strings */
-  {L"00000409", L"00000409", L"1252", L"437", L"10000", L"English",       enUSPages, enUSErrorEntries },
-  {L"00000402", L"00000402", L"1251", L"866", L"10007", L"Bulgarian",     bgBGPages, bgBGErrorEntries },
-  {L"00000403", L"00000403", L"1252", L"850", L"10000", L"Catalan",       enUSPages, enUSErrorEntries },
-  {L"00000804", L"00000804", L"936",  L"936", L"10008", L"Chinese (PRC)", enUSPages, enUSErrorEntries },
-  {L"00000406", L"00000406", L"1252", L"850", L"10000", L"Danish",        enUSPages, enUSErrorEntries },
-  {L"00000413", L"00000813", L"1252", L"850", L"10000", L"Dutch",         enUSPages, enUSErrorEntries },
-  {L"0000040B", L"0000040B", L"1252", L"850", L"10000", L"Finnish",       enUSPages, enUSErrorEntries },
-  {L"0000040C", L"0000040C", L"1252", L"850", L"10000", L"French",        frFRPages, frFRErrorEntries },
-  {L"00000407", L"00000407", L"1252", L"850", L"10000", L"German",        deDEPages, deDEErrorEntries },
-  {L"00000408", L"00000408", L"1253", L"737", L"10006", L"Greek",         elGRPages, elGRErrorEntries },
-  {L"0000040D", L"0000040D", L"1255", L"862", L"10005", L"Hebrew",        enUSPages, enUSErrorEntries },
-  {L"0000040E", L"0000040E", L"1250", L"852", L"10029", L"Hungarian",     enUSPages, enUSErrorEntries },
-  {L"00000410", L"00000410", L"1252", L"850", L"10000", L"Italian",       itITPages, itITErrorEntries },
-  {L"00000411", L"00000411", L"932",  L"932", L"10001", L"Japanese",      enUSPages, enUSErrorEntries },
-  {L"00000412", L"00000412", L"949",  L"949", L"10003", L"Korean",        enUSPages, enUSErrorEntries },
-  {L"00000427", L"00000427", L"1257", L"775", L"10029", L"Lithuanian",    ltLTPages, ltLTErrorEntries },
-  {L"00000414", L"00000414", L"1252", L"850", L"10000", L"Norwegian",     enUSPages, enUSErrorEntries },
-  {L"00000419", L"00000419", L"1251", L"866", L"10007", L"Russian",       ruRUPages, ruRUErrorEntries },
-  {L"0000041B", L"0000041B", L"1250", L"852", L"10029", L"Slovak",        skSKPages, skSKErrorEntries },
-  {L"0000040A", L"0000040A", L"1252", L"850", L"10000", L"Spanish",       esESPages, esESErrorEntries },
-  {L"00000415", L"00000415", L"1250", L"852", L"10029", L"Polish",        plPLPages, plPLErrorEntries },
-  {L"00000816", L"00000816", L"1252", L"850", L"10000", L"Portuguese",    enUSPages, enUSErrorEntries },
-  {L"0000041D", L"0000041D", L"1252", L"850", L"10000", L"Swedish",       svSEPages, svSEErrorEntries },
-  {L"0000041E", L"0000041E", L"874",  L"874", L"10021", L"Thai",          enUSPages, enUSErrorEntries },
-  {L"0000041F", L"0000041F", L"1254", L"857", L"10081", L"Turkish",       enUSPages, enUSErrorEntries },
-  {L"00000422", L"00000422", L"1251", L"866", L"10017", L"Ukrainian",     ukUAPages, ukUAErrorEntries },
+  {L"00000409", L"00000409", L"1252", L"437", L"10000", L"English",       enUSPages, enUSErrorEntries, enUSStrings },
+  {L"00000402", L"00000402", L"1251", L"866", L"10007", L"Bulgarian",     bgBGPages, bgBGErrorEntries, enUSStrings },
+  {L"00000403", L"00000403", L"1252", L"850", L"10000", L"Catalan",       enUSPages, enUSErrorEntries, enUSStrings },
+  {L"00000804", L"00000804", L"936",  L"936", L"10008", L"Chinese (PRC)", enUSPages, enUSErrorEntries, enUSStrings },
+  {L"00000406", L"00000406", L"1252", L"850", L"10000", L"Danish",        enUSPages, enUSErrorEntries, enUSStrings },
+  {L"00000413", L"00000813", L"1252", L"850", L"10000", L"Dutch",         enUSPages, enUSErrorEntries, enUSStrings },
+  {L"0000040B", L"0000040B", L"1252", L"850", L"10000", L"Finnish",       enUSPages, enUSErrorEntries, enUSStrings },
+  {L"0000040C", L"0000040C", L"1252", L"850", L"10000", L"French",        frFRPages, frFRErrorEntries, enUSStrings },
+  {L"00000407", L"00000407", L"1252", L"850", L"10000", L"German",        deDEPages, deDEErrorEntries, deDEStrings },
+  {L"00000408", L"00000408", L"1253", L"737", L"10006", L"Greek",         elGRPages, elGRErrorEntries, enUSStrings },
+  {L"0000040D", L"0000040D", L"1255", L"862", L"10005", L"Hebrew",        enUSPages, enUSErrorEntries, enUSStrings },
+  {L"0000040E", L"0000040E", L"1250", L"852", L"10029", L"Hungarian",     enUSPages, enUSErrorEntries, enUSStrings },
+  {L"00000410", L"00000410", L"1252", L"850", L"10000", L"Italian",       itITPages, itITErrorEntries, enUSStrings },
+  {L"00000411", L"00000411", L"932",  L"932", L"10001", L"Japanese",      enUSPages, enUSErrorEntries, enUSStrings },
+  {L"00000412", L"00000412", L"949",  L"949", L"10003", L"Korean",        enUSPages, enUSErrorEntries, enUSStrings },
+  {L"00000427", L"00000427", L"1257", L"775", L"10029", L"Lithuanian",    ltLTPages, ltLTErrorEntries, enUSStrings },
+  {L"00000414", L"00000414", L"1252", L"850", L"10000", L"Norwegian",     enUSPages, enUSErrorEntries, enUSStrings },
+  {L"00000419", L"00000419", L"1251", L"866", L"10007", L"Russian",       ruRUPages, ruRUErrorEntries, enUSStrings },
+  {L"0000041B", L"0000041B", L"1250", L"852", L"10029", L"Slovak",        skSKPages, skSKErrorEntries, enUSStrings },
+  {L"0000040A", L"0000040A", L"1252", L"850", L"10000", L"Spanish",       esESPages, esESErrorEntries, enUSStrings },
+  {L"00000415", L"00000415", L"1250", L"852", L"10029", L"Polish",        plPLPages, plPLErrorEntries, enUSStrings },
+  {L"00000816", L"00000816", L"1252", L"850", L"10000", L"Portuguese",    enUSPages, enUSErrorEntries, enUSStrings },
+  {L"0000041D", L"0000041D", L"1252", L"850", L"10000", L"Swedish",       svSEPages, svSEErrorEntries, enUSStrings },
+  {L"0000041E", L"0000041E", L"874",  L"874", L"10021", L"Thai",          enUSPages, enUSErrorEntries, enUSStrings },
+  {L"0000041F", L"0000041F", L"1254", L"857", L"10081", L"Turkish",       enUSPages, enUSErrorEntries, enUSStrings },
+  {L"00000422", L"00000422", L"1251", L"866", L"10017", L"Ukrainian",     ukUAPages, ukUAErrorEntries, enUSStrings },
   {NULL, NULL, NULL, NULL, NULL}
 };
 
@@ -140,6 +140,28 @@ FindMUIErrorEntries(VOID)
     return NULL;
 }
 
+static
+const MUI_STRING *
+FindMUIStringEntries(VOID)
+{
+    ULONG lngIndex = 0;
+
+    do
+    {
+        /* First we search the language list till we find current selected language messages */
+        if (_wcsicmp(LanguageList[lngIndex].LanguageID , SelectedLanguageId) == 0)
+        {
+            /* Get all available strings for this language */
+            return LanguageList[lngIndex].MuiStrings;
+        }
+
+        lngIndex++;
+    }
+    while (LanguageList[lngIndex].MuiPages != NULL);
+
+    return NULL;
+}
+
 LPCWSTR
 MUIDefaultKeyboardLayout(VOID)
 {
@@ -234,6 +256,32 @@ MUIDisplayError(IN ULONG ErrorNum, OUT PINPUT_RECORD Ir, IN ULONG WaitEvent)
                WaitEvent);
 }
 
+LPSTR
+MUIGetString(ULONG Number)
+{
+    ULONG i;
+    const MUI_STRING * entry;
+
+    entry = FindMUIStringEntries();
+    if (entry)
+    {
+        for (i = 0; entry[i].Number != 0; i++)
+        {
+            if (entry[i].Number == Number)
+            {
+                return entry[i].String;
+            }
+        }
+    }
+
+    PopupError("Error: Failed to find translated string",
+                NULL,
+                NULL,
+                POPUP_WAIT_NONE);
+
+    return "<nostring>";
+}
+
 static BOOLEAN
 AddCodepageToRegistry(IN LPCWSTR ACPage, IN LPCWSTR OEMCPage, IN LPCWSTR MACCPage)
 {
index d920549..cfe87ae 100644 (file)
@@ -21,6 +21,12 @@ typedef struct
     MUI_ENTRY * MuiEntry;
 }MUI_PAGE;
 
+typedef struct
+{
+    LONG Number;
+    LPSTR String;
+} MUI_STRING;
+
 typedef struct
 {
     PWCHAR LanguageID;
@@ -31,6 +37,7 @@ typedef struct
     PWCHAR LanguageDescriptor;
     const MUI_PAGE * MuiPages;
     const MUI_ERROR * MuiErrors;
+    const MUI_STRING * MuiStrings;
 }MUI_LANGUAGE;
 
 
@@ -59,4 +66,20 @@ AddCodePage(VOID);
 VOID
 SetConsoleCodePage(VOID);
 
+LPSTR
+MUIGetString(ULONG Number);
+
+#define STRING_INSTALLCREATEPARTITION 1
+#define STRING_INSTALLDELETEPARTITION 2
+#define STRING_CREATEPARTITION 3
+#define STRING_PARTITIONSIZE 4
+#define STRING_PLEASEWAIT 5
+#define STRING_CHOOSENEWPARTITION 6
+#define STRING_COPYING 7
+#define STRING_SETUPCOPYINGFILES 8
+#define STRING_PAGEDMEM 9
+#define STRING_NONPAGEDMEM 10
+#define STRING_FREEMEM 11
+
+
 #endif