From 0ea09361561a96e8dc960be954fee5d1c0e88e90 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 22 May 2015 14:14:02 +0200 Subject: [PATCH] Use default locale when missing a translation, only warn once. https://bugs.eressea.de/view.php?id=2103 remove locale::fallback, it was never set anyhow (also, we have no good fallbacks). --- src/util/language.c | 9 +++++++-- src/util/language_struct.h | 1 - 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/util/language.c b/src/util/language.c index 79697f95f..9409ab3c7 100644 --- a/src/util/language.c +++ b/src/util/language.c @@ -153,8 +153,13 @@ const char *locale_string(const locale * lang, const char *key, bool warn) if (warn) { log_warning("missing translation for \"%s\" in locale %s\n", key, lang->name); } - if (lang->fallback) { - return locale_string(lang->fallback, key, warn); + if (default_locale && lang != default_locale) { + const char * value = locale_string(default_locale, key, warn); + if (value) { + /* TODO: evil side-effects for a const function */ + locale_setstring(get_or_create_locale(lang->name), key, value); + } + return value; } } return 0; diff --git a/src/util/language_struct.h b/src/util/language_struct.h index 84932532e..7caad74af 100644 --- a/src/util/language_struct.h +++ b/src/util/language_struct.h @@ -19,7 +19,6 @@ typedef struct locale { struct locale *next; unsigned int hashkey; struct locale_str *strings[SMAXHASH]; - struct locale *fallback; } locale; extern locale *default_locale;