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).
This commit is contained in:
Enno Rehling 2015-05-22 14:14:02 +02:00
parent 7a65658cc5
commit 0ea0936156
2 changed files with 7 additions and 3 deletions

View File

@ -153,8 +153,13 @@ const char *locale_string(const locale * lang, const char *key, bool warn)
if (warn) { if (warn) {
log_warning("missing translation for \"%s\" in locale %s\n", key, lang->name); log_warning("missing translation for \"%s\" in locale %s\n", key, lang->name);
} }
if (lang->fallback) { if (default_locale && lang != default_locale) {
return locale_string(lang->fallback, key, warn); 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; return 0;

View File

@ -19,7 +19,6 @@ typedef struct locale {
struct locale *next; struct locale *next;
unsigned int hashkey; unsigned int hashkey;
struct locale_str *strings[SMAXHASH]; struct locale_str *strings[SMAXHASH];
struct locale *fallback;
} locale; } locale;
extern locale *default_locale; extern locale *default_locale;