Marcel
10/08/2024, 8:09 PMMuaz KADAN
10/10/2024, 4:04 AM@OptIn(ExperimentalResourceApi::class)
object SharedStrings {
private val stringResources: Map<String, StringResource> = Res.allStringResources
private val scope = CoroutineScope(<http://Dispatchers.IO|Dispatchers.IO>)
private val loadedStrings = mutableMapOf<String, String>()
fun get(key: String): String {
return loadedStrings[key] ?: scope.async {
val resource = stringResources[key]
if (resource != null) {
val localizedString = getString(resource)
loadedStrings[key] = localizedString
localizedString
} else {
key
}
}.let { runBlocking { it.await() } }
}
}
but I ended up not using it 😄Marcel
10/10/2024, 7:18 AMMuaz KADAN
10/10/2024, 7:53 AMMarcel
10/10/2024, 7:56 AM