Handle newlines better in the strings.xml

This commit is contained in:
Syer10
2021-07-13 14:24:05 -04:00
parent 9b362a1777
commit 44a89bb1d1

View File

@@ -49,15 +49,17 @@ class XmlResourceBundle internal constructor(internal val lookup: ConcurrentHash
return XmlResourceBundle(ConcurrentHashMap(lookup + other.lookup))
}
private fun String.replaceAndroid() = replace("\\n", "%n")
fun getStringA(key: String): String {
return Formatter().format(getString(key))
return Formatter().format(getString(key).replaceAndroid())
.let { formatter ->
formatter.toString().also { formatter.close() }
}
}
fun getString(key: String, vararg replacements: Any?): String {
return Formatter().format(getString(key), *replacements)
return Formatter().format(getString(key).replaceAndroid(), *replacements)
.let { formatter ->
formatter.toString().also { formatter.close() }
}