Use GitHub Action to check for missing translations (#1019)

* Use GitHub Action to check for missing translations

* fix: missing translations

* fix: Traditional Chinese in I18N_zh_CN

* fix: I18N_zh
This commit is contained in:
Glavo
2021-09-11 14:39:55 +08:00
committed by GitHub
parent 4ace33bd80
commit 513897406d
5 changed files with 106 additions and 2 deletions

View File

@@ -122,4 +122,37 @@ task 'preTouchOpenJFXDependencies' {
}
}
}
}
task 'checkTranslations' {
group 'verification'
doLast {
var en = new Properties()
var zh = new Properties()
var zh_CN = new Properties()
file("HMCL/src/main/resources/assets/lang/I18N.properties").withInputStream { en.load(it) }
file("HMCL/src/main/resources/assets/lang/I18N_zh.properties").withInputStream { zh.load(it) }
file("HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties").withInputStream { zh_CN.load(it) }
boolean success = true
zh_CN.forEach { k, v ->
if (!en.containsKey(k)) {
project.logger.log(LogLevel.WARN, "I18N.properties missing key '$k'")
success = false
}
}
zh_CN.forEach { k, v ->
if (!zh.containsKey(k)) {
project.logger.log(LogLevel.WARN, "I18N_zh.properties missing key '$k'")
success = false
}
}
if (!success) {
throw new GradleException("Part of the translation is missing")
}
}
}