From 56654663f5dd1fe460fb9a8a2f7de1b0c83d465c Mon Sep 17 00:00:00 2001 From: Heiko Hund Date: Thu, 26 Jul 2012 08:57:27 +0200 Subject: [PATCH] fall back to English resource if string is missing --- localization.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/localization.c b/localization.c index 1fffac2..8447073 100644 --- a/localization.c +++ b/localization.c @@ -106,12 +106,12 @@ LoadStringLang(UINT stringId, LANGID langId, PTSTR buffer, int bufferSize, va_li /* find resource block for string */ HRSRC res = FindResourceLang(RT_STRING, resBlockId, langId); if (res == NULL) - return 0; + goto err; /* get pointer to first entry in resource block */ entry = (PWCH) LoadResource(o.hInstance, res); if (entry == NULL) - return 0; + goto err; /* search for string in block */ for (int i = 0; i < 16; i++) @@ -140,6 +140,11 @@ LoadStringLang(UINT stringId, LANGID langId, PTSTR buffer, int bufferSize, va_li return _tcslen(buffer); } +err: + /* not found, try again with the default language */ + if (langId != fallbackLangId) + return LoadStringLang(stringId, fallbackLangId, buffer, bufferSize, args); + return 0; }