1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619
|
/*
* Copyright (C) Volition, Inc. 1999. All rights reserved.
*
* All source code herein is the property of Volition, Inc. You may not sell
* or otherwise commercially exploit the source or things you created based on the
* source.
*
*/
#include <ctype.h>
#include "cfile/cfile.h"
#include "localization/localize.h"
#include "osapi/osregistry.h"
#include "parse/encrypt.h"
#include "parse/parselo.h"
#include "playerman/player.h"
// ------------------------------------------------------------------------------------------------------------
// LOCALIZE DEFINES/VARS
//
// general language/localization data ---------------------
// current language
int Lcl_current_lang = FS2_OPEN_DEFAULT_LANGUAGE;
SCP_vector<lang_info> Lcl_languages;
// These are the original languages supported by FS2. The code expects these languages to be supported even if the tables don't
lang_info Lcl_builtin_languages[NUM_BUILTIN_LANGUAGES] = {
{ "English", "", {127,0,176,0,0}, 589986744}, // English
{ "German", "gr", {164,0,176,0,0}, -1132430286 }, // German
{ "French", "fr", {164,0,176,0,0}, 0 }, // French
{ "Polish", "pl", {127,0,176,0,0}, -1131728960}, // Polish
};
int Lcl_special_chars;
// use these to replace *_BUILD, values before
// only 1 will be active at a time
int Lcl_fr = 0;
int Lcl_gr = 0;
int Lcl_pl = 0;
int Lcl_english = 1;
// executable string localization data --------------------
// XSTR_SIZE is the total count of unique XSTR index numbers. An index is used to
// reference an entry in strings.tbl. This is used for translation of strings from
// the english version (in the code) to a foreign version (in the table). Thus, if you
// add a new string to the code, you must assign it a new index. Use the number below for
// that index and increase the number below by one.
#define XSTR_SIZE 1638
// struct to allow for strings.tbl-determined x offset
// offset is 0 for english, by default
typedef struct {
const char *str;
int offset_x; // string offset in 640
int offset_x_hi; // string offset in 1024
} lcl_xstr;
//char *Xstr_table[XSTR_SIZE];
lcl_xstr Xstr_table[XSTR_SIZE];
int Xstr_inited = 0;
// table/mission externalization stuff --------------------
#define PARSE_TEXT_BUF_SIZE PARSE_BUF_SIZE
#define PARSE_ID_BUF_SIZE 5
#define LCL_MAX_STRINGS 4500
char *Lcl_ext_str[LCL_MAX_STRINGS];
// ------------------------------------------------------------------------------------------------------------
// LOCALIZE FORWARD DECLARATIONS
//
// given a valid XSTR() tag piece of text, extract the string portion, return it in out, nonzero on success
int lcl_ext_get_text(const char *xstr, char *out);
int lcl_ext_get_text(const SCP_string &xstr, SCP_string &out);
// given a valid XSTR() tag piece of text, extract the id# portion, return the value in out, nonzero on success
int lcl_ext_get_id(const char *xstr, int *out);
int lcl_ext_get_id(const SCP_string &xstr, int *out);
// if the char is a valid char for a signed integer value string
int lcl_is_valid_numeric_char(char c);
// parses the string.tbl and reports back only on the languages it found
void parse_stringstbl_quick(const char *filename);
// ------------------------------------------------------------------------------------------------------------
// LOCALIZE FUNCTIONS
//
// initialize localization, if no language is passed - use the language specified in the registry
void lcl_init(int lang_init)
{
atexit(lcl_xstr_close);
char lang_string[128];
const char *ret;
int lang, idx, i;
// initialize encryption
encrypt_init();
// setup English
Lcl_languages.push_back(Lcl_builtin_languages[FS2_OPEN_DEFAULT_LANGUAGE]);
// check string.tbl to see which languages we support
try
{
parse_stringstbl_quick("strings.tbl");
}
catch (const parse::ParseException& e)
{
mprintf(("TABLES: Unable to parse '%s'! Error message = %s.\n", "strings.tbl", e.what()));
}
parse_modular_table(NOX("*-lcl.tbm"), parse_stringstbl_quick);
// if the only language we have at this point is English, we need to setup the builtin languages as we might be dealing with an old style strings.tbl
// which doesn't support anything beyond the builtin languages. Note, we start at i = 1 because we added English above.
if ((int)Lcl_languages.size() == 1) {
for (i=1; i<NUM_BUILTIN_LANGUAGES; i++) {
Lcl_languages.push_back(Lcl_builtin_languages[i]);
}
}
// read the language from the registry
if(lang_init < 0){
memset(lang_string, 0, 128);
// default to DEFAULT_LANGUAGE (which should be English so we don't have to put German text
// in tstrings in the #default section)
ret = os_config_read_string(NULL, "Language", Lcl_languages[FS2_OPEN_DEFAULT_LANGUAGE].lang_name);
if(ret == NULL){
Error(LOCATION, "Default language not found.");
}
strcpy_s(lang_string, ret);
// look it up
lang = -1;
for(idx = 0; idx < (int)Lcl_languages.size(); idx++){
if(!stricmp(Lcl_languages[idx].lang_name, lang_string)){
lang = idx;
break;
}
}
if(lang < 0){
lang = 0;
}
} else {
Assert((lang_init >= 0) && (lang_init < (int)Lcl_languages.size()));
lang = lang_init;
}
// set the language (this function takes care of setting up file pointers)
lcl_set_language(lang);
}
// determine what language we're running in, see LCL_* defines above
int lcl_get_language()
{
return Lcl_current_lang;
}
// parses the string.tbl to see which languages are supported. Doesn't read in any strings.
void parse_stringstbl_quick(const char *filename)
{
lang_info language;
int lang_idx;
int i;
read_file_text(filename, CF_TYPE_TABLES);
reset_parse();
if (optional_string("#Supported Languages")) {
while (required_string_either("#End","$Language:")) {
required_string("$Language:");
stuff_string(language.lang_name, F_RAW, LCL_LANG_NAME_LEN + 1);
required_string("+Extension:");
stuff_string(language.lang_ext, F_RAW, LCL_LANG_NAME_LEN + 1);
required_string("+Special Character Index:");
stuff_ubyte(&language.special_char_indexes[0]);
for (i = 1; i < MAX_FONTS; ++i) {
// default to "none"/0 except for font03 which defaults to 176
// NOTE: fonts.tbl may override these values
if (i == FONT3) {
language.special_char_indexes[i] = 176;
} else {
language.special_char_indexes[i] = 0;
}
}
lang_idx = -1;
// see if we already have this language
for (i = 0; i < (int)Lcl_languages.size(); i++) {
if (!strcmp(Lcl_languages[i].lang_name, language.lang_name)) {
strcpy_s(Lcl_languages[i].lang_ext, language.lang_ext);
Lcl_languages[i].special_char_indexes[0] = language.special_char_indexes[0];
lang_idx = i;
break;
}
}
// if we have a new language, add it.
if (lang_idx == -1) {
Lcl_languages.push_back(language);
}
}
}
}
// Unified function for loading strings.tbl and tstrings.tbl (and their modular versions).
// The "external" parameter controls which format to load: true for tstrings.tbl, false for strings.tbl
void parse_stringstbl_common(const char *filename, const bool external)
{
char chr, buf[4096];
char language_tag[512];
int i, z, index;
char *p_offset = NULL;
int offset_lo = 0, offset_hi = 0;
read_file_text(filename, CF_TYPE_TABLES);
reset_parse();
// move down to the proper section
memset(language_tag, 0, sizeof(language_tag));
strcpy_s(language_tag, "#");
if (external && Lcl_current_lang == FS2_OPEN_DEFAULT_LANGUAGE){
strcat_s(language_tag, "default");
} else {
strcat_s(language_tag, Lcl_languages[Lcl_current_lang].lang_name);
}
if ( skip_to_string(language_tag) != 1 ) {
mprintf(("Current language not found in %s\n", filename));
return;
}
// parse all the strings in this section of the table
while ( !check_for_string("#") ) {
int num_offsets_on_this_line = 0;
stuff_int(&index);
if (external) {
ignore_white_space();
get_string(buf, sizeof(buf));
drop_trailing_white_space(buf);
} else {
stuff_string(buf, F_RAW, sizeof(buf));
}
if (external && (index < 0 || index >= LCL_MAX_STRINGS)) {
error_display(0, "Invalid tstrings table index specified (%i). Please increment LCL_MAX_STRINGS in localize.cpp.", index);
return;
} else if (!external && (index < 0 || index >= XSTR_SIZE)) {
Error(LOCATION, "Invalid strings table index specified (%i)", index);
}
if (!external) {
i = strlen(buf);
while (i--) {
if ( !isspace(buf[i]) )
break;
}
// trim unnecessary end of string
if (i >= 0) {
// Assert(buf[i] == '"');
if (buf[i] != '"') {
// probably an offset on this entry
// drop down a null terminator (prolly unnecessary)
buf[i+1] = 0;
// back up over the potential offset
while ( !is_white_space(buf[i]) )
i--;
// now back up over intervening spaces
while ( is_white_space(buf[i]) )
i--;
num_offsets_on_this_line = 1;
if (buf[i] != '"') {
// could have a 2nd offset value (one for 640, one for 1024)
// so back up again
while ( !is_white_space(buf[i]) )
i--;
// now back up over intervening spaces
while ( is_white_space(buf[i]) )
i--;
num_offsets_on_this_line = 2;
}
p_offset = &buf[i+1]; // get ptr to string section with offset in it
if (buf[i] != '"')
Error(LOCATION, "%s is corrupt", filename); // now its an error
}
buf[i] = 0;
}
// copy string into buf
z = 0;
for (i = 1; buf[i]; i++) {
chr = buf[i];
if (chr == '\\') {
chr = buf[++i];
if (chr == 'n')
chr = '\n';
else if (chr == 'r')
chr = '\r';
}
buf[z++] = chr;
}
// null terminator on buf
buf[z] = 0;
}
// write into Xstr_table (for strings.tbl) or Lcl_ext_str (for tstrings.tbl)
if (Parsing_modular_table) {
if ( external && (Lcl_ext_str[index] != NULL) ) {
vm_free((void *) Lcl_ext_str[index]);
Lcl_ext_str[index] = NULL;
} else if ( !external && (Xstr_table[index].str != NULL) ) {
vm_free((void *) Xstr_table[index].str);
Xstr_table[index].str = NULL;
}
}
if (external && (Lcl_ext_str[index] != NULL)) {
Warning(LOCATION, "Tstrings table index %d used more than once", index);
} else if (!external && (Xstr_table[index].str != NULL)) {
Warning(LOCATION, "Strings table index %d used more than once", index);
}
if (external) {
Lcl_ext_str[index] = vm_strdup(buf);
} else {
Xstr_table[index].str = vm_strdup(buf);
}
// the rest of this loop applies only to strings.tbl,
// so we can move on to the next line if we're reading from tstrings.tbl
if (external) {
continue;
}
// read offset information, assume 0 if nonexistant
if (p_offset != NULL) {
if (sscanf(p_offset, "%d%d", &offset_lo, &offset_hi) < num_offsets_on_this_line) {
// whatever is in the file ain't a proper offset
Error(LOCATION, "%s is corrupt", filename);
}
}
Xstr_table[index].offset_x = offset_lo;
if (num_offsets_on_this_line == 2)
Xstr_table[index].offset_x_hi = offset_hi;
else
Xstr_table[index].offset_x_hi = offset_lo;
// clear out our vars
p_offset = NULL;
offset_lo = 0;
offset_hi = 0;
}
}
void parse_stringstbl(const char *filename)
{
parse_stringstbl_common(filename, false);
}
void parse_tstringstbl(const char *filename)
{
parse_stringstbl_common(filename, true);
}
// initialize the xstr table
void lcl_xstr_init()
{
int i;
for (i = 0; i < XSTR_SIZE; i++)
Xstr_table[i].str = NULL;
for (i = 0; i < LCL_MAX_STRINGS; i++)
Lcl_ext_str[i] = NULL;
try
{
parse_stringstbl("strings.tbl");
}
catch (const parse::ParseException& e)
{
mprintf(("TABLES: Unable to parse '%s'! Error message = %s.\n", "strings.tbl", e.what()));
}
parse_modular_table(NOX("*-lcl.tbm"), parse_stringstbl);
try
{
parse_tstringstbl("tstrings.tbl");
}
catch (const parse::ParseException& e)
{
mprintf(("TABLES: Unable to parse '%s'! Error message = %s.\n", "tstrings.tbl", e.what()));
}
parse_modular_table(NOX("*-tlc.tbm"), parse_tstringstbl);
Xstr_inited = 1;
}
// free Xstr table
void lcl_xstr_close()
{
int i;
for (i=0; i<XSTR_SIZE; i++){
if (Xstr_table[i].str != NULL) {
vm_free((void *) Xstr_table[i].str);
Xstr_table[i].str = NULL;
}
}
for (i=0; i<LCL_MAX_STRINGS; i++){
if (Lcl_ext_str[i] != NULL) {
vm_free((void *) Lcl_ext_str[i]);
Lcl_ext_str[i] = NULL;
}
}
}
// set our current language
void lcl_set_language(int lang)
{
Lcl_current_lang = lang;
nprintf(("General", "Setting language to %s\n", Lcl_languages[lang].lang_name));
Assertion((Lcl_current_lang >= 0) && (Lcl_current_lang < (int)Lcl_languages.size()), "Attempt to set language to an invalid language");
// flag the proper language as being active
Lcl_special_chars = Lcl_languages[Lcl_current_lang].special_char_indexes[0];
Lcl_fr = 0;
Lcl_gr = 0;
Lcl_pl = 0;
Lcl_english = 0;
if (!strcmp(Lcl_languages[Lcl_current_lang].lang_name, Lcl_builtin_languages[LCL_ENGLISH].lang_name)) {
Lcl_english = 1;
} else if (!strcmp(Lcl_languages[Lcl_current_lang].lang_name, Lcl_builtin_languages[LCL_FRENCH].lang_name)) {
Lcl_fr = 1;
} else if (!strcmp(Lcl_languages[Lcl_current_lang].lang_name, Lcl_builtin_languages[LCL_GERMAN].lang_name)) {
Lcl_gr = 1;
} else if (!strcmp(Lcl_languages[Lcl_current_lang].lang_name, Lcl_builtin_languages[LCL_POLISH].lang_name)) {
Lcl_pl = 1;
}
}
ubyte lcl_get_font_index(int font_num)
{
Assertion((font_num >= 0) && (font_num < MAX_FONTS), "Passed an invalid font index");
Assertion((Lcl_current_lang >= 0) && (Lcl_current_lang < (int)Lcl_languages.size()), "Current language is not valid, can't get font indexes");
return Lcl_languages[Lcl_current_lang].special_char_indexes[font_num];
}
// maybe add on an appropriate subdirectory when opening a localized file
void lcl_add_dir(char *current_path)
{
char last_char;
int path_len;
// if the disk extension is 0 length, don't add enything
if (strlen(Lcl_languages[Lcl_current_lang].lang_ext) <= 0) {
return;
}
// get the length of the string so far
path_len = strlen(current_path);
if (path_len <= 0) {
return;
}
// get the current last char
last_char = current_path[path_len - 1];
// if the last char is a slash, just copy in the disk extension
if (last_char == DIR_SEPARATOR_CHAR) {
strcat(current_path, Lcl_languages[Lcl_current_lang].lang_ext);
strcat(current_path, DIR_SEPARATOR_STR);
}
// otherwise add a slash, then copy in the disk extension
else {
strcat(current_path, DIR_SEPARATOR_STR);
strcat(current_path, Lcl_languages[Lcl_current_lang].lang_ext);
}
}
// maybe add localized directory to full path with file name when opening a localized file
int lcl_add_dir_to_path_with_filename(char *current_path, size_t path_max)
{
// if the disk extension is 0 length, don't add anything
if (strlen(Lcl_languages[Lcl_current_lang].lang_ext) <= 0) {
return 1;
}
size_t str_size = path_max + 1;
char *temp = new char[str_size];
memset(temp, 0, str_size * sizeof(char));
// find position of last slash and copy rest of filename (not counting slash) to temp
// mark end of current path with '\0', so strcat will work
char *last_slash = strrchr(current_path, DIR_SEPARATOR_CHAR);
if (last_slash == NULL) {
strncpy(temp, current_path, path_max);
current_path[0] = '\0';
} else {
strncpy(temp, last_slash+1, path_max);
last_slash[1] = '\0';
}
// add extension
strcat_s(current_path, path_max, Lcl_languages[Lcl_current_lang].lang_ext);
strcat_s(current_path, path_max, DIR_SEPARATOR_STR );
// copy rest of filename from temp
strcat_s(current_path, path_max, temp);
delete [] temp;
return 1;
}
// externalization of table/mission files -----------------------
void lcl_replace_stuff(char *text, size_t max_len)
{
if (Fred_running)
return;
Assert(text); // Goober5000
// delegate to SCP_string for the replacements
SCP_string temp_text = text;
lcl_replace_stuff(temp_text);
// fill up the original string
size_t len = temp_text.copy(text, max_len);
text[len] = 0;
}
// Goober5000 - replace stuff in the string, e.g. $callsign with player's callsign
// now will also replace $rank with rank, e.g. "Lieutenant"
// now will also replace $quote with double quotation marks
// now will also replace $semicolon with semicolon mark
// now will also replace $slash and $backslash
void lcl_replace_stuff(SCP_string &text)
{
if (Fred_running)
return;
if (Player != NULL)
{
replace_all(text, "$callsign", Player->callsign);
replace_all(text, "$rank", Ranks[Player->stats.rank].name);
}
replace_all(text, "$quote", "\"");
replace_all(text, "$semicolon", ";");
replace_all(text, "$slash", "/");
replace_all(text, "$backslash", "\\");
}
void lcl_fred_replace_stuff(char *text, size_t max_len)
{
if (!Fred_running)
return;
Assert(text); // Goober5000
// delegate to SCP_string for the replacements
SCP_string temp_text = text;
lcl_fred_replace_stuff(temp_text);
// fill up the original string
size_t len = temp_text.copy(text, max_len);
text[len] = 0;
}
void lcl_fred_replace_stuff(SCP_string &text)
{
if (!Fred_running)
return;
replace_all(text, "\"", "$quote");
replace_all(text, ";", "$semicolon");
replace_all(text, "/", "$slash");
replace_all(text, "\\", "$backslash");
}
// get the localized version of the string. if none exists, return the original string
// valid input to this function includes :
// "this is some text"
// XSTR("wheeee", -1)
// XSTR("whee", 20)
// and these should cover all the externalized string cases
// fills in id if non-NULL. a value of -2 indicates it is not an external string
void lcl_ext_localize_sub(const char *in, char *out, size_t max_len, int *id)
{
char text_str[PARSE_BUF_SIZE]="";
int str_id;
size_t str_len;
Assert(in);
Assert(out);
// default (non-external string) value
if (id != NULL) {
*id = -2;
}
str_len = strlen(in);
// if the string is < 9 chars, it can't be an XSTR("",) tag, so just copy it
if (str_len < 9) {
if (str_len > max_len)
error_display(0, "Token too long: [%s]. Length = %i. Max is %i.\n", in, str_len, max_len);
strncpy(out, in, max_len);
if (id != NULL)
*id = -2;
return;
}
// otherwise, check to see if it's an XSTR() tag
if (strnicmp(in, "XSTR", 4)) {
// NOT an XSTR() tag
if (str_len > max_len)
error_display(0, "Token too long: [%s]. Length = %i. Max is %i.\n", in, str_len, max_len);
strncpy(out, in, max_len);
if (id != NULL)
*id = -2;
return;
}
// at this point we _know_ its an XSTR() tag, so split off the strings and id sections
if (!lcl_ext_get_text(in, text_str)) {
if (str_len > max_len)
error_display(0, "Token too long: [%s]. Length = %i. Max is %i.\n", in, str_len, max_len);
strncpy(out, in, max_len);
if (id != NULL)
*id = -1;
return;
}
if (!lcl_ext_get_id(in, &str_id)) {
if (str_len > max_len)
error_display(0, "Token too long: [%s]. Length = %i. Max is %i.\n", in, str_len, max_len);
strncpy(out, in, max_len);
if (id != NULL)
*id = -1;
return;
}
// if the localization file is not open, or we're running in the default language, return the original string
if ( !Xstr_inited || (str_id < 0) || (Lcl_current_lang == FS2_OPEN_DEFAULT_LANGUAGE) ) {
if ( strlen(text_str) > max_len )
error_display(0, "Token too long: [%s]. Length = %i. Max is %i.\n", text_str, strlen(text_str), max_len);
strncpy(out, text_str, max_len);
if (id != NULL)
*id = str_id;
return;
}
// get the string if it exists
if ((str_id < LCL_MAX_STRINGS) && (Lcl_ext_str[str_id] != NULL)) {
// copy to the outgoing string
if ( strlen(Lcl_ext_str[str_id]) > max_len )
error_display(0, "Token too long: [%s]. Length = %i. Max is %i.\n", Lcl_ext_str[str_id], strlen(Lcl_ext_str[str_id]), max_len);
strncpy(out, Lcl_ext_str[str_id], max_len);
}
// otherwise use what we have - probably should Int3() or assert here
else {
if ( strlen(text_str) > max_len )
error_display(0, "Token too long: [%s]. Length = %i. Max is %i.\n", text_str, strlen(text_str), max_len);
if (str_id >= LCL_MAX_STRINGS)
error_display(0, "Invalid XSTR ID: [%d]. (Must be less than %d.)\n", str_id, LCL_MAX_STRINGS);
strncpy(out, text_str, max_len);
}
// set the id #
if (id != NULL) {
*id = str_id;
}
}
// ditto for SCP_string
void lcl_ext_localize_sub(const SCP_string &in, SCP_string &out, int *id)
{
SCP_string text_str = "";
int str_id;
// default (non-external string) value
if (id != NULL) {
*id = -2;
}
// if the string is < 9 chars, it can't be an XSTR("",) tag, so just copy it
if (in.length() < 9) {
out = in;
if (id != NULL)
*id = -2;
return;
}
// otherwise, check to see if it's an XSTR() tag
if (in.compare(0, 4, "XSTR")) {
// NOT an XSTR() tag
out = in;
if (id != NULL)
*id = -2;
return;
}
// at this point we _know_ its an XSTR() tag, so split off the strings and id sections
if (!lcl_ext_get_text(in, text_str)) {
out = in;
if (id != NULL)
*id = -1;
return;
}
if (!lcl_ext_get_id(in, &str_id)) {
out = in;
if (id != NULL)
*id = -1;
return;
}
// if the localization file is not open, or we're running in the default language, return the original string
if ( !Xstr_inited || (str_id < 0) || (Lcl_current_lang == FS2_OPEN_DEFAULT_LANGUAGE) ) {
out = text_str;
if (id != NULL)
*id = str_id;
return;
}
// get the string if it exists
if ((str_id < LCL_MAX_STRINGS) && (Lcl_ext_str[str_id] != NULL)) {
// copy to the outgoing string
out = Lcl_ext_str[str_id];
}
// otherwise use what we have - probably should Int3() or assert here
else {
if (str_id >= LCL_MAX_STRINGS)
error_display(0, "Invalid XSTR ID: [%d]. (Must be less than %d.)\n", str_id, LCL_MAX_STRINGS);
out = text_str;
}
// set the id #
if (id != NULL){
*id = str_id;
}
}
// Goober5000 - wrapper for lcl_ext_localize_sub; used because lcl_replace_stuff has to
// be called *after* the translation is done, and the original function returned in so
// many places that it would be messy to call lcl_replace_stuff everywhere
void lcl_ext_localize(const char *in, char *out, size_t max_len, int *id)
{
// do XSTR translation
lcl_ext_localize_sub(in, out, max_len, id);
// do translation of $callsign, $rank, etc.
lcl_replace_stuff(out, max_len);
}
// ditto for SCP_string
void lcl_ext_localize(const SCP_string &in, SCP_string &out, int *id)
{
// do XSTR translation
lcl_ext_localize_sub(in, out, id);
// do translation of $callsign, $rank, etc.
lcl_replace_stuff(out);
}
// translate the specified string based upon the current language
const char *XSTR(const char *str, int index)
{
if(!Xstr_inited)
{
Int3();
return str;
}
// perform a lookup
if (index >= 0 && index < XSTR_SIZE)
{
// return translation of string
if (Xstr_table[index].str)
return Xstr_table[index].str;
}
// can't translate; return original english string
return str;
}
// retrieve the offset for a localized string
int lcl_get_xstr_offset(int index, int res)
{
if (res == GR_640) {
return Xstr_table[index].offset_x;
} else {
return Xstr_table[index].offset_x_hi;
}
}
// ------------------------------------------------------------------------------------------------------------
// LOCALIZE FORWARD DEFINITIONS
//
// given a valid XSTR() tag piece of text, extract the string portion, return it in out, nonzero on success
int lcl_ext_get_text(const char *xstr, char *out)
{
int str_start, str_end;
int str_len;
const char *p, *p2;
Assert(xstr != NULL);
Assert(out != NULL);
str_len = strlen(xstr);
// this is some crazy wack-ass code.
// look for the open quote
str_start = str_end = 0;
p = strstr(xstr, "\"");
if(p == NULL){
error_display(0, "Error parsing XSTR() tag %s\n", xstr);
return 0;
} else {
str_start = p - xstr + 1;
}
// make sure we're not about to walk past the end of the string
if((p - xstr) >= str_len){
error_display(0, "Error parsing XSTR() tag %s\n", xstr);
return 0;
}
// look for the close quote
p2 = strstr(p+1, "\"");
if(p2 == NULL){
error_display(0, "Error parsing XSTR() tag %s\n", xstr);
return 0;
} else {
str_end = p2 - xstr;
}
// check bounds
if (str_end - str_start > PARSE_BUF_SIZE - 1) {
error_display(0, "String cannot fit within XSTR buffer!\n\n%s\n", xstr);
return 0;
}
// now that we know the boundaries of the actual string in the XSTR() tag, copy it
memcpy(out, xstr + str_start, str_end - str_start);
// success
return 1;
}
// given a valid XSTR() tag piece of text, extract the string portion, return it in out, nonzero on success
int lcl_ext_get_text(const SCP_string &xstr, SCP_string &out)
{
size_t open_quote_pos, close_quote_pos;
// this is some crazy wack-ass code.
// look for the open quote
open_quote_pos = xstr.find('\"');
if (open_quote_pos == SCP_string::npos) {
error_display(0, "Error parsing XSTR() tag %s\n", xstr.c_str());
return 0;
}
// look for the close quote
close_quote_pos = xstr.find('\"', open_quote_pos+1);
if (close_quote_pos == SCP_string::npos) {
error_display(0, "Error parsing XSTR() tag %s\n", xstr.c_str());
return 0;
}
// now that we know the boundaries of the actual string in the XSTR() tag, copy it
out.assign(xstr, open_quote_pos + 1, close_quote_pos - open_quote_pos - 1);
// success
return 1;
}
// given a valid XSTR() tag piece of text, extract the id# portion, return the value in out, nonzero on success
int lcl_ext_get_id(const char *xstr, int *out)
{
const char *p, *pnext;
int str_len;
Assert(xstr != NULL);
Assert(out != NULL);
str_len = strlen(xstr);
// find the first quote
p = strchr(xstr, '"');
if(p == NULL){
error_display(0, "Error parsing id# in XSTR() tag %s\n", xstr);
return 0;
}
// make sure we're not about to walk off the end of the string
if((p - xstr) >= str_len){
error_display(0, "Error parsing id# in XSTR() tag %s\n", xstr);
return 0;
}
p++;
// continue searching until we find the close quote
while(true){
pnext = strchr(p, '"');
if(pnext == NULL){
error_display(0, "Error parsing id# in XSTR() tag %s\n", xstr);
return 0;
}
// if the previous char is a \, we know its not the "end-of-string" quote
if(*(pnext - 1) != '\\'){
p = pnext;
break;
}
// continue
p = pnext;
}
// search until we find a ,
pnext = strchr(p, ',');
if(pnext == NULL){
error_display(0, "Error parsing id# in XSTR() tag %s\n", xstr);
return 0;
}
// make sure we're not about to walk off the end of the string
if((pnext - xstr) >= str_len){
error_display(0, "Error parsing id# in XSTR() tag %s\n", xstr);
return 0;
}
// now get the id string
p = pnext+1;
while (is_gray_space(*p))
p++;
pnext = strchr(p+1, ')');
if(pnext == NULL){
error_display(0, "Error parsing id# in XSTR() tag %s\n", xstr);
return 0;
}
if(pnext - p >= PARSE_ID_BUF_SIZE){
error_display(0, "XSTR() id# is too long in %s\n", xstr);
return 0;
}
char buf[PARSE_ID_BUF_SIZE];
strncpy(buf, p, pnext - p);
buf[pnext - p] = 0;
// get the value and we're done
*out = atoi(buf);
// success
return 1;
}
// given a valid XSTR() tag piece of text, extract the id# portion, return the value in out, nonzero on success
int lcl_ext_get_id(const SCP_string &xstr, int *out)
{
char id_buf[10];
size_t p, pnext;
// find the first quote
p = xstr.find('\"');
if (p == SCP_string::npos) {
error_display(0, "Error parsing id# in XSTR() tag %s\n", xstr.c_str());
return 0;
}
p++;
// continue searching until we find the close quote
while(1) {
pnext = xstr.find('\"', p);
if (pnext == SCP_string::npos) {
error_display(0, "Error parsing id# in XSTR() tag %s\n", xstr.c_str());
return 0;
}
// if the previous char is a \, we know its not the "end-of-string" quote
if (xstr[pnext - 1] != '\\') {
p = pnext;
break;
}
// continue
p = pnext;
}
// search until we find a ,
pnext = xstr.find(',', p);
if (pnext == SCP_string::npos) {
error_display(0, "Error parsing id# in XSTR() tag %s\n", xstr.c_str());
return 0;
}
pnext++;
// find the close parenthesis
p = pnext;
pnext = xstr.find(')', p);
if (pnext == SCP_string::npos) {
error_display(0, "Error parsing id# in XSTR() tag %s\n", xstr.c_str());
return 0;
}
pnext--;
// get only the number
while (is_white_space(xstr[p]) && p <= pnext)
p++;
while (is_white_space(xstr[pnext]) && p <= pnext)
pnext--;
if (p > pnext) {
error_display(0, "Error parsing id# in XSTR() tag %s\n", xstr.c_str());
return 0;
}
// now get the id string
if ((pnext - p + 1) > 9) {
error_display(0, "Error parsing id# in XSTR() tag %s\n", xstr.c_str());
return 0;
}
memset(id_buf, 0, 10);
xstr.copy(id_buf, pnext - p + 1, p);
// get the value and we're done
*out = atoi(id_buf);
// success
return 1;
}
// if the char is a valid char for a signed integer value
int lcl_is_valid_numeric_char(char c)
{
return ( (c == '-') || (c == '0') || (c == '1') || (c == '2') || (c == '3') || (c == '4') ||
(c == '5') || (c == '6') || (c == '7') || (c == '8') || (c == '9') ) ? 1 : 0;
}
void lcl_get_language_name(char *lang_name)
{
Assert(Lcl_current_lang < (int)Lcl_languages.size());
strcpy(lang_name, Lcl_languages[Lcl_current_lang].lang_name);
}
// ------------------------------------------------------------------
// lcl_translate_wep_name_gr()
//
// For displaying weapon names in german version
// since we can't actually just change them outright.
//
void lcl_translate_wep_name_gr(char *name)
{
if (!strcmp(name, "Morning Star")) {
strcpy(name, "Morgenstern");
} else if (!strcmp(name, "MorningStar")) {
strcpy(name, "Morgenstern D");
} else if (!strcmp(name, "UD-8 Kayser")) {
strcpy(name, "Kayserstrahl");
} else if (!strcmp(name, "UD-D Kayser")) {
strcpy(name, "Kayserstrahl");
}
}
// ------------------------------------------------------------------
// lcl_translate_brief_icon_name_gr()
//
// For displaying ship names in german version
// since we can't actually just change them outright.
//
void lcl_translate_brief_icon_name_gr(char *name)
{
char *pos;
char buf[128];
if (!stricmp(name, "Subspace Portal")) {
strcpy(name, "Subraum Portal");
} else if (!stricmp(name, "Alpha Wing")) {
strcpy(name, "Alpha");
} else if (!stricmp(name, "Beta Wing")) {
strcpy(name, "Beta");
} else if (!stricmp(name, "Zeta Wing")) {
strcpy(name, "Zeta");
} else if (!stricmp(name, "Capella Node")) {
strcpy(name, "Capella");
} else if (!stricmp(name, "Hostile")) {
strcpy(name, "Gegner");
} else if (!stricmp(name, "Hostile Craft")) {
strcpy(name, "Gegner");
} else if (!stricmp(name, "Rebel Wing")) {
strcpy(name, "Rebellen");
} else if (!stricmp(name, "Rebel Fleet")) {
strcpy(name, "Rebellenflotte");
} else if (!stricmp(name, "Sentry Gun")) {
strcpy(name, "Gesch\x81tz");
} else if (!stricmp(name, "Cargo")) {
strcpy(name, "Fracht");
} else if (!stricmp(name, "Knossos Device")) {
strcpy(name, "Knossosger\x84t");
} else if (!stricmp(name, "Support")) {
strcpy(name, "Versorger");
} else if (!stricmp(name, "Unknown")) {
strcpy(name, "Unbekannt");
} else if (!stricmp(name, "Instructor")) {
strcpy(name, "Ausbilder");
} else if (!stricmp(name, "Jump Node")) {
strcpy(name, "Sprungknoten");
} else if (!stricmp(name, "Escort")) {
strcpy(name, "Geleitschutz");
} else if (!stricmp(name, "Asteroid Field")) {
strcpy(name, "Asteroidenfeld");
} else if (!stricmp(name, "Enif Station")) {
strcpy(name, "Station Enif");
} else if (!stricmp(name, "Rally Point")) {
strcpy(name, "Sammelpunkt");
} else if ((pos = strstr(name, "Transport")) != NULL) {
pos += 9; // strlen of "transport"
strcpy_s(buf, "Transporter");
strcat_s(buf, pos);
strcpy(name, buf);
} else if ((pos = strstr(name, "Jump Node")) != NULL) {
pos += 9; // strlen of "jump node"
strcpy_s(buf, "Sprungknoten");
strcat_s(buf, pos);
strcpy(name, buf);
} else if (!stricmp(name, "Orion under repair")) {
strcpy(name, "Orion wird repariert");
// SOTY-specific ones below!
} else if (!stricmp(name, "Wayfarer Station")) {
strcpy(name, "Station Wayfarer");
} else if (!stricmp(name, "Enemy")) {
strcpy(name, "Gegner");
} else if (!stricmp(name, "Supply Depot")) {
strcpy(name, "Nachschubdepot");
} else if (!stricmp(name, "Fighter Escort")) {
strcpy(name, "Jagdschutz");
} else if (!stricmp(name, "Shivans")) {
strcpy(name, "Shivaner");
} else if (!stricmp(name, "NTF Base of Operations")) {
strcpy(name, "NTF-Operationsbasis");
} else if (!stricmp(name, "NTF Bombers")) {
strcpy(name, "NTF-Bomber");
} else if (!stricmp(name, "NTF Fighters")) {
strcpy(name, "NTF-J\x84ger");
} else if (!stricmp(name, "Sentry")) {
strcpy(name, "Sperrgesch\x81tz");
} else if (!stricmp(name, "Cargo Containers")) {
strcpy(name, "Frachtbeh\x84lter");
} else if (!stricmp(name, "NTF Reinforcements")) {
strcpy(name, "NTF-Verst\x84rkungen");
} else if (!stricmp(name, "NTF Base")) {
strcpy(name, "NTF-St\x81tzpunkt");
} else if (!stricmp(name, "Refugee Convoy")) {
strcpy(name, "Fl\x81""chtlingskonvoi");
} else if (!stricmp(name, "Food Convoy")) {
strcpy(name, "Nachschubkonvoi");
} else if (!stricmp(name, "Governor's Shuttle")) {
strcpy(name, "F\x84hre des Gouverneurs");
} else if (!stricmp(name, "GTVA Patrol")) {
strcpy(name, "GTVA-Patrouille");
} else if (!stricmp(name, "Escort fighters")) {
strcpy(name, "Geleitschutz");
} else if (!stricmp(name, "Nagada Outpost")) {
strcpy(name, "Nagada-Aussenposten");
} else if (!stricmp(name, "Fighters")) {
strcpy(name, "J\x84ger");
} else if (!stricmp(name, "Bombers")) {
strcpy(name, "Bomber");
} else if (!stricmp(name, "Enemy Destroyers")) {
strcpy(name, "Feindliche Zerst\x94rer");
} else if (!stricmp(name, "Ross 128 System")) {
strcpy(name, "System Ross 128");
} else if (!stricmp(name, "Knossos Station")) {
strcpy(name, "Knossos-Station");
} else if (!stricmp(name, "Transporters")) {
strcpy(name, "Transporter");
} else if (!stricmp(name, "Pirates?")) {
strcpy(name, "Piraten?");
} else if (!stricmp(name, "Escorts")) {
strcpy(name, "Geleitschutz");
} else if (!stricmp(name, "Shivan Fighters")) {
strcpy(name, "J\x84ger");
} else if (!stricmp(name, "Shivan Territory")) {
strcpy(name, "Shivaner");
}
}
// ------------------------------------------------------------------
// lcl_translate_brief_icon_name_pl()
//
// For displaying ship names in polish version
// since we can't actually just change them outright.
//
void lcl_translate_brief_icon_name_pl(char *name)
{
char *pos;
char buf[128];
if (!stricmp(name, "Subspace Portal")) {
strcpy(name, "Portal podprz.");
} else if (!stricmp(name, "Alpha Wing")) {
strcpy(name, "Alfa");
} else if (!stricmp(name, "Beta Wing")) {
strcpy(name, "Beta");
} else if (!stricmp(name, "Zeta Wing")) {
strcpy(name, "Zeta");
} else if (!stricmp(name, "Capella Node")) {
strcpy(name, "Capella");
} else if (!stricmp(name, "Hostile")) {
strcpy(name, "Wr\xF3g");
} else if (!stricmp(name, "Hostile Craft")) {
strcpy(name, "Wr\xF3g");
} else if (!stricmp(name, "Rebel Wing")) {
strcpy(name, "Rebelianci");
} else if (!stricmp(name, "Rebel Fleet")) {
strcpy(name, "Flota Rebelii");
} else if (!stricmp(name, "Sentry Gun")) {
strcpy(name, "Dzia\xB3o str.");
} else if (!stricmp(name, "Cargo")) {
strcpy(name, "\xA3\x61\x64unek");
} else if (!stricmp(name, "Knossos Device")) {
strcpy(name, "Urz. Knossos");
} else if (!stricmp(name, "Support")) {
strcpy(name, "Wsparcie");
} else if (!stricmp(name, "Unknown")) {
strcpy(name, "Nieznany");
} else if (!stricmp(name, "Instructor")) {
strcpy(name, "Instruktor");
} else if (!stricmp(name, "Jump Node")) {
strcpy(name, "W\xEAze\xB3 skokowy");
} else if (!stricmp(name, "Escort")) {
strcpy(name, "Eskorta");
} else if (!stricmp(name, "Asteroid Field")) {
strcpy(name, "Pole asteroid");
} else if (!stricmp(name, "Enif Station")) {
strcpy(name, "Stacja Enif");
} else if (!stricmp(name, "Rally Point")) {
strcpy(name, "Pkt zborny");
} else if ((pos = strstr(name, "Transport")) != NULL) {
pos += 9; // strlen of "transport"
strcpy_s(buf, "Transportowiec");
strcat_s(buf, pos);
strcpy(name, buf);
} else if ((pos = strstr(name, "Jump Node")) != NULL) {
pos += 9; // strlen of "jump node"
strcpy_s(buf, "W\xEAze\xB3 skokowy");
strcat_s(buf, pos);
strcpy(name, buf);
} else if (!stricmp(name, "Orion under repair")) {
strcpy(name, "Naprawiany Orion");
}
}
// ------------------------------------------------------------------
// lcl_translate_ship_name_gr()
//
// For displaying ship names in german version in the briefing
// since we can't actually just change them outright.
//
void lcl_translate_ship_name_gr(char *name)
{
if (!strcmp(name, "GTDR Amazon Advanced")) {
strcpy(name, "GTDR Amazon VII");
}
}
// ------------------------------------------------------------------
// lcl_translate_targetbox_name_gr()
//
// For displaying ship names in german version in the targetbox
// since we can't actually just change them outright.
//
void lcl_translate_targetbox_name_gr(char *name)
{
char *pos;
char buf[128];
if ((pos = strstr(name, "Sentry")) != NULL) {
pos += 6; // strlen of "sentry"
strcpy_s(buf, "Sperrgesch\x81tz");
strcat_s(buf, pos);
strcpy(name, buf);
} else if ((pos = strstr(name, "Support")) != NULL) {
pos += 7; // strlen of "support"
strcpy_s(buf, "Versorger");
strcat_s(buf, pos);
strcpy(name, buf);
} else if ((pos = strstr(name, "Unknown")) != NULL) {
pos += 7; // strlen of "unknown"
strcpy_s(buf, "Unbekannt");
strcat_s(buf, pos);
strcpy(name, buf);
} else if ((pos = strstr(name, "Drone")) != NULL) {
pos += 5; // strlen of "drone"
strcpy_s(buf, "Drohne");
strcat_s(buf, pos);
strcpy(name, buf);
} else if ((pos = strstr(name, "Jump Node")) != NULL) {
pos += 9; // strlen of "jump node"
strcpy_s(buf, "Sprungknoten");
strcat_s(buf, pos);
strcpy(name, buf);
} else if (!stricmp(name, "Instructor")) {
strcpy(name, "Ausbilder");
} else if (!stricmp(name, "NTF Vessel")) {
strcpy(name, "NTF-Schiff");
} else if (!stricmp(name, "Enif Station")) {
strcpy(name, "Station Enif");
}
}
// ------------------------------------------------------------------
// lcl_translate_targetbox_name_pl()
//
// For displaying ship names in polish version in the targetbox
// since we can't actually just change them outright.
//
void lcl_translate_targetbox_name_pl(char *name)
{
char *pos;
char buf[128];
if ((pos = strstr(name, "Sentry")) != NULL) {
pos += 6; // strlen of "sentry"
strcpy_s(buf, "Stra\xBFnik");
strcat_s(buf, pos);
strcpy(name, buf);
} else if ((pos = strstr(name, "Support")) != NULL) {
pos += 7; // strlen of "support"
strcpy_s(buf, "Wsparcie");
strcat_s(buf, pos);
strcpy(name, buf);
} else if ((pos = strstr(name, "Unknown")) != NULL) {
pos += 7; // strlen of "unknown"
strcpy_s(buf, "Nieznany");
strcat_s(buf, pos);
strcpy(name, buf);
} else if ((pos = strstr(name, "Drone")) != NULL) {
pos += 5; // strlen of "drone"
strcpy_s(buf, "Sonda");
strcat_s(buf, pos);
strcpy(name, buf);
} else if ((pos = strstr(name, "Jump Node")) != NULL) {
pos += 9; // strlen of "jump node"
strcpy_s(buf, "W\xEAze\xB3 skokowy");
strcat_s(buf, pos);
strcpy(name, buf);
} else if (!stricmp(name, "Instructor")) {
strcpy(name, "Instruktor");
} else if (!stricmp(name, "NTF Vessel")) {
strcpy(name, "Okr\xEAt NTF");
} else if (!stricmp(name, "Enif Station")) {
strcpy(name, "Stacja Enif");
}
}
// this is just a hack to display translated names without actually changing the names,
// which would break stuff
// (this used to be in medals.cpp)
void lcl_translate_medal_name_gr(char *name)
{
if (!strcmp(name, "Epsilon Pegasi Liberation")) {
strcpy(name, "Epsilon Pegasi Befreiungsmedaille");
} else if (!strcmp(name, "Imperial Order of Vasuda")) {
strcpy(name, "Imperialer Orden von Vasuda ");
} else if (!strcmp(name, "Distinguished Flying Cross")) {
strcpy(name, "Fliegerkreuz Erster Klasse");
} else if (!strcmp(name, "SOC Service Medallion")) {
strcpy(name, "SEK-Dienstmedaille ");
} else if (!strcmp(name, "Intelligence Cross")) {
strcpy(name, "Geheimdienstkreuz am Bande");
} else if (!strcmp(name, "Order of Galatea")) {
strcpy(name, "Orden von Galatea ");
} else if (!strcmp(name, "Meritorious Unit Commendation")) {
strcpy(name, "Ehrenspange der Allianz");
} else if (!strcmp(name, "Medal of Valor")) {
strcpy(name, "Tapferkeitsmedaille ");
} else if (!strcmp(name, "GTVA Legion of Honor")) {
strcpy(name, "Orden der GTVA-Ehrenlegion");
} else if (!strcmp(name, "Allied Defense Citation")) {
strcpy(name, "Alliierte Abwehrspange ");
} else if (!strcmp(name, "Nebula Campaign Victory Star")) {
strcpy(name, "Nebel-Siegesstern");
} else if (!strcmp(name, "NTF Campaign Victory Star")) {
strcpy(name, "NTF-Siegesstern ");
} else if (!strcmp(name, "Rank")) {
strcpy(name, "Dienstgrad");
} else if (!strcmp(name, "Wings")) {
strcpy(name, "Fliegerspange");
} else if (!strcmp(name, "Ace")) {
strcpy(name, "Flieger-As");
} else if (!strcmp(name, "Double Ace")) {
strcpy(name, "Doppel-As ");
} else if (!strcmp(name, "Triple Ace")) {
strcpy(name, "Dreifach-As ");
} else if (!strcmp(name, "SOC Unit Crest")) {
strcpy(name, "SEK-Abzeichen ");
}
}
// this is just a hack to display translated names without actually changing the names,
// which would break stuff
// (this used to be in medals.cpp)
void lcl_translate_medal_name_pl(char *name)
{
if (!strcmp(name, "Epsilon Pegasi Liberation")) {
strcpy(name, "Order Wyzwolenia Epsilon Pegasi");
} else if (!strcmp(name, "Imperial Order of Vasuda")) {
strcpy(name, "Imperialny Order Vasudy");
} else if (!strcmp(name, "Distinguished Flying Cross")) {
strcpy(name, "Krzy\xBF Wybitnego Pilota");
} else if (!strcmp(name, "SOC Service Medallion")) {
strcpy(name, "Krzy\xBF S\xB3u\xBF\x62 Specjalnych");
} else if (!strcmp(name, "Intelligence Cross")) {
strcpy(name, "Krzy\xBF Wywiadu");
} else if (!strcmp(name, "Order of Galatea")) {
strcpy(name, "Order Galatei");
} else if (!strcmp(name, "Meritorious Unit Commendation")) {
strcpy(name, "Medal Pochwalny");
} else if (!strcmp(name, "Medal of Valor")) {
strcpy(name, "Medal za Odwag\xEA");
} else if (!strcmp(name, "GTVA Legion of Honor")) {
strcpy(name, "Legia Honorowa GTVA");
} else if (!strcmp(name, "Allied Defense Citation")) {
strcpy(name, "Order za Obron\xEA Sojuszu");
} else if (!strcmp(name, "Nebula Campaign Victory Star")) {
strcpy(name, "Gwiazda Wiktorii Kampanii w Mg\xB3\x61wicy");
} else if (!strcmp(name, "NTF Campaign Victory Star")) {
strcpy(name, "Gwiazda Wiktorii Kampanii NTF");
} else if (!strcmp(name, "Rank")) {
strcpy(name, "Ranga");
} else if (!strcmp(name, "Wings")) {
strcpy(name, "Skrzyd\xB3\x61");
} else if (!strcmp(name, "Ace")) {
strcpy(name, "As");
} else if (!strcmp(name, "Double Ace")) {
strcpy(name, "Podw\xF3jny As");
} else if (!strcmp(name, "Triple Ace")) {
strcpy(name, "Potr\xF3jny As");
} else if (!strcmp(name, "SOC Unit Crest")) {
strcpy(name, "Tarcza S\xB3u\xBF\x62 Specjalnych");
}
}
|