2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
4 * All source code herein is the property of Volition, Inc. You may not sell
5 * or otherwise commercially exploit the source or things you created based on
10 * $Logfile: /Freespace2/code/Localization/localize.cpp $
17 * Revision 1.10 2005/10/03 11:23:14 taylor
18 * don't display error message in FS1 for missing tstrings.tbl, it's ok to be missing in that case
20 * Revision 1.9 2005/10/01 21:35:51 taylor
21 * various FS1 related changes, removes need to extra fs1.vp file
23 * Revision 1.8 2005/03/29 02:18:47 taylor
24 * Various 64-bit platform fixes
25 * Fix compiler errors with MAKE_FS1 and fix gr_set_bitmap() too
26 * Make sure that turrets can fire at asteroids for FS1 (needed for a couple missions)
27 * Streaming audio support (big thanks to Pierre Willenbrock!!)
28 * Removed dependance on strings.tbl for FS1 since we don't actually need it now
30 * Revision 1.7 2004/07/04 11:39:06 taylor
31 * fix missing debrief text, crash on exit, path separator's, warning fixes, no GR_SOFT
33 * Revision 1.6 2003/06/11 18:30:32 taylor
36 * Revision 1.5 2003/06/03 04:00:40 taylor
37 * Polish language support (Janusz Dziemidowicz)
39 * Revision 1.4 2003/05/18 03:55:30 taylor
40 * automatic language selection support
42 * Revision 1.3 2002/06/09 04:41:22 relnev
43 * added copyright header
45 * Revision 1.2 2002/05/07 03:16:46 theoddone33
46 * The Great Newline Fix
48 * Revision 1.1.1.1 2002/05/03 03:28:09 root
52 * 91 6/16/00 3:16p Jefff
53 * sim of the year dvd version changes, a few german soty localization
56 * 90 11/02/99 8:20p Jefff
57 * more translation changes/additions
59 * 89 11/02/99 3:24p Jefff
60 * added translation functions for a few key instances where english was
63 * 88 10/29/99 10:40p Jefff
66 * 87 10/28/99 2:05a Jefff
67 * safety fix in localization stuff
69 * 86 10/26/99 10:53a Jefff
70 * German builds now correctly default to German on first run
72 * 85 10/25/99 11:22p Jefff
73 * mo' strings (launcher)
75 * 84 10/25/99 5:46p Jefff
76 * Many localization fixes/changes for German builds
78 * 83 10/14/99 3:25p Jefff
79 * soo...many....xstrs....
81 * 82 10/14/99 2:52p Jefff
82 * localization fixes. added support for hi-res specific xstr offsets
84 * 81 10/13/99 3:58p Jefff
85 * added a bunch of missed XSTRs
87 * 80 9/13/99 11:30a Dave
88 * Added checkboxes and functionality for disabling PXO banners as well as
89 * disabling d3d zbuffer biasing.
91 * 79 9/08/99 9:59a Jefff
93 * 78 9/07/99 4:01p Dave
94 * Fixed up a string.tbl paroblem (self destruct message). Make sure IPX
95 * does everything properly (setting up address when binding). Remove
96 * black rectangle background from UI_INPUTBOX.
98 * 77 9/07/99 1:54p Jefff
99 * skip mission strings added
101 * 76 9/03/99 10:55a Jefff
104 * 75 9/03/99 1:31a Dave
105 * CD checking by act. Added support to play 2 cutscenes in a row
106 * seamlessly. Fixed super low level cfile bug related to files in the
107 * root directory of a CD. Added cheat code to set campaign mission # in
110 * 74 8/27/99 12:04a Dave
111 * Campaign loop screen.
113 * 73 8/26/99 12:48p Jefff
115 * 72 8/22/99 5:53p Dave
116 * Scoring fixes. Added self destruct key. Put callsigns in the logfile
117 * instead of ship designations for multiplayer players.
119 * 71 8/22/99 1:55p Dave
120 * Cleaned up host/team-captain leaving code.
122 * 70 8/17/99 7:32p Jefff
125 * 69 8/16/99 5:15p Dave
126 * Upped string count.
128 * 68 8/16/99 4:04p Dave
129 * Big honking checkin.
131 * 67 8/11/99 2:09p Jefff
132 * ill give you three guesses.
134 * 66 8/10/99 7:57p Jefff
137 * 65 8/05/99 2:40p Jefff
140 * 64 8/02/99 9:13p Dave
143 * 63 8/02/99 12:01p Jefff
146 * 62 7/29/99 10:47p Dave
147 * Standardized D3D fogging using vertex fog. Shook out Savage 4 bugs.
149 * 61 7/29/99 9:44a Jefff
150 * added some strings for ingame objectives screen
152 * 60 7/27/99 7:15p Jefff
153 * 3 new interface strings
155 * 59 7/27/99 6:53p Dave
156 * Hi-res main hall support.
158 * 58 7/24/99 1:54p Dave
159 * Hud text flash gauge. Reworked dead popup to use 4 buttons in red-alert
162 * 57 7/22/99 4:08p Jefff
165 * 56 7/19/99 7:20p Dave
166 * Beam tooling. Specialized player-killed-self messages. Fixed d3d nebula
169 * 55 7/19/99 2:13p Dave
170 * Added some new strings for Heiko.
172 * 54 7/15/99 2:37p Jefff
174 * 53 7/13/99 6:07p Jefff
175 * Added support for localization string offsets.
177 * 52 7/09/99 10:32p Dave
178 * Command brief and red alert screens.
180 * 51 6/25/99 2:51p Jasons
183 * 50 6/25/99 11:59a Dave
184 * Multi options screen.
186 * 49 6/24/99 12:34a Dave
187 * Main options screen.
189 * 48 6/19/99 3:58p Dave
192 * 47 6/14/99 5:19p Dave
194 * 46 6/04/99 11:32a Dave
195 * Added reset text to ship select screen. Fixed minor xstr bug in ui
198 * 45 6/01/99 6:07p Dave
199 * New loading/pause/please wait bar.
201 * 44 6/01/99 4:03p Dave
202 * Changed some popup flag #defines. Upped string count to 1336
204 * 43 5/26/99 11:46a Dave
205 * Added ship-blasting lighting and made the randomization of lighting
206 * much more customizable.
208 * 42 5/22/99 6:05p Dave
209 * Fixed a few localization # problems.
211 * 41 5/21/99 6:45p Dave
212 * Sped up ui loading a bit. Sped up localization disk access stuff. Multi
213 * start game screen, multi password, and multi pxo-help screen.
215 * 40 5/17/99 2:52p Dave
216 * Fixed dumb localization problem.
218 * 39 5/17/99 10:07a Dave
219 * Updated string count.
221 * 38 5/04/99 6:38p Dave
222 * Finished multi join-wait screen.
224 * 37 5/04/99 5:20p Dave
225 * Fixed up multiplayer join screen and host options screen. Should both
228 * 36 5/03/99 11:04p Dave
229 * Most of the way done with the multi join screen.
231 * 35 5/03/99 8:32p Dave
232 * New version of multi host options screen.
234 * 34 4/09/99 2:28p Dave
235 * Upped Xstring count.
237 * 33 4/09/99 2:21p Dave
238 * Multiplayer beta stuff. CD checking.
240 * 32 4/08/99 12:50p Neilk
241 * changed number of xstr constant
243 * 31 4/07/99 5:54p Dave
244 * Fixes for encryption in updatelauncher.
246 * 30 3/24/99 4:05p Dave
247 * Put in support for assigning the player to a specific squadron with a
248 * specific logo. Preliminary work for doing pos/orient checksumming in
249 * multiplayer to reduce bandwidth.
251 * 29 3/23/99 3:35p Andsager
252 * Add error check for duplicate string indices
254 * 28 3/22/99 2:56p Andsager
255 * Localize Launcher Updater
257 * 27 2/23/99 11:18a Andsager
258 * Localize launcher using strings.tbl
260 * 26 2/22/99 9:35p Andsager
261 * Add lcl_get_language_name() returns string with current lang. Added
262 * localization for launcher.
264 * 25 2/21/99 6:02p Dave
265 * Fixed standalone WSS packets.
267 * 24 2/17/99 2:11p Dave
268 * First full run of squad war. All freespace and tracker side stuff
271 * 23 2/12/99 6:15p Dave
272 * Pre-mission Squad War code is 95% done.
274 * 22 2/02/99 7:27p Neilk
275 * implemented lc_close() to free up some string memory when shutting down
277 * 21 1/30/99 1:29a Dave
278 * Fixed nebula thumbnail problem. Full support for 1024x768 choose pilot
279 * screen. Fixed beam weapon death messages.
281 * 20 1/29/99 7:56p Neilk
282 * Added new mission log interface
284 * 19 1/29/99 4:17p Dave
285 * New interface screens.
287 * 18 1/29/99 12:47a Dave
288 * Put in sounds for beam weapon. A bunch of interface screens (tech
291 * 17 1/13/99 2:10p Andsager
294 * 16 12/14/98 12:13p Dave
295 * Spiffed up xfer system a bit. Put in support for squad logo file xfer.
298 * 15 12/03/98 5:22p Dave
299 * Ported over Freespace 1 multiplayer ships.tbl and weapons.tbl
302 * 14 12/02/98 5:47p Dave
303 * Put in interface xstr code. Converted barracks screen to new format.
305 * 13 12/01/98 4:46p Dave
306 * Put in targa bitmap support (16 bit).
314 #include "localize.h"
316 #include "osregistry.h"
320 // ------------------------------------------------------------------------------------------------------------
321 // LOCALIZE DEFINES/VARS
324 // general language/localization data ---------------------
327 int Lcl_current_lang = LCL_ENGLISH;
329 // language info table
330 typedef struct lang_info {
331 char lang_name[LCL_LANG_NAME_LEN + 1]; // literal name of the language
332 char lang_ext[LCL_LANG_NAME_LEN + 1]; // for adding to names on disk access
335 lang_info Lcl_languages[LCL_NUM_LANGUAGES] = {
336 { "English", "" }, // english
337 { "German", "gr" }, // german
338 { "French", "fr" }, // french
339 { "Polish", "pl" }, // polish
342 //#if defined(GERMAN_BUILD)
343 //#define DEFAULT_LANGUAGE "German"
345 #define DEFAULT_LANGUAGE "English"
348 // following is the offset where special characters start in our font
349 #define LCL_SPECIAL_CHARS_FR 164
350 #define LCL_SPECIAL_CHARS_GR 164
351 #define LCL_SPECIAL_CHARS_PL 127
352 #define LCL_SPECIAL_CHARS 127
353 int Lcl_special_chars;
355 // use these to replace *_BUILD, values before
356 // only 1 will be active at a time
363 // executable string localization data --------------------
365 // XSTR_SIZE is the total count of unique XSTR index numbers. An index is used to
366 // reference an entry in strings.tbl. This is used for translation of strings from
367 // the english version (in the code) to a foreign version (in the table). Thus, if you
368 // add a new string to the code, you must assign it a new index. Use the number below for
369 // that index and increase the number below by one.
370 #define XSTR_SIZE 1570
373 // struct to allow for strings.tbl-determined x offset
374 // offset is 0 for english, by default
377 int offset_x; // string offset in 640
378 int offset_x_hi; // string offset in 1024
381 //char *Xstr_table[XSTR_SIZE];
382 lcl_xstr Xstr_table[XSTR_SIZE];
386 // table/mission externalization stuff --------------------
388 #define TABLE_STRING_FILENAME "tstrings.tbl"
389 // filename of the file to use when localizing table strings
390 char *Lcl_ext_filename = NULL;
391 CFILE *Lcl_ext_file = NULL;
393 // for scanning/parsing tstrings.tbl (from ExStr)
394 #define PARSE_TEXT_STRING_LEN 2048
395 #define PARSE_ID_STRING_LEN 128
396 #define TS_SCANNING 0 // scanning for a line of text
397 #define TS_ID_STRING 1 // reading in an id string
398 #define TS_OPEN_QUOTE 2 // looking for an open quote
399 #define TS_STRING 3 // reading in the text string itself
400 int Ts_current_state = 0;
401 char Ts_text[PARSE_TEXT_STRING_LEN]; // string we're currently working with
402 char Ts_id_text[PARSE_ID_STRING_LEN]; // id string we're currently working with
406 // file pointers for optimized string lookups
407 // some example times for Freespace2 startup with granularities (mostly .tbl files, ~500 strings in the table file, many looked up more than once)
408 // granularity 20 : 13 secs
409 // granularity 10 : 11 secs
410 // granularity 5 : 9 secs
411 // granularity 2 : 7-8 secs
412 #define LCL_GRANULARITY 1 // how many strings between each pointer (lower granularities should give faster lookup times)
413 #define LCL_MAX_POINTERS 4500 // max # of pointers
414 #define LCL_MAX_STRINGS (LCL_GRANULARITY * LCL_MAX_POINTERS)
415 int Lcl_pointers[LCL_MAX_POINTERS];
416 int Lcl_pointer_count = 0;
419 // strings.tbl for FS1, hard coded
420 extern const char *FS1_trans[LCL_NUM_LANGUAGES_FS1][LCL_NUM_STRINGS_FS1];
423 // ------------------------------------------------------------------------------------------------------------
424 // LOCALIZE FORWARD DECLARATIONS
427 // associate table file externalization with the specified input file
428 void lcl_ext_associate(const char *filename);
430 // given a valid XSTR() tag piece of text, extract the string portion, return it in out, nonzero on success
431 int lcl_ext_get_text(char *xstr, char *out);
433 // given a valid XSTR() tag piece of text, extract the id# portion, return the value in out, nonzero on success
434 int lcl_ext_get_id(char *xstr, int *out);
436 // given a valid XSTR() id#, lookup the string in tstrings.tbl, filling in out if found, nonzero on success
437 int lcl_ext_lookup(char *out, const int max_out, int id);
439 // if the char is a valid char for a signed integer value string
440 int lcl_is_valid_numeric_char(char c);
442 // sub-parse function for individual lines of tstrings.tbl (from Exstr)
443 // returns : integer with the low bits having the following values :
444 // 0 on fail, 1 on success, 2 if found a matching id/string pair, 3 if end of language has been found
445 // for cases 1 and 2 : the high bit (1<<31) will be set if the parser detected the beginning of a new string id on this line
446 // so be sure to mask this value out to get the low portion of the return value
448 int lcl_ext_lookup_sub(char *text, char *out, const int max_out, int id);
450 // initialize the pointer array into tstrings.tbl (call from lcl_ext_open() ONLY)
451 void lcl_ext_setup_pointers();
454 // ------------------------------------------------------------------------------------------------------------
455 // LOCALIZE FUNCTIONS
458 // initialize localization, if no language is passed - use the language specified in the registry
459 void lcl_init(int lang_init)
461 char lang_string[128];
465 // initialize encryption
468 // read the language from the registry
470 memset(lang_string, 0, 128);
472 // default to DEFAULT_LANGUAGE (which should be english so we dont have to put German text
473 // in tstrings in the #default section
474 ret = os_config_read_string(NULL, "Language", DEFAULT_LANGUAGE);
478 SDL_strlcpy(lang_string, DEFAULT_LANGUAGE, sizeof(lang_string));
480 SDL_strlcpy(lang_string, ret, sizeof(lang_string));
485 for(idx=0; idx<LCL_NUM_LANGUAGES; idx++){
486 if(!SDL_strcasecmp(Lcl_languages[idx].lang_name, lang_string)){
495 SDL_assert((lang_init >= 0) && (lang_init < LCL_NUM_LANGUAGES));
500 if (lang >= LCL_NUM_LANGUAGES_FS1)
505 Lcl_pointer_count = 0;
507 // associate the table string file
508 lcl_ext_associate(TABLE_STRING_FILENAME);
510 // set the language (this function takes care of setting up file pointers)
511 lcl_set_language(lang);
514 // added 2.2.99 by NeilK to take care of fs2 launcher memory leaks
515 // shutdown localization
518 // if the filename exists, free it up
519 if(Lcl_ext_filename != NULL){
520 free(Lcl_ext_filename);
523 // free the Xstr_table
527 // determine what language we're running in, see LCL_* defines above
528 int lcl_get_language()
530 return Lcl_current_lang;
533 // initialize the xstr table
539 char language_tag[512];
541 char *p_offset = NULL;
542 int offset_lo = 0, offset_hi = 0;
543 int num_offsets_on_this_line = 0;
545 for (i=0; i<XSTR_SIZE; i++){
546 Xstr_table[i].str = NULL;
549 if ((rval = setjmp(parse_abort)) != 0) {
550 mprintf(("Error parsing 'strings.tbl'\nError code = %i.\n", rval));
552 // make sure localization is NOT running
555 read_file_text("strings.tbl");
558 // move down to the proper section
559 memset(language_tag, 0, 512);
560 SDL_strlcpy(language_tag, "#", sizeof(language_tag));
561 SDL_strlcat(language_tag, Lcl_languages[Lcl_current_lang].lang_name, sizeof(language_tag));
562 if(skip_to_string(language_tag) != 1){
563 Error(LOCATION, NOX("Strings.tbl is corrupt"));
566 // parse all the strings in this section of the table
567 while (!check_for_string("#")) {
569 stuff_string(buf, F_NAME, NULL, 4096);
577 if (!isspace(buf[i])) {
582 // trim unneccesary end of string
584 // SDL_assert(buf[i] == '"');
586 // probably an offset on this entry
587 buf[i+1] = 0; // drop down a null terminator (prolly unnecessary)
588 while(!is_white_space(buf[i])) i--; // back up over the potential offset
589 while(is_white_space(buf[i])) i--; // now back up over intervening spaces
590 num_offsets_on_this_line = 1;
592 // could have a 2nd offset value (one for 640, one for 1024)
594 while(!is_white_space(buf[i])) i--; // back up over the 2nd offset
595 while(is_white_space(buf[i])) i--; // now back up over intervening spaces
596 num_offsets_on_this_line = 2;
599 p_offset = &buf[i+1]; // get ptr to string section with offset in it
601 Error(LOCATION, NOX("Strings.tbl is corrupt")); // now its an error
608 // copy string into buf
610 for (i=1; buf[i]; i++) {
616 } else if (chr == 'r') {
625 // null terminator on buf
628 // write into Xstr_table
629 if (index >= 0 && index < XSTR_SIZE) {
630 if (Xstr_table[index].str != NULL) {
631 Warning(LOCATION, "Strings table index %d used more than once", index);
633 Xstr_table[index].str = strdup(buf);
636 // read offset information, assume 0 if nonexistant
637 if (p_offset != NULL) {
638 if (sscanf(p_offset, "%d%d", &offset_lo, &offset_hi) < num_offsets_on_this_line) {
639 // whatever is in the file ain't a proper offset
640 Error(LOCATION, NOX("Strings.tbl is corrupt"));
643 Xstr_table[index].offset_x = offset_lo;
644 if (num_offsets_on_this_line == 2) {
645 Xstr_table[index].offset_x_hi = offset_hi;
647 Xstr_table[index].offset_x_hi = offset_lo;
650 // clear out our vars
654 num_offsets_on_this_line = 0;
660 SDL_assert(XSTR_SIZE == LCL_NUM_STRINGS_FS1);
661 SDL_assert(Lcl_current_lang < LCL_NUM_LANGUAGES_FS1);
663 for (i=0; i<XSTR_SIZE; i++) {
664 if ( !strlen(FS1_trans[Lcl_current_lang][i]) ) {
665 Xstr_table[i].str = NULL;
667 Xstr_table[i].str = (char *)FS1_trans[Lcl_current_lang][i];
670 Xstr_table[i].offset_x = 0;
671 Xstr_table[i].offset_x_hi = 0;
680 void lcl_xstr_close()
683 for (int i=0; i<XSTR_SIZE; i++){
684 if (Xstr_table[i].str != NULL) {
685 free(Xstr_table[i].str);
686 Xstr_table[i].str = NULL;
693 // set our current language
694 void lcl_set_language(int lang)
696 Lcl_current_lang = lang;
698 nprintf(("General", "Setting language to %s\n", Lcl_languages[lang].lang_name));
700 // flag the proper language as being active
708 Lcl_special_chars = LCL_SPECIAL_CHARS;
712 Lcl_special_chars = LCL_SPECIAL_CHARS_FR;
716 Lcl_special_chars = LCL_SPECIAL_CHARS_GR;
720 Lcl_special_chars = LCL_SPECIAL_CHARS_PL;
724 // set to 0, so lcl_ext_open() knows to reset file pointers
725 Lcl_pointer_count = 0;
727 // reset file pointers to the proper language-section
728 if(Lcl_current_lang != LCL_DEFAULT_LANGUAGE){
729 lcl_ext_setup_pointers();
733 // maybe add on an appropriate subdirectory when opening a localized file
734 void lcl_add_dir(char *current_path, const int max_len)
739 // if the disk extension is 0 length, don't add enything
740 if (strlen(Lcl_languages[Lcl_current_lang].lang_ext) <= 0) {
744 // get the length of the string so far
745 path_len = strlen(current_path);
750 // get the current last char
751 last_char = current_path[path_len - 1];
753 // if the last char is a slash, just copy in the disk extension
754 if (last_char == DIR_SEPARATOR_CHAR) {
755 SDL_strlcat(current_path, Lcl_languages[Lcl_current_lang].lang_ext, max_len);
756 SDL_strlcat(current_path, DIR_SEPARATOR_STR, max_len);
758 // otherwise add a slash, then copy in the disk extension
760 SDL_strlcat(current_path, DIR_SEPARATOR_STR, max_len);
761 SDL_strlcat(current_path, Lcl_languages[Lcl_current_lang].lang_ext, max_len);
765 // maybe add localized directory to full path with file name when opening a localized file
766 void lcl_add_dir_to_path_with_filename(char *current_path, const int path_len)
768 char temp[MAX_PATH_LEN];
770 // if the disk extension is 0 length, don't add enything
771 if (strlen(Lcl_languages[Lcl_current_lang].lang_ext) <= 0) {
775 // find position of last slash and copy rest of filename (not counting slash) to temp
776 // mark end of current path with '\0', so strcat will work
777 char *last_slash = strrchr(current_path, DIR_SEPARATOR_CHAR);
778 if (last_slash == NULL) {
779 SDL_strlcpy(temp, current_path, sizeof(temp));
780 current_path[0] = '\0';
782 SDL_strlcpy(temp, last_slash+1, sizeof(temp));
783 last_slash[1] = '\0';
787 SDL_strlcat(current_path, Lcl_languages[Lcl_current_lang].lang_ext, path_len);
788 SDL_strlcat(current_path, DIR_SEPARATOR_STR, path_len);
790 // copy rest of filename from temp
791 SDL_strlcat(current_path, temp, path_len);
795 // externalization of table/mission files -----------------------
797 // open the externalization file for use during parsing (call before parsing a given file)
800 // if the file is already open, do nothing
801 SDL_assert(Lcl_ext_file == NULL);
803 // if we're running in the default language, do nothing
804 if(Lcl_current_lang == LCL_DEFAULT_LANGUAGE){
809 // otherwise open the file
810 Lcl_ext_file = cfopen(Lcl_ext_filename, "rt");
811 if(Lcl_ext_file == NULL){
817 // close the externalization file (call after parsing a given file)
820 // if the file is not open, do nothing
821 if(Lcl_ext_file == NULL){
825 // if we're running in the default language, do nothing
826 if(Lcl_current_lang == LCL_DEFAULT_LANGUAGE){
830 // otherwise close it
831 cfclose(Lcl_ext_file);
835 // get the localized version of the string. if none exists, return the original string
836 // valid input to this function includes :
837 // "this is some text"
838 // XSTR("wheeee", -1)
840 // and these should cover all the externalized string cases
841 // fills in id if non-NULL. a value of -2 indicates it is not an external string
842 void lcl_ext_localize(char *in, char *out, int max_len, int *id)
845 char text_str[2048]="";
846 char lookup_str[2048]="";
853 // default (non-external string) value
858 str_len = strlen(in);
860 // if the string is < 9 chars, it can't be an XSTR("",) tag, so just copy it
862 if(str_len > max_len){
863 error_display(0, "Token too long: [%s]. Length = %i. Max is %i.\n", in, str_len, max_len);
866 SDL_strlcpy(out, in, max_len);
873 // otherwise, check to see if it's an XSTR() tag
874 memset(first_four, 0, 5);
875 SDL_strlcpy(first_four, in, sizeof(first_four));
876 if(SDL_strcasecmp(first_four, "XSTR")){
878 if(str_len > max_len){
879 error_display(0, "Token too long: [%s]. Length = %i. Max is %i.\n", in, str_len, max_len);
882 SDL_strlcpy(out, in, max_len);
889 // at this point we _know_ its an XSTR() tag, so split off the strings and id sections
890 if(!lcl_ext_get_text(in, text_str)){
892 SDL_strlcpy(out, in, max_len);
898 if(!lcl_ext_get_id(in, &str_id)){
899 SDL_strlcpy(out, in, max_len);
906 // if the localization file is not open, or we're running in the default language, return the original string
907 if((Lcl_ext_file == NULL) || (str_id < 0) || (Lcl_current_lang == LCL_DEFAULT_LANGUAGE)){
908 SDL_strlcpy(out, text_str, max_len);
915 // attempt to find the string
916 if(lcl_ext_lookup(lookup_str, sizeof(lookup_str), str_id)){
917 // copy to the outgoing string
918 SDL_assert(strlen(lookup_str) <= (unsigned int)(max_len - 1));
920 if (strlen(lookup_str) > (unsigned int)(max_len-1)) {
921 // be safe and truncate string to fit
922 SDL_strlcpy(out, lookup_str, max_len);
924 SDL_strlcpy(out, lookup_str, max_len);
928 // otherwise use what we have - probably should Int3() or assert here
930 SDL_strlcpy(out, text_str, max_len);
939 // translate the specified string based upon the current language
940 const char *XSTR(const char *str, int index)
947 if (index >= 0 && index < XSTR_SIZE) {
948 if (Xstr_table[index].str){
949 return Xstr_table[index].str; // return translation of string
953 // can't translate, return original english string
957 // retrieve the offset for a localized string
958 int lcl_get_xstr_offset(int index, int res)
961 return Xstr_table[index].offset_x;
963 return Xstr_table[index].offset_x_hi;
968 // ------------------------------------------------------------------------------------------------------------
969 // LOCALIZE FORWARD DEFINITIONS
972 // associate table file externalization with the specified input file
973 void lcl_ext_associate(const char *filename)
976 // if the filename already exists, free it up
977 if(Lcl_ext_filename != NULL){
978 free(Lcl_ext_filename);
981 // set the new filename
982 Lcl_ext_filename = strdup(filename);
986 // given a valid XSTR() tag piece of text, extract the string portion, return it in out, nonzero on success
987 int lcl_ext_get_text(char *xstr, char *out)
989 int str_start = 0, str_end = 0;
993 SDL_assert(xstr != NULL);
994 SDL_assert(out != NULL);
995 str_len = strlen(xstr);
997 // this is some crazy wack-ass code.
998 // look for the open quote
999 p = strstr(xstr, "\"");
1001 error_display(0, "Error parsing XSTR() tag %s\n", xstr);
1004 str_start = p - xstr + 1;
1006 // make sure we're not about to walk past the end of the string
1007 if((p - xstr) >= str_len){
1008 error_display(0, "Error parsing XSTR() tag %s\n", xstr);
1012 // look for the close quote
1013 p2 = strstr(p+1, "\"");
1015 error_display(0, "Error parsing XSTR() tag %s\n", xstr);
1018 str_end = p2 - xstr;
1021 // now that we know the boundaries of the actual string in the XSTR() tag. copy it
1022 memcpy(out, xstr + str_start, str_end - str_start);
1025 lcl_fix_polish(out);
1032 // given a valid XSTR() tag piece of text, extract the id# portion, return the value in out, nonzero on success
1033 int lcl_ext_get_id(char *xstr, int *out)
1038 SDL_assert(xstr != NULL);
1039 SDL_assert(out != NULL);
1041 str_len = strlen(xstr);
1043 // find the first quote
1044 p = strstr(xstr, "\"");
1046 error_display(0, "Error parsing id# in XSTR() tag %s\n", xstr);
1049 // make sure we're not about to walk off the end of the string
1050 if((p - xstr) >= str_len){
1051 error_display(0, "Error parsing id# in XSTR() tag %s\n", xstr);
1056 // continue searching until we find the close quote
1058 pnext = strstr(p, "\"");
1060 error_display(0, "Error parsing id# in XSTR() tag %s\n", xstr);
1064 // if the previous char is a \, we know its not the "end-of-string" quote
1065 if(*(pnext - 1) != '\\'){
1074 // search until we find a ,
1075 pnext = strstr(p, ",");
1077 error_display(0, "Error parsing id# in XSTR() tag %s\n", xstr);
1080 // make sure we're not about to walk off the end of the string
1081 if((pnext - xstr) >= str_len){
1082 error_display(0, "Error parsing id# in XSTR() tag %s\n", xstr);
1087 // now get the id string
1089 pnext = strtok(p, ")");
1091 error_display(0, "Error parsing id# in XSTR() tag %s\n", xstr);
1095 // get the value and we're done
1102 // given a valid XSTR() id#, lookup the string in tstrings.tbl, filling in out if found, nonzero on success
1103 int lcl_ext_lookup(char *out, const int max_out, int id)
1109 SDL_assert(Lcl_pointer_count >= 0);
1110 SDL_assert(Lcl_pointers[0] >= 0);
1111 SDL_assert(Lcl_pointers[Lcl_pointer_count - 1] >= 0);
1112 SDL_assert(Lcl_ext_file != NULL);
1113 SDL_assert(id >= 0);
1115 // seek to the closest pointer <= the id# we're looking for
1116 pointer = id / LCL_GRANULARITY;
1117 cfseek(Lcl_ext_file, Lcl_pointers[pointer], CF_SEEK_SET);
1119 // reset parsing vars and go to town
1120 Ts_current_state = TS_SCANNING;
1121 Ts_id_text_size = 0;
1123 memset(Ts_text, 0, PARSE_TEXT_STRING_LEN);
1124 memset(Ts_id_text, 0, PARSE_ID_STRING_LEN);
1125 while((cftell(Lcl_ext_file) < Lcl_pointers[Lcl_pointer_count - 1]) && cfgets(text, 1024, Lcl_ext_file)){
1126 ret = lcl_ext_lookup_sub(text, out, max_out, id);
1128 // run the line parse function
1129 switch(ret & 0x0fffffff){
1132 Int3(); // should never get here - it means the string doens't exist in the table!!
1135 // success parsing the line - please continue
1139 // found a matching string/id pair
1143 // this is because tstrings.tbl reads in as ANSI for some reason
1144 // opening tstrings with "rb" mode didnt seem to help, so its now still "rt" like before
1145 lcl_fix_umlauts(out, LCL_TO_ASCII);
1149 // end of language found
1151 Int3(); // should never get here - it means the string doens't exist in the table!!
1156 Int3(); // should never get here - it means the string doens't exist in the table!!
1160 // sub-parse function for individual lines of tstrings.tbl (from Exstr)
1161 // returns : integer with the low bits having the following values :
1162 // 0 on fail, 1 on success, 2 if found a matching id/string pair, 3 if end of language has been found
1163 // for cases 1 and 2 : the high bit (1<<31) will be set if the parser detected the beginning of a new string id on this line
1165 int lcl_ext_lookup_sub(char *text, char *out, const int max_out, int id)
1167 char *p; // current ptr
1168 int len = strlen(text);
1170 char text_copy[1024];
1172 int found_new_string_id = 0;
1177 // do something useful
1178 switch(Ts_current_state){
1179 // scanning for a line of text
1181 // if the first word is #end, we're done with the file altogether
1182 SDL_strlcpy(text_copy, text, sizeof(text_copy));
1183 tok = strtok(text_copy, " \n");
1184 if((tok != NULL) && !SDL_strcasecmp(tok, "#end")){
1187 // if its a commented line, skip it
1188 else if((text[0] == ';') || (text[0] == ' ') || (text[0] == '\n')){
1191 // otherwise we should have an ID #, so stuff it and move to the proper state
1193 if(lcl_is_valid_numeric_char(*p)){
1194 memset(Ts_id_text, 0, PARSE_ID_STRING_LEN);
1195 Ts_id_text_size = 0;
1196 Ts_id_text[Ts_id_text_size++] = *p;
1197 Ts_current_state = TS_ID_STRING;
1199 found_new_string_id = 1;
1209 // scanning in an id string
1211 // if we have another valid char
1212 if(lcl_is_valid_numeric_char(*p)){
1213 Ts_id_text[Ts_id_text_size++] = *p;
1215 // if we found a comma, our id# is finished, look for the open quote
1217 Ts_current_state = TS_OPEN_QUOTE;
1225 // valid space or an open quote
1226 if((*p == ' ') || (*p == '\"')){
1228 memset(Ts_text, 0, PARSE_TEXT_STRING_LEN);
1230 Ts_current_state = TS_STRING;
1239 // if we have an end quote, we need to look for a comma
1240 if((*p == '\"') /*&& (Ts_text_size > 0)*/ && (Ts_text[Ts_text_size - 1] != '\\')){
1241 // we're now done - we have a string
1242 Ts_current_state = TS_SCANNING;
1244 // if the id#'s match, copy the string and return "string found"
1245 if((atoi(Ts_id_text) == id) && (out != NULL)){
1246 SDL_strlcpy(out, Ts_text, max_out);
1248 return found_new_string_id ? (1<<1) | (1<<31) : (1<<1);
1251 // otherwise, just continue parsing
1252 return found_new_string_id ? (1<<0) | (1<<31) : (1<<0);
1254 // otherwise add to the string
1256 Ts_text[Ts_text_size++] = *p;
1261 // if we have a newline, return success, we're done with this line
1263 return found_new_string_id ? (1<<0) | (1<<31) : (1<<0);
1266 // next char in the line
1272 return found_new_string_id ? (1<<0) | (1<<31) : (1<<0);
1275 // if the char is a valid char for a signed integer value
1276 int lcl_is_valid_numeric_char(char c)
1278 return ( (c == '-') || (c == '0') || (c == '1') || (c == '2') || (c == '3') || (c == '4') ||
1279 (c == '5') || (c == '6') || (c == '7') || (c == '8') || (c == '9') ) ? 1 : 0;
1282 // initialize the pointer array into tstrings.tbl (call from lcl_ext_open() ONLY)
1283 void lcl_ext_setup_pointers()
1285 char language_string[128];
1290 int found_start = 0;
1292 // open the localization file
1294 if(Lcl_ext_file == NULL){
1296 error_display(0, "Error opening externalization file! File likely does not exist or could not be found");
1301 // seek to the currently active language
1302 memset(language_string, 0, 128);
1303 SDL_strlcpy(language_string, "#", sizeof(language_string));
1304 if(!SDL_strcasecmp(DEFAULT_LANGUAGE, Lcl_languages[Lcl_current_lang].lang_name)){
1305 SDL_strlcat(language_string, "default", sizeof(language_string));
1307 SDL_strlcat(language_string, Lcl_languages[Lcl_current_lang].lang_name, sizeof(language_string));
1309 memset(line, 0, 1024);
1311 // reset seek variables and begin
1312 Lcl_pointer_count = 0;
1313 while(cfgets(line, 1024, Lcl_ext_file)){
1314 tok = strtok(line, " \n");
1319 // if the language matches, we're good to start parsing strings
1320 if(!SDL_strcasecmp(language_string, tok)){
1326 // if we didn't find the language specified, error
1327 if(found_start <= 0){
1328 error_display(0, "Could not find specified langauge in tstrings.tbl!\n");
1334 while(cfgets(line, 1024, Lcl_ext_file)){
1335 ret = lcl_ext_lookup_sub(line, NULL, 0, -1);
1338 switch(ret & 0x0fffffff){
1344 // end of language found
1346 // mark one final pointer
1347 Lcl_pointers[Lcl_pointer_count++] = cftell(Lcl_ext_file) - strlen(line) - 1;
1352 // the only other case we care about is the beginning of a new id#
1354 if((string_count % LCL_GRANULARITY) == 0){
1355 // mark the pointer down
1356 Lcl_pointers[Lcl_pointer_count++] = cftell(Lcl_ext_file) - strlen(line) - 1;
1358 // if we're out of pointer slots
1359 if(Lcl_pointer_count >= LCL_MAX_POINTERS){
1360 error_display(0, "Out of pointer for tstrings.tbl lookup. Please increment LCL_MAX_POINTERS in localize.cpp");
1365 // increment string count
1370 // should never get here. we should always be exiting through case 3 (end of language section) of the above switch
1376 void lcl_get_language_name(char *lang_name, const int max_len)
1378 SDL_assert(LCL_NUM_LANGUAGES == 3);
1380 SDL_strlcpy(lang_name, Lcl_languages[Lcl_current_lang].lang_name, max_len);
1383 // converts german umlauted chars from ASCII to ANSI
1384 // so they appear in the launcher
1385 // how friggin lame is this
1386 // pass in a null terminated string, foo!
1387 // returns ptr to string you sent in
1388 char* lcl_fix_umlauts(char *str, int which_way)
1392 if (which_way == LCL_TO_ANSI) {
1393 // moving to ANSI charset
1394 // run thru string and perform appropriate conversions
1395 while (str[i] != '\0') {
1422 // beta-lookin thing that means "ss"
1430 // moving to ASCII charset
1431 // run thru string and perform appropriate conversions
1432 while (str[i] != '\0') {
1459 // beta-lookin thing that means "ss"
1471 // convert some of the polish characters
1472 void lcl_fix_polish(char *str)
1475 if(*str == '\xA2') *str = '\xF3';
1476 else if(*str == '\x88') *str = '\xEA';
1480 // ------------------------------------------------------------------
1481 // lcl_translate_wep_name()
1483 // For displaying weapon names in german version
1484 // since we cant actually just change them outright.
1486 void lcl_translate_wep_name(char *name, const int max_len)
1488 if (!strcmp(name, "Morning Star")) {
1489 SDL_strlcpy(name, "Morgenstern", max_len);
1490 } else if (!strcmp(name, "MorningStar")) {
1491 SDL_strlcpy(name, "Morgenstern D", max_len);
1492 } else if (!strcmp(name, "UD-8 Kayser")) {
1493 SDL_strlcpy(name, "Kayserstrahl", max_len);
1494 } else if (!strcmp(name, "UD-D Kayser")) {
1495 SDL_strlcpy(name, "Kayserstrahl", max_len);
1499 // ------------------------------------------------------------------
1500 // lcl_translate_brief_icon_name()
1502 // For displaying ship names in german version
1503 // since we cant actually just change them outright.
1505 void lcl_translate_brief_icon_name(char *name, const int max_len)
1510 if (!SDL_strcasecmp(name, "Subspace Portal")) {
1511 SDL_strlcpy(name, "Subraum Portal", max_len);
1513 } else if (!SDL_strcasecmp(name, "Alpha Wing")) {
1514 SDL_strlcpy(name, "Alpha", max_len);
1516 } else if (!SDL_strcasecmp(name, "Beta Wing")) {
1517 SDL_strlcpy(name, "Beta", max_len);
1519 } else if (!SDL_strcasecmp(name, "Zeta Wing")) {
1520 SDL_strlcpy(name, "Zeta", max_len);
1522 } else if (!SDL_strcasecmp(name, "Capella Node")) {
1523 SDL_strlcpy(name, "Capella", max_len);
1525 } else if (!SDL_strcasecmp(name, "Hostile")) {
1526 SDL_strlcpy(name, "Gegner", max_len);
1528 } else if (!SDL_strcasecmp(name, "Hostile Craft")) {
1529 SDL_strlcpy(name, "Gegner", max_len);
1531 } else if (!SDL_strcasecmp(name, "Rebel Wing")) {
1532 SDL_strlcpy(name, "Rebellen", max_len);
1534 } else if (!SDL_strcasecmp(name, "Rebel Fleet")) {
1535 SDL_strlcpy(name, "Rebellenflotte", max_len);
1537 } else if (!SDL_strcasecmp(name, "Sentry Gun")) {
1538 SDL_strlcpy(name, "Gesch\x81tz", max_len);
1540 } else if (!SDL_strcasecmp(name, "Cargo")) {
1541 SDL_strlcpy(name, "Fracht", max_len);
1543 } else if (!SDL_strcasecmp(name, "Knossos Device")) {
1544 SDL_strlcpy(name, "Knossosger\x84t", max_len);
1546 } else if (!SDL_strcasecmp(name, "Support")) {
1547 SDL_strlcpy(name, "Versorger", max_len);
1549 } else if (!SDL_strcasecmp(name, "Unknown")) {
1550 SDL_strlcpy(name, "Unbekannt", max_len);
1552 } else if (!SDL_strcasecmp(name, "Instructor")) {
1553 SDL_strlcpy(name, "Ausbilder", max_len);
1555 } else if (!SDL_strcasecmp(name, "Jump Node")) {
1556 SDL_strlcpy(name, "Sprungknoten", max_len);
1558 } else if (!SDL_strcasecmp(name, "Escort")) {
1559 SDL_strlcpy(name, "Geleitschutz", max_len);
1561 } else if (!SDL_strcasecmp(name, "Asteroid Field")) {
1562 SDL_strlcpy(name, "Asteroidenfeld", max_len);
1564 } else if (!SDL_strcasecmp(name, "Enif Station")) {
1565 SDL_strlcpy(name, "Station Enif", max_len);
1567 } else if (!SDL_strcasecmp(name, "Rally Point")) {
1568 SDL_strlcpy(name, "Sammelpunkt", max_len);
1570 } else if ((pos = strstr(name, "Transport")) != NULL) {
1571 pos += 9; // strlen of "transport"
1572 SDL_strlcpy(buf, "Transporter", sizeof(buf));
1573 SDL_strlcat(buf, pos, sizeof(buf));
1574 SDL_strlcpy(name, buf, max_len);
1576 } else if ((pos = strstr(name, "Jump Node")) != NULL) {
1577 pos += 9; // strlen of "jump node"
1578 SDL_strlcpy(buf, "Sprungknoten", sizeof(buf));
1579 SDL_strlcat(buf, pos, sizeof(buf));
1580 SDL_strlcpy(name, buf, max_len);
1582 } else if (!SDL_strcasecmp(name, "Orion under repair")) {
1583 SDL_strlcpy(name, "Orion wird repariert", max_len);
1585 // SOTY-specific ones below!
1587 } else if (!SDL_strcasecmp(name, "Wayfarer Station")) {
1588 SDL_strlcpy(name, "Station Wayfarer", max_len);
1589 } else if (!SDL_strcasecmp(name, "Enemy")) {
1590 SDL_strlcpy(name, "Gegner", max_len);
1591 } else if (!SDL_strcasecmp(name, "Supply Depot")) {
1592 SDL_strlcpy(name, "Nachschubdepot", max_len);
1593 } else if (!SDL_strcasecmp(name, "Fighter Escort")) {
1594 SDL_strlcpy(name, "Jagdschutz", max_len);
1595 } else if (!SDL_strcasecmp(name, "Shivans")) {
1596 SDL_strlcpy(name, "Shivaner", max_len);
1597 } else if (!SDL_strcasecmp(name, "NTF Base of Operations")) {
1598 SDL_strlcpy(name, "NTF-Operationsbasis", max_len);
1599 } else if (!SDL_strcasecmp(name, "NTF Bombers")) {
1600 SDL_strlcpy(name, "NTF-Bomber", max_len);
1601 } else if (!SDL_strcasecmp(name, "NTF Fighters")) {
1602 SDL_strlcpy(name, "NTF-J\x84ger", max_len);
1603 } else if (!SDL_strcasecmp(name, "Sentry")) {
1604 SDL_strlcpy(name, "Sperrgesch\x81tz", max_len);
1605 } else if (!SDL_strcasecmp(name, "Cargo Containers")) {
1606 SDL_strlcpy(name, "Frachtbeh\x84lter", max_len);
1607 } else if (!SDL_strcasecmp(name, "NTF Reinforcements")) {
1608 SDL_strlcpy(name, "NTF-Verst\x84rkungen", max_len);
1609 } else if (!SDL_strcasecmp(name, "NTF Base")) {
1610 SDL_strlcpy(name, "NTF-St\x81tzpunkt", max_len);
1611 } else if (!SDL_strcasecmp(name, "Refugee Convoy")) {
1612 SDL_strlcpy(name, "Fl\x81""chtlingskonvoi", max_len);
1613 } else if (!SDL_strcasecmp(name, "Food Convoy")) {
1614 SDL_strlcpy(name, "Nachschubkonvoi", max_len);
1615 } else if (!SDL_strcasecmp(name, "Governor's Shuttle")) {
1616 SDL_strlcpy(name, "F\x84hre des Gouverneurs", max_len);
1617 } else if (!SDL_strcasecmp(name, "GTVA Patrol")) {
1618 SDL_strlcpy(name, "GTVA-Patrouille", max_len);
1619 } else if (!SDL_strcasecmp(name, "Escort fighters")) {
1620 SDL_strlcpy(name, "Geleitschutz", max_len);
1621 } else if (!SDL_strcasecmp(name, "Nagada Outpost")) {
1622 SDL_strlcpy(name, "Nagada-Aussenposten", max_len);
1623 } else if (!SDL_strcasecmp(name, "Fighters")) {
1624 SDL_strlcpy(name, "J\x84ger", max_len);
1625 } else if (!SDL_strcasecmp(name, "Bombers")) {
1626 SDL_strlcpy(name, "Bomber", max_len);
1627 } else if (!SDL_strcasecmp(name, "Enemy Destroyers")) {
1628 SDL_strlcpy(name, "Feindliche Zerst\x94rer", max_len);
1629 } else if (!SDL_strcasecmp(name, "Ross 128 System")) {
1630 SDL_strlcpy(name, "System Ross 128", max_len);
1631 } else if (!SDL_strcasecmp(name, "Knossos Station")) {
1632 SDL_strlcpy(name, "Knossos-Station", max_len);
1633 } else if (!SDL_strcasecmp(name, "Transporters")) {
1634 SDL_strlcpy(name, "Transporter", max_len);
1635 } else if (!SDL_strcasecmp(name, "Pirates?")) {
1636 SDL_strlcpy(name, "Piraten?", max_len);
1637 } else if (!SDL_strcasecmp(name, "Escorts")) {
1638 SDL_strlcpy(name, "Geleitschutz", max_len);
1639 } else if (!SDL_strcasecmp(name, "Shivan Fighters")) {
1640 SDL_strlcpy(name, "J\x84ger", max_len);
1641 } else if (!SDL_strcasecmp(name, "Shivan Territory")) {
1642 SDL_strlcpy(name, "Shivaner", max_len);
1646 // ------------------------------------------------------------------
1647 // lcl_translate_brief_icon_name_pl()
1649 // For displaying ship names in polish version
1650 // since we cant actually just change them outright.
1652 void lcl_translate_brief_icon_name_pl(char *name, const int max_len)
1657 if (!SDL_strcasecmp(name, "Subspace Portal")) {
1658 SDL_strlcpy(name, "Portal podprz.", max_len);
1660 } else if (!SDL_strcasecmp(name, "Alpha Wing")) {
1661 SDL_strlcpy(name, "Alfa", max_len);
1663 } else if (!SDL_strcasecmp(name, "Beta Wing")) {
1664 SDL_strlcpy(name, "Beta", max_len);
1666 } else if (!SDL_strcasecmp(name, "Zeta Wing")) {
1667 SDL_strlcpy(name, "Zeta", max_len);
1669 } else if (!SDL_strcasecmp(name, "Capella Node")) {
1670 SDL_strlcpy(name, "Capella", max_len);
1672 } else if (!SDL_strcasecmp(name, "Hostile")) {
1673 SDL_strlcpy(name, "Wr\xF3g", max_len);
1675 } else if (!SDL_strcasecmp(name, "Hostile Craft")) {
1676 SDL_strlcpy(name, "Wr\xF3g", max_len);
1678 } else if (!SDL_strcasecmp(name, "Rebel Wing")) {
1679 SDL_strlcpy(name, "Rebelianci", max_len);
1681 } else if (!SDL_strcasecmp(name, "Rebel Fleet")) {
1682 SDL_strlcpy(name, "Flota Rebelii", max_len);
1684 } else if (!SDL_strcasecmp(name, "Sentry Gun")) {
1685 SDL_strlcpy(name, "Dzia\xB3o str.", max_len);
1687 } else if (!SDL_strcasecmp(name, "Cargo")) {
1688 SDL_strlcpy(name, "\xA3\x61\x64unek", max_len);
1690 } else if (!SDL_strcasecmp(name, "Knossos Device")) {
1691 SDL_strlcpy(name, "Urz. Knossos, max_len", max_len);
1693 } else if (!SDL_strcasecmp(name, "Support")) {
1694 SDL_strlcpy(name, "Wsparcie", max_len);
1696 } else if (!SDL_strcasecmp(name, "Unknown")) {
1697 SDL_strlcpy(name, "Nieznany", max_len);
1699 } else if (!SDL_strcasecmp(name, "Instructor")) {
1700 SDL_strlcpy(name, "Instruktor", max_len);
1702 } else if (!SDL_strcasecmp(name, "Jump Node")) {
1703 SDL_strlcpy(name, "W\xEAze\xB3 skokowy", max_len);
1705 } else if (!SDL_strcasecmp(name, "Escort")) {
1706 SDL_strlcpy(name, "Eskorta", max_len);
1708 } else if (!SDL_strcasecmp(name, "Asteroid Field")) {
1709 SDL_strlcpy(name, "Pole asteroid", max_len);
1711 } else if (!SDL_strcasecmp(name, "Enif Station")) {
1712 SDL_strlcpy(name, "Stacja Enif", max_len);
1714 } else if (!SDL_strcasecmp(name, "Rally Point")) {
1715 SDL_strlcpy(name, "Pkt zborny", max_len);
1717 } else if ((pos = strstr(name, "Transport")) != NULL) {
1718 pos += 9; // strlen of "transport"
1719 SDL_strlcpy(buf, "Transporter", sizeof(buf));
1720 SDL_strlcat(buf, pos, sizeof(buf));
1721 SDL_strlcpy(name, buf, max_len);
1723 } else if ((pos = strstr(name, "Jump Node")) != NULL) {
1724 pos += 9; // strlen of "jump node"
1725 SDL_strlcpy(buf, "W\xEAze\xB3 skokowy", sizeof(buf));
1726 SDL_strlcat(buf, pos, sizeof(buf));
1727 SDL_strlcpy(name, buf, max_len);
1729 } else if (!SDL_strcasecmp(name, "Orion under repair")) {
1730 SDL_strlcpy(name, "Naprawiany Orion", max_len);
1734 // ------------------------------------------------------------------
1735 // lcl_translate_ship_name()
1737 // For displaying ship names in german version in the briefing
1738 // since we cant actually just change them outright.
1740 void lcl_translate_ship_name(char *name, const int max_len)
1742 if (!strcmp(name, "GTDR Amazon Advanced")) {
1743 SDL_strlcpy(name, "GTDR Amazon VII", max_len);
1747 // ------------------------------------------------------------------
1748 // lcl_translate_targetbox_name()
1750 // For displaying ship names in german version in the targetbox
1751 // since we cant actually just change them outright.
1753 void lcl_translate_targetbox_name(char *name, const int max_len)
1758 if ((pos = strstr(name, "Sentry")) != NULL) {
1759 pos += 6; // strlen of "sentry"
1760 SDL_strlcpy(buf, "Sperrgesch\x81tz", sizeof(buf));
1761 SDL_strlcat(buf, pos, sizeof(buf));
1762 SDL_strlcpy(name, buf, max_len);
1764 } else if ((pos = strstr(name, "Support")) != NULL) {
1765 pos += 7; // strlen of "support"
1766 SDL_strlcpy(buf, "Versorger", sizeof(buf));
1767 SDL_strlcat(buf, pos, sizeof(buf));
1768 SDL_strlcpy(name, buf, max_len);
1770 } else if ((pos = strstr(name, "Unknown")) != NULL) {
1771 pos += 7; // strlen of "unknown"
1772 SDL_strlcpy(buf, "Unbekannt", sizeof(buf));
1773 SDL_strlcat(buf, pos, sizeof(buf));
1774 SDL_strlcpy(name, buf, max_len);
1776 } else if ((pos = strstr(name, "Drone")) != NULL) {
1777 pos += 5; // strlen of "drone"
1778 SDL_strlcpy(buf, "Drohne", sizeof(buf));
1779 SDL_strlcat(buf, pos, sizeof(buf));
1780 SDL_strlcpy(name, buf, max_len);
1782 } else if ((pos = strstr(name, "Jump Node")) != NULL) {
1783 pos += 9; // strlen of "jump node"
1784 SDL_strlcpy(buf, "Sprungknoten", sizeof(buf));
1785 SDL_strlcat(buf, pos, sizeof(buf));
1786 SDL_strlcpy(name, buf, max_len);
1788 } else if (!SDL_strcasecmp(name, "Instructor")) {
1789 SDL_strlcpy(name, "Ausbilder", max_len);
1791 } else if (!SDL_strcasecmp(name, "NTF Vessel")) {
1792 SDL_strlcpy(name, "NTF-Schiff", max_len);
1794 } else if (!SDL_strcasecmp(name, "Enif Station")) {
1795 SDL_strlcpy(name, "Station Enif", max_len);
1799 // ------------------------------------------------------------------
1800 // lcl_translate_targetbox_name_pl()
1802 // For displaying ship names in polish version in the targetbox
1803 // since we cant actually just change them outright.
1805 void lcl_translate_targetbox_name_pl(char *name, const int max_len)
1810 if ((pos = strstr(name, "Sentry")) != NULL) {
1811 pos += 6; // strlen of "sentry"
1812 SDL_strlcpy(buf, "Stra\xBFnik", sizeof(buf));
1813 SDL_strlcat(buf, pos, sizeof(buf));
1814 SDL_strlcpy(name, buf, max_len);
1816 } else if ((pos = strstr(name, "Support")) != NULL) {
1817 pos += 7; // strlen of "support"
1818 SDL_strlcpy(buf, "Wsparcie", sizeof(buf));
1819 SDL_strlcat(buf, pos, sizeof(buf));
1820 SDL_strlcpy(name, buf, max_len);
1822 } else if ((pos = strstr(name, "Unknown")) != NULL) {
1823 pos += 7; // strlen of "unknown"
1824 SDL_strlcpy(buf, "Nieznany", sizeof(buf));
1825 SDL_strlcat(buf, pos, sizeof(buf));
1826 SDL_strlcpy(name, buf, max_len);
1828 } else if ((pos = strstr(name, "Drone")) != NULL) {
1829 pos += 5; // strlen of "drone"
1830 SDL_strlcpy(buf, "Sonda", sizeof(buf));
1831 SDL_strlcat(buf, pos, sizeof(buf));
1832 SDL_strlcpy(name, buf, max_len);
1834 } else if ((pos = strstr(name, "Jump Node")) != NULL) {
1835 pos += 9; // strlen of "jump node"
1836 SDL_strlcpy(buf, "W\xEAze\xB3 skokowy", sizeof(buf));
1837 SDL_strlcat(buf, pos, sizeof(buf));
1838 SDL_strlcpy(name, buf, max_len);
1840 } else if (!SDL_strcasecmp(name, "Instructor")) {
1841 SDL_strlcpy(name, "Instruktor", max_len);
1843 } else if (!SDL_strcasecmp(name, "NTF Vessel")) {
1844 SDL_strlcpy(name, "Okr\xEAt NTF", max_len);
1846 } else if (!SDL_strcasecmp(name, "Enif Station")) {
1847 SDL_strlcpy(name, "Stacja Enif", max_len);