From 4f498fba9865c738c3bf8662a417bbeb342b17e7 Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 6 May 2018 12:27:37 +0100 Subject: [PATCH] Bug fix for allowing language to be specified. --- src/galaxy/starSystems.h | 1 + src/main.c | 4 ++-- src/system/i18n.c | 7 ++++++- src/system/i18n.h | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/galaxy/starSystems.h b/src/galaxy/starSystems.h index 75e2341..b51091e 100644 --- a/src/galaxy/starSystems.h +++ b/src/galaxy/starSystems.h @@ -28,5 +28,6 @@ extern int isMissionAvailable(Mission *mission, Mission *prev); extern char **getFileList(char *dir, int *count); extern Mission *loadMissionMeta(char *filename); extern int getJSONValue(cJSON *node, char *name, int defValue); +extern char *getTranslatedString(char *string); extern Game game; diff --git a/src/main.c b/src/main.c index f0d0f01..2bd273c 100644 --- a/src/main.c +++ b/src/main.c @@ -240,9 +240,9 @@ static void handleMissionArgs(int argc, char *argv[]) for (i = 1 ; i < argc ; i++) { /* assume this is filename for testing */ - if (argv[i][0] != '-') + if (strcmp(argv[i], "-mission") == 0) { - loadTestMission(argv[i]); + loadTestMission(argv[++i]); testingMission = 1; } diff --git a/src/system/i18n.c b/src/system/i18n.c index 7199526..6717c5e 100644 --- a/src/system/i18n.c +++ b/src/system/i18n.c @@ -75,8 +75,13 @@ void setLanguage(char *applicationName, char *languageCode) strtok(language, "."); SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Locale is %s", language); + + sprintf(c, "locale/%s.mo", language); - sprintf(c, "%s/%s/LC_MESSAGES/%s.mo", LOCALE_DIR, language, applicationName); + if (!fileExists(c)) + { + sprintf(c, "%s/%s/LC_MESSAGES/%s.mo", LOCALE_DIR, language, applicationName); + } #if DEV == 1 printf("Opening %s\n", c); diff --git a/src/system/i18n.h b/src/system/i18n.h index d73d04f..7fe037f 100644 --- a/src/system/i18n.h +++ b/src/system/i18n.h @@ -28,3 +28,4 @@ Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. char *getTranslatedString(char *); void setLanguage(char *, char *); void cleanupLanguage(void); +extern int fileExists(char *filename);