package app.revanced.util import java.io.File /** * Comments out the non-standard and tags. * * Previously this was done on Crowdin after pushing. * But Crowdin preprocessing has randomly failed but still used the unmodified * strings.xml file, which effectively deletes all patch strings from Crowdin. */ internal fun main(args: Array) { if (args.size != 2) { throw RuntimeException("Exactly two arguments are required: ") } val inputFilePath = args[0] val inputFile = File(inputFilePath) if (!inputFile.exists()) { throw RuntimeException( "Input file not found: $inputFilePath currentDirectory: " + File(".").canonicalPath ) } // Comment out the non-standard tags. Otherwise Crowdin interprets the file // not as Android but instead a generic xml file where strings are // identified by xml position and not key. val content = inputFile.readText() val tagRegex = """(()|()|()|())""".toRegex() val modifiedContent = content.replace(tagRegex, """""") // Write modified content to the output file (creates file if it doesn't exist). val outputFilePath = args[1] val outputFile = File(outputFilePath) outputFile.parentFile?.mkdirs() outputFile.writeText(modifiedContent) println("Preprocessed strings.xml to: $outputFilePath") }