mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-10-26 14:24:40 +00:00
New gradle task to help translators
* The new gradle task "checkTranslations" creates reports on missing/extra lang file entries for all language files * It is not included in the normal build process and must be run by hand * The reports are gitgnore'ed
This commit is contained in:
1 parent
4a4077a50b
commit
6ca97cead6
2 files changed
+34
No files matched your search
@@ -167,3 +167,35 @@ curse {
|
||||
changelog = System.getenv("CHANGELOG").equals("none") ? getChangelogText() : System.getenv("CHANGELOG")
|
||||
releaseType = project.hasProperty('mod_appendix') ? "${mod_appendix}".toString() : 'release'
|
||||
}
|
||||
|
||||
task checkTranslations << {
|
||||
Map<String, String> mapen = new HashMap<String, String>()
|
||||
(new File('resources/assets/enderio/lang/en_US.lang')).eachLine {
|
||||
def (value1, value2) = it.tokenize( '=' )
|
||||
if (value1 == null || value2 == null) {return}
|
||||
mapen.put(value1, value2)
|
||||
}
|
||||
|
||||
new File('resources/assets/enderio/lang/').eachFileMatch( ~".*\\.lang\$" ) { langfile ->
|
||||
if (!langfile.getName().contains("en_US")) {
|
||||
Map<String, String> map = new HashMap<String, String>()
|
||||
File outfile = new File("${langfile}.txt")
|
||||
Writer outwriter = outfile.newWriter("UTF8")
|
||||
outwriter.write("\n// Additional translations:\n")
|
||||
outwriter << langfile.filterLine {
|
||||
def (value1, value2) = it.tokenize( '=' )
|
||||
if (value1 == null || value2 == null) {return false}
|
||||
map.put(value1, value2)
|
||||
return !mapen.containsKey(value1)
|
||||
}
|
||||
|
||||
outwriter.append("\n// Missing translations:\n")
|
||||
for (e in mapen) {
|
||||
if (!map.containsKey(e.key)) {
|
||||
outwriter.append(e.key + "=" + e.value + "\n")
|
||||
}
|
||||
}
|
||||
println "Created translation report ${outfile}"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user