From 6377fd5e734550eb03e64e5fcc17f449d24ff194 Mon Sep 17 00:00:00 2001 From: Dav999 Date: Fri, 8 Dec 2023 02:05:24 +0100 Subject: [PATCH] Make language sync support creating blank language files Two translators thus far have tried to populate initial language files by creating a blank folder and then using the in-game sync option. For example, see #1078. That is not how the sync option was intended to be used, but it's really close to getting everything, so I decided to just complete the support by making sure numbers.xml is copied from English, and making sure meta.xml is filled in with English text and not text from an arbitrary language. Also, minor detail on plural form 1 being set to 1 by default if reset, so strings_plural.xml is fully consistent too. --- desktop_version/src/LocalizationMaint.cpp | 11 +++++++++++ desktop_version/src/LocalizationStorage.cpp | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/desktop_version/src/LocalizationMaint.cpp b/desktop_version/src/LocalizationMaint.cpp index 6ce4f34d..35f54761 100644 --- a/desktop_version/src/LocalizationMaint.cpp +++ b/desktop_version/src/LocalizationMaint.cpp @@ -177,6 +177,17 @@ static void sync_lang_file(const std::string& langcode) FILESYSTEM_saveTiXml2Document((langcode + "/strings.xml").c_str(), doc); } + if (!load_lang_doc("numbers", doc, langcode)) + { + /* If numbers.xml doesn't exist _at all_, then simply copy it from English, + * so that you can make a new translation simply by making a folder and syncing. */ + + if (load_lang_doc("numbers", doc, "en")) + { + FILESYSTEM_saveTiXml2Document((langcode + "/numbers.xml").c_str(), doc); + } + } + if (load_lang_doc("strings_plural", doc, "en")) { /* Form 255 is technically invalid, but we have to account for it */ diff --git a/desktop_version/src/LocalizationStorage.cpp b/desktop_version/src/LocalizationStorage.cpp index faa323be..a670a995 100644 --- a/desktop_version/src/LocalizationStorage.cpp +++ b/desktop_version/src/LocalizationStorage.cpp @@ -59,6 +59,10 @@ static void loadmeta(LangMeta& meta, const std::string& langcode = lang) { meta.active = true; meta.code = langcode; + meta.nativename = langcode; + meta.credit = ""; + meta.action_hint = "Press Space, Z, or V to select"; + meta.gamepad_hint = "Press {button} to select"; meta.autowordwrap = true; meta.toupper = true; meta.toupper_i_dot = false; @@ -238,6 +242,7 @@ void resettext(bool final_shutdown) number[i] = ""; } SDL_zeroa(number_plural_form); + number_plural_form[1] = 1; SDL_zeroa(translation_roomnames); SDL_zeroa(explanation_roomnames);