- Allow LANGUAGE_PAGE localization
[reactos.git] / reactos / base / setup / usetup / mui.c
1 /*
2 * ReactOS kernel
3 * Copyright (C) 2008 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 /*
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS text-mode setup
22 * FILE: subsys/system/usetup/mui.c
23 * PURPOSE: Text-mode setup
24 * PROGRAMMER:
25 */
26
27 #include "usetup.h"
28 #include "errorcode.h"
29 #include "mui.h"
30
31 #include "lang/en-US.h"
32 #include "lang/de-DE.h"
33 #include "lang/el-GR.h"
34 #include "lang/es-ES.h"
35 #include "lang/fr-FR.h"
36 #include "lang/it-IT.h"
37 #include "lang/ru-RU.h"
38 #include "lang/sv-SE.h"
39 #include "lang/uk-UA.h"
40
41 static MUI_LANGUAGE LanguageList[] =
42 {
43 {
44 L"00000409", /* The Language ID */
45 L"00000409", /* Default Keyboard Layout for this language */
46 L"English", /* Language Name , not used just to make things easier when updating this file */
47 enUSPages /* Translated strings */
48 },
49 {
50 L"0000040C",
51 L"0000040C",
52 L"French",
53 frFRPages
54 },
55 {
56 L"00000407",
57 L"00000407",
58 L"German",
59 deDEPages
60 },
61 {
62 L"00000408",
63 L"00000408",
64 L"Greek",
65 elGRPages
66 },
67 {
68 L"00000410",
69 L"00000410",
70 L"Italian",
71 itITPages
72 },
73 {
74 L"00000419",
75 L"00000419",
76 L"Russian",
77 ruRUPages
78 },
79 {
80 L"0000040A",
81 L"0000040A",
82 L"Spanish",
83 esESPages
84 },
85 {
86 L"0000041D",
87 L"0000041D",
88 L"Swedish",
89 svSEPages
90 },
91 {
92 L"00000422",
93 L"00000422",
94 L"Ukrainian",
95 ukUAPages
96 },
97 {
98 NULL,
99 NULL,
100 NULL
101 }
102 };
103
104 extern
105 VOID
106 PopupError(PCHAR Text,
107 PCHAR Status,
108 PINPUT_RECORD Ir,
109 ULONG WaitEvent);
110
111 static
112 MUI_ENTRY *
113 FindMUIEntriesOfPage (ULONG PageNumber)
114 {
115 ULONG muiIndex = 0;
116 ULONG lngIndex = 0;
117 MUI_PAGE * Pages = NULL;
118
119 do
120 {
121 /* First we search the language list till we find current selected language messages */
122 if (_wcsicmp(LanguageList[lngIndex].LanguageID , SelectedLanguageId) == 0)
123 {
124 /* Get all available pages for this language */
125 Pages = LanguageList[lngIndex].MuiPages;
126
127 do
128 {
129 /* Get page messages */
130 if (Pages[muiIndex].Number == PageNumber)
131 return Pages[muiIndex].MuiEntry;
132
133 muiIndex++;
134 }
135 while (Pages[muiIndex].MuiEntry != NULL);
136 }
137
138 lngIndex++;
139 }
140 while (LanguageList[lngIndex].MuiPages != NULL);
141
142 return NULL;
143 }
144
145 VOID
146 MUIDisplayPage(ULONG page)
147 {
148 MUI_ENTRY * entry;
149 int index;
150 int flags;
151
152 entry = FindMUIEntriesOfPage (page);
153 if (!entry)
154 {
155 PopupError("Error: Failed to find translated page",
156 NULL,
157 NULL,
158 POPUP_WAIT_NONE);
159 return;
160 }
161
162 index = 0;
163 do
164 {
165 flags = entry[index].Flags;
166 switch(flags)
167 {
168 case TEXT_NORMAL:
169 CONSOLE_SetTextXY(entry[index].X, entry[index].Y, entry[index].Buffer);
170 break;
171 case TEXT_HIGHLIGHT:
172 CONSOLE_SetHighlightedTextXY(entry[index].X, entry[index].Y, entry[index].Buffer);
173 break;
174 case TEXT_UNDERLINE:
175 CONSOLE_SetUnderlinedTextXY(entry[index].X, entry[index].Y, entry[index].Buffer);
176 break;
177 case TEXT_STATUS:
178 CONSOLE_SetStatusText(entry[index].Buffer);
179 break;
180 default:
181 break;
182 }
183 index++;
184 }
185 while (entry[index].Buffer != NULL);
186 }
187
188 VOID
189 MUIDisplayError(ULONG ErrorNum, PINPUT_RECORD Ir, ULONG WaitEvent)
190 {
191 if (ErrorNum >= ERROR_LAST_ERROR_CODE)
192 {
193 PopupError("invalid error number provided",
194 "press enter to continue",
195 Ir,
196 POPUP_WAIT_ENTER);
197
198 return;
199 }
200
201 PopupError(enUSErrorEntries[ErrorNum].ErrorText,
202 enUSErrorEntries[ErrorNum].ErrorStatus,
203 Ir,
204 WaitEvent);
205 }
206
207 /* EOF */