64 |
64 |
65 static bool _masterlang; |
65 static bool _masterlang; |
66 static bool _translated; |
66 static bool _translated; |
67 static const char* _file = "(unknown file)"; |
67 static const char* _file = "(unknown file)"; |
68 static int _cur_line; |
68 static int _cur_line; |
69 static int _errors, _warnings; |
69 static int _errors, _warnings, _show_todo; |
70 |
70 |
71 struct LangString { |
71 struct LangString { |
72 char *name; // Name of the string |
72 char *name; // Name of the string |
73 char *english; // English text |
73 char *english; // English text |
74 char *translated; // Translated text |
74 char *translated; // Translated text |
375 if (_plural_form_counts[_lang_pluralform] != nw) { |
375 if (_plural_form_counts[_lang_pluralform] != nw) { |
376 if (_translated) { |
376 if (_translated) { |
377 fatal("%s: Invalid number of plural forms. Expecting %d, found %d.", _cur_ident, |
377 fatal("%s: Invalid number of plural forms. Expecting %d, found %d.", _cur_ident, |
378 _plural_form_counts[_lang_pluralform], nw); |
378 _plural_form_counts[_lang_pluralform], nw); |
379 } else { |
379 } else { |
380 warning("'%s' is untranslated. Tweaking english string to allow compilation for plural forms", _cur_ident); |
380 if ((_show_todo & 2) != 0) warning("'%s' is untranslated. Tweaking english string to allow compilation for plural forms", _cur_ident); |
381 if (nw > _plural_form_counts[_lang_pluralform]) { |
381 if (nw > _plural_form_counts[_lang_pluralform]) { |
382 nw = _plural_form_counts[_lang_pluralform]; |
382 nw = _plural_form_counts[_lang_pluralform]; |
383 } else { |
383 } else { |
384 for (; nw < _plural_form_counts[_lang_pluralform]; nw++) { |
384 for (; nw < _plural_form_counts[_lang_pluralform]; nw++) { |
385 words[nw] = words[nw - 1]; |
385 words[nw] = words[nw - 1]; |
1173 |
1173 |
1174 _cur_ident = ls->name; |
1174 _cur_ident = ls->name; |
1175 _cur_line = ls->line; |
1175 _cur_line = ls->line; |
1176 |
1176 |
1177 // Produce a message if a string doesn't have a translation. |
1177 // Produce a message if a string doesn't have a translation. |
1178 if (show_todo > 0 && ls->translated == NULL) { |
1178 if (_show_todo > 0 && ls->translated == NULL) { |
1179 if (show_todo == 2) { |
1179 if ((_show_todo & 2) != 0) { |
1180 warning("'%s' is untranslated", ls->name); |
1180 warning("'%s' is untranslated", ls->name); |
1181 } else { |
1181 } |
|
1182 if ((_show_todo & 1) != 0) { |
1182 const char *s = "<TODO> "; |
1183 const char *s = "<TODO> "; |
1183 while (*s != '\0') PutByte(*s++); |
1184 while (*s != '\0') PutByte(*s++); |
1184 } |
1185 } |
1185 } |
1186 } |
1186 |
1187 |
1285 { |
1286 { |
1286 char pathbuf[256]; |
1287 char pathbuf[256]; |
1287 const char *src_dir = "."; |
1288 const char *src_dir = "."; |
1288 const char *dest_dir = NULL; |
1289 const char *dest_dir = NULL; |
1289 |
1290 |
1290 int show_todo = 0; |
|
1291 |
|
1292 while (argc > 1 && *argv[1] == '-') { |
1291 while (argc > 1 && *argv[1] == '-') { |
1293 if (strcmp(argv[1], "-v") == 0 || strcmp(argv[1], "--version") == 0) { |
1292 if (strcmp(argv[1], "-v") == 0 || strcmp(argv[1], "--version") == 0) { |
1294 puts("$Revision$"); |
1293 puts("$Revision$"); |
1295 return 0; |
1294 return 0; |
1296 } |
1295 } |
1297 |
1296 |
1298 if (strcmp(argv[1], "-t") == 0 || strcmp(argv[1], "--todo") == 0) { |
1297 if (strcmp(argv[1], "-t") == 0 || strcmp(argv[1], "--todo") == 0) { |
1299 show_todo = 1; |
1298 _show_todo |= 1; |
1300 argc--, argv++; |
1299 argc--, argv++; |
1301 continue; |
1300 continue; |
1302 } |
1301 } |
1303 |
1302 |
1304 if (strcmp(argv[1], "-w") == 0 || strcmp(argv[1], "--warning") == 0) { |
1303 if (strcmp(argv[1], "-w") == 0 || strcmp(argv[1], "--warning") == 0) { |
1305 show_todo = 2; |
1304 _show_todo |= 2; |
1306 argc--, argv++; |
1305 argc--, argv++; |
1307 continue; |
1306 continue; |
1308 } |
1307 } |
1309 |
1308 |
1310 if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0) { |
1309 if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0) { |
1376 |
1375 |
1377 /* rename the .txt (input-extension) to .lng */ |
1376 /* rename the .txt (input-extension) to .lng */ |
1378 r = strrchr(pathbuf, '.'); |
1377 r = strrchr(pathbuf, '.'); |
1379 if (r == NULL || strcmp(r, ".txt") != 0) r = strchr(pathbuf, '\0'); |
1378 if (r == NULL || strcmp(r, ".txt") != 0) r = strchr(pathbuf, '\0'); |
1380 ttd_strlcpy(r, ".lng", (size_t)(r - pathbuf)); |
1379 ttd_strlcpy(r, ".lng", (size_t)(r - pathbuf)); |
1381 WriteLangfile(pathbuf, show_todo); |
1380 WriteLangfile(pathbuf); |
1382 |
1381 |
1383 /* if showing warnings, print a summary of the language */ |
1382 /* if showing warnings, print a summary of the language */ |
1384 if (show_todo == 2) { |
1383 if ((_show_todo & 2) != 0) { |
1385 fprintf(stdout, "%d warnings and %d errors for %s\n", _warnings, _errors, pathbuf); |
1384 fprintf(stdout, "%d warnings and %d errors for %s\n", _warnings, _errors, pathbuf); |
1386 } |
1385 } |
1387 } else { |
1386 } else { |
1388 fprintf(stderr, "Invalid arguments\n"); |
1387 fprintf(stderr, "Invalid arguments\n"); |
1389 } |
1388 } |