usetup Spanish localization by gabriel <gabrielilardi at hotmail dot it>
[reactos.git] / reactos / base / setup / usetup / mui.c
1 #include "usetup.h"
2 #include "mui.h"
3
4 #include "lang/en-US.h"
5 #include "lang/de-DE.h"
6 #include "lang/es-ES.h"
7
8 static MUI_LANGUAGE LanguageList[] =
9 {
10 {
11 "English (USA)",
12 enUSPages
13 },
14 {
15 "German",
16 deDEPages
17 },
18 {
19 "Spanish",
20 esESPages
21 },
22 {
23 NULL,
24 NULL
25 }
26 };
27
28 static ULONG SelectedLanguage = 0;
29
30 extern
31 VOID
32 PopupError(PCHAR Text,
33 PCHAR Status,
34 PINPUT_RECORD Ir,
35 ULONG WaitEvent);
36
37
38 PGENERIC_LIST
39 MUICreateLanguageList()
40 {
41 PGENERIC_LIST List;
42 ULONG Index;
43
44 List = CreateGenericList();
45 if (List == NULL)
46 {
47 return NULL;
48 }
49
50 Index = 0;
51
52 do
53 {
54 AppendGenericListEntry(List, LanguageList[Index].LanguageDescriptor, (PVOID)Index, (Index == 0 ? TRUE : FALSE));
55 Index++;
56 }while(LanguageList[Index].MuiPages && LanguageList[Index].LanguageDescriptor);
57
58 return List;
59 }
60
61 BOOLEAN
62 MUISelectLanguage(ULONG LanguageIndex)
63 {
64 SelectedLanguage = LanguageIndex;
65 return TRUE;
66 }
67
68
69 static
70 MUI_ENTRY *
71 findMUIEntriesOfPage(ULONG PageNumber, MUI_PAGE * Pages)
72 {
73 ULONG Index = 0;
74 do
75 {
76 if (Pages[Index].Number == PageNumber)
77 {
78 return Pages[Index].MuiEntry;
79 }
80 Index++;
81 }while(Pages[Index].MuiEntry != NULL);
82 return NULL;
83 }
84
85 VOID
86 MUIDisplayPage(ULONG pg)
87 {
88 MUI_ENTRY * entry;
89 int index;
90 int flags;
91
92 entry = findMUIEntriesOfPage(pg, LanguageList[SelectedLanguage].MuiPages);
93 if (!entry)
94 {
95 PopupError("Error: Failed to find translated page",
96 NULL,
97 NULL,
98 POPUP_WAIT_NONE);
99 return;
100 }
101
102 index = 0;
103 do
104 {
105 flags = entry[index].Flags;
106 switch(flags)
107 {
108 case TEXT_NORMAL:
109 CONSOLE_SetTextXY(entry[index].X, entry[index].Y, entry[index].Buffer);
110 break;
111 case TEXT_HIGHLIGHT:
112 CONSOLE_SetHighlightedTextXY(entry[index].X, entry[index].Y, entry[index].Buffer);
113 break;
114 case TEXT_UNDERLINE:
115 CONSOLE_SetUnderlinedTextXY(entry[index].X, entry[index].Y, entry[index].Buffer);
116 break;
117 case TEXT_STATUS:
118 CONSOLE_SetStatusText(entry[index].Buffer);
119 break;
120 default:
121 break;
122 }
123 index++;
124 }while(entry[index].Buffer != NULL);
125 }