Polish localization support (#414)
This commit is contained in:
parent
a826a16d75
commit
20e81f46ff
|
@ -8,6 +8,7 @@
|
|||
#include "globvrpb.h"
|
||||
#include "graphics.h"
|
||||
#include "harness/config.h"
|
||||
#include "harness/hooks.h"
|
||||
#include "harness/trace.h"
|
||||
#include "input.h"
|
||||
#include "loading.h"
|
||||
|
@ -292,7 +293,7 @@ char* GetALineWithNoPossibleService(FILE* pF, unsigned char* pS) {
|
|||
if (ch != -1) {
|
||||
ungetc(ch, pF);
|
||||
}
|
||||
} while (!isalnum(s[0])
|
||||
} while (!Harness_Hook_isalnum(s[0])
|
||||
&& s[0] != '-'
|
||||
&& s[0] != '.'
|
||||
&& s[0] != '!'
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "platforms/null.h"
|
||||
#include "version.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -95,6 +96,9 @@ static void Harness_DetectGameMode(void) {
|
|||
if (strstr(buffer, "NEUES SPIEL") != NULL) {
|
||||
harness_game_info.localization = eGameLocalization_german;
|
||||
LOG_INFO("Language: \"%s\"", "German");
|
||||
} else if (strstr(buffer, "NOWA GRA") != NULL) {
|
||||
harness_game_info.localization = eGameLocalization_polish;
|
||||
LOG_INFO("Language: \"%s\"", "Polish");
|
||||
} else {
|
||||
LOG_INFO("Language: unrecognized");
|
||||
}
|
||||
|
@ -285,3 +289,19 @@ int Harness_ProcessCommandLine(int* argc, char* argv[]) {
|
|||
FILE* Harness_Hook_fopen(const char* pathname, const char* mode) {
|
||||
return OS_fopen(pathname, mode);
|
||||
}
|
||||
|
||||
// Localization
|
||||
int Harness_Hook_isalnum(int c)
|
||||
{
|
||||
if (harness_game_info.localization == eGameLocalization_polish) {
|
||||
// Polish diacritic letters in Windows-1250
|
||||
unsigned char letters[] = { 140, 143, 156, 159, 163, 165, 175, 179, 185, 191, 198, 202, 209, 211, 230, 234, 241, 243 };
|
||||
for (int i = 0; i < (int)sizeof(letters); i++) {
|
||||
if ((unsigned char)c == letters[i]) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return isalnum(c);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ typedef enum tHarness_game_type {
|
|||
typedef enum {
|
||||
eGameLocalization_none,
|
||||
eGameLocalization_german,
|
||||
eGameLocalization_polish,
|
||||
} tHarness_game_localization;
|
||||
|
||||
typedef struct tHarness_game_info {
|
||||
|
|
|
@ -45,4 +45,7 @@ void Harness_Init(int* argc, char* argv[]);
|
|||
// Filesystem hooks
|
||||
FILE* Harness_Hook_fopen(const char* pathname, const char* mode);
|
||||
|
||||
// Localization
|
||||
int Harness_Hook_isalnum(int c);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue