MCPcopy Create free account
hub / github.com/dborth/vbagx / LoadLanguage

Function LoadLanguage

source/utils/gettext.cpp:205–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203}
204
205bool LoadLanguage()
206{
207 char line[200];
208 char *lastID = NULL;
209
210 char *file, *eof;
211
212 switch(GCSettings.language)
213 {
214 case LANG_JAPANESE: file = (char *)jp_lang; eof = file + jp_lang_size; break;
215 case LANG_ENGLISH: file = (char *)en_lang; eof = file + en_lang_size; break;
216 case LANG_GERMAN: file = (char *)de_lang; eof = file + de_lang_size; break;
217 case LANG_FRENCH: file = (char *)fr_lang; eof = file + fr_lang_size; break;
218 case LANG_SPANISH: file = (char *)es_lang; eof = file + es_lang_size; break;
219 case LANG_ITALIAN: file = (char *)it_lang; eof = file + it_lang_size; break;
220 case LANG_DUTCH: file = (char *)nl_lang; eof = file + nl_lang_size; break;
221 case LANG_SIMP_CHINESE:
222 case LANG_TRAD_CHINESE: file = (char *)zh_lang; eof = file + zh_lang_size; break;
223 case LANG_KOREAN: file = (char *)ko_lang; eof = file + ko_lang_size; break;
224 case LANG_PORTUGUESE: file = (char *)pt_lang; eof = file + pt_lang_size; break;
225 case LANG_BRAZILIAN_PORTUGUESE: file = (char *)pt_br_lang; eof = file + pt_br_lang_size; break;
226 case LANG_CATALAN: file = (char *)ca_lang; eof = file + ca_lang_size; break;
227 case LANG_TURKISH: file = (char *)tr_lang; eof = file + tr_lang_size; break;
228 case LANG_SWEDISH: file = (char *)sv_lang; eof = file + sv_lang_size; break;
229 default: return false;
230 }
231
232 gettextCleanUp();
233
234 while (file && file < eof)
235 {
236 file = memfgets(line, sizeof(line), file);
237
238 if(!file)
239 break;
240
241 // lines starting with # are comments
242 if (line[0] == '#')
243 continue;
244
245 if (strncmp(line, "msgid \"", 7) == 0)
246 {
247 char *msgid, *end;
248 if (lastID)
249 {
250 free(lastID);
251 lastID = NULL;
252 }
253 msgid = &line[7];
254 end = strrchr(msgid, '"');
255 if (end && end - msgid > 1)
256 {
257 *end = 0;
258 lastID = strdup(msgid);
259 }
260 }
261 else if (strncmp(line, "msgstr \"", 8) == 0)
262 {

Callers 1

ResetTextFunction · 0.85

Calls 3

gettextCleanUpFunction · 0.85
memfgetsFunction · 0.85
setMSGFunction · 0.85

Tested by

no test coverage detected