-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unittests for server-side translations
- Loading branch information
Showing
4 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |