diff --git a/games/devtest/mods/unittests/init.lua b/games/devtest/mods/unittests/init.lua index edba2c3d2a8aa..f3738c41c8a78 100644 --- a/games/devtest/mods/unittests/init.lua +++ b/games/devtest/mods/unittests/init.lua @@ -182,6 +182,7 @@ dofile(modpath .. "/get_version.lua") dofile(modpath .. "/itemstack_equals.lua") dofile(modpath .. "/content_ids.lua") dofile(modpath .. "/metadata.lua") +dofile(modpath .. "/translations.lua") -------------- diff --git a/games/devtest/mods/unittests/locale/unittests.de.tr b/games/devtest/mods/unittests/locale/unittests.de.tr new file mode 100644 index 0000000000000..e79e5feefee7c --- /dev/null +++ b/games/devtest/mods/unittests/locale/unittests.de.tr @@ -0,0 +1,5 @@ +# textdomain: unittests +# Note that the "translations" here are only for testing; it is not necessary +# to actually translate any text here. +Only in primary language.=Result in primary language. +Available in both languages.=Result in primary language. diff --git a/games/devtest/mods/unittests/locale/unittests.fr.tr b/games/devtest/mods/unittests/locale/unittests.fr.tr new file mode 100644 index 0000000000000..efde0ab6ef777 --- /dev/null +++ b/games/devtest/mods/unittests/locale/unittests.fr.tr @@ -0,0 +1,5 @@ +# textdomain: unittests +# Note that the "translations" here are only for testing; it is not necessary +# to actually translate any text here. +Only in secondary language.=Result in secondary language. +Available in both languages.=Result in secondary language. diff --git a/games/devtest/mods/unittests/translations.lua b/games/devtest/mods/unittests/translations.lua new file mode 100644 index 0000000000000..8bcfdf70a11f3 --- /dev/null +++ b/games/devtest/mods/unittests/translations.lua @@ -0,0 +1,13 @@ +local S = core.get_translator("unittests") + +local function test_server_translation() + local function translate(str) + return core.get_translated_string("de:fr", S(str)) + end + local RESULT_PRIMARY = "Result in primary language." + local RESULT_SECONDARY = "Result in secondary language." + assert(translate("Only in primary language.") == RESULT_PRIMARY, "missing translation for primary language") + assert(translate("Only in secondary language.") == RESULT_SECONDARY, "missing translation for secondary language") + assert(translate("Available in both languages.") == RESULT_PRIMARY, "incorrect translation priority list applied") +end +unittests.register("test_server_translation", test_server_translation)