From d669b0a3bd3f180e4bdba882a53ef5e853508cb6 Mon Sep 17 00:00:00 2001 From: y5nw <37980625+y5nw@users.noreply.github.com> Date: Mon, 24 Feb 2025 15:45:21 +0100 Subject: [PATCH] Add multilang test to testtranslations --- games/devtest/mods/testtranslations/init.lua | 12 +++++++++++- .../testtranslations/locale/translation_po.fr.po | 8 ++++++++ .../testtranslations/locale/translation_po.fr_CH.po | 3 +++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 games/devtest/mods/testtranslations/locale/translation_po.fr_CH.po diff --git a/games/devtest/mods/testtranslations/init.lua b/games/devtest/mods/testtranslations/init.lua index a2de998a21..79af80a9f7 100644 --- a/games/devtest/mods/testtranslations/init.lua +++ b/games/devtest/mods/testtranslations/init.lua @@ -5,12 +5,18 @@ local function send_compare(name, text) core.get_translated_string("", text), text, core.get_translated_string("fr", text))) end +local function send_multilang_compare(name, text) + core.chat_send_player(name, ("%s | %s | %s | %s"):format( + core.get_translated_string("", text), text, + core.get_translated_string("fr_CH:fr", text), core.get_translated_string("fr:fr_CH", text))) +end + core.register_chatcommand("testtranslations", { params = "", description = "Test translations", privs = {}, func = function(name, param) - core.chat_send_player(name, "Please ensure your locale is set to \"fr\"") + core.chat_send_player(name, "Please ensure your locale is set to \"fr_CH\"") core.chat_send_player(name, "Untranslated | Client-side translation | Server-side translation (fr)") send_compare(name, S("Testing .tr files: untranslated")) send_compare(name, S("Testing .po files: untranslated")) @@ -22,5 +28,9 @@ core.register_chatcommand("testtranslations", { send_compare(name, NS("@1: .po singular", "@1: .po plural", i, tostring(i))) send_compare(name, NS("@1: .mo singular", "@1: .mo plural", i, tostring(i))) end + core.chat_send_player(name, "Untranslated | Client-side translations" .. + " | Server-side translation (fr_CH:fr) | Server-side translation (fr:fr_CH)") + send_multilang_compare(name, S("Testing translation with multiple languages")) + send_multilang_compare(name, S("Testing French-only translation: untranslated")) end }) diff --git a/games/devtest/mods/testtranslations/locale/translation_po.fr.po b/games/devtest/mods/testtranslations/locale/translation_po.fr.po index 5aefc0f414..4f68cb3718 100644 --- a/games/devtest/mods/testtranslations/locale/translation_po.fr.po +++ b/games/devtest/mods/testtranslations/locale/translation_po.fr.po @@ -20,3 +20,11 @@ msgstr "Testing fuzzy .po entry: translated (wrong)" msgid "Testing .po without context: untranslated" msgstr "Testing .po without context: translated" + +msgctxt "testtranslations" +msgid "Testing translation with multiple languages" +msgstr" Testing translation: translated in standard French" + +msgctxt "testtranslations" +msgid "Testing French-only translation: untranslated" +msgstr "Testing French-only translation: translated" diff --git a/games/devtest/mods/testtranslations/locale/translation_po.fr_CH.po b/games/devtest/mods/testtranslations/locale/translation_po.fr_CH.po new file mode 100644 index 0000000000..a2cc8b1216 --- /dev/null +++ b/games/devtest/mods/testtranslations/locale/translation_po.fr_CH.po @@ -0,0 +1,3 @@ +msgctxt "testtranslations" +msgid "Testing translation with multiple languages" +msgstr "Testing translation: translated in Swiss French"