mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-23 06:08:46 +07:00
Add unit test for unique translation template keys (#7557)
This commit is contained in:

committed by
GitHub

parent
64e79ffa0d
commit
53d18095ee
@ -126,6 +126,28 @@ class TranslationTests {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun allTranslationsHaveUniquePlaceholders() {
|
||||
// check that the templates have unique placeholders (the translation entries are checked below)
|
||||
val templateLines = Gdx.files.internal(TranslationFileWriter.templateFileLocation).reader().readLines()
|
||||
var noTwoPlaceholdersAreTheSame = true
|
||||
for (template in templateLines) {
|
||||
if (template.startsWith("#")) continue
|
||||
val placeholders = squareBraceRegex.findAll(template)
|
||||
.map { it.value }.toList()
|
||||
|
||||
for (placeholder in placeholders)
|
||||
if (placeholders.count { it == placeholder } > 1) {
|
||||
noTwoPlaceholdersAreTheSame = false
|
||||
println("Template key $template has the parameter $placeholder more than once")
|
||||
break
|
||||
}
|
||||
}
|
||||
Assert.assertTrue(
|
||||
"This test will only pass when no translation template keys have the same parameter twice",
|
||||
noTwoPlaceholdersAreTheSame)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun noTwoPlaceholdersAreTheSame() {
|
||||
var noTwoPlaceholdersAreTheSame = true
|
||||
|
Reference in New Issue
Block a user