From 3448eab2d3b3bb3e2f6635e254eb29b5ddfc9e02 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sat, 23 Oct 2021 14:50:01 +0100 Subject: [PATCH] Translations: Restore support for ".mo" files Note that they now need to go into the "assets/" subdirectory of the build directory. --- Source/utils/language.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Source/utils/language.cpp b/Source/utils/language.cpp index cbdc1967a..476132d0b 100644 --- a/Source/utils/language.cpp +++ b/Source/utils/language.cpp @@ -266,9 +266,16 @@ bool HasTranslation(const std::string &locale) void LanguageInitialize() { - std::string filename = sgOptions.Language.szCode; - filename.append(".gmo"); - SDL_RWops *rw = SFileOpenRw(filename.c_str()); + const std::string lang = sgOptions.Language.szCode; + SDL_RWops *rw; + + // Translations normally come in ".gmo" files. + // We also support ".mo" because that is what poedit generates + // and what translators use to test their work. + for (const char *ext : { ".mo", ".gmo" }) { + if ((rw = SFileOpenRw((lang + ext).c_str())) != nullptr) + break; + } if (rw == nullptr) return;