Hey, i’m trying to change my translations on runti...
# compose
a
Hey, i’m trying to change my translations on runtime and i looked into lyricist which looks quite promising. I think it should be somehow possible to override the lyricist variable which according to the samples is defined in MainActivity. I’m just not able figure out how to do this, since rememberStrings() needs a compose context and i’m not in a compose context when i want to react on some newly downloaded json. Maybe someone could give me push into the right direction 🙂
In the end it was mostly missing the key on the remember function. Lyricist uses this function for remembering Lyricist
Copy code
@Composable
public fun <T> rememberStrings(
    translations: Map<LanguageTag, T>,
    defaultLanguageTag: LanguageTag = "en",
    currentLanguageTag: LanguageTag = Locale.current.toLanguageTag()
): Lyricist<T> =
    remember(defaultLanguageTag) {
        Lyricist(defaultLanguageTag, translations)
    }.apply {
        languageTag = currentLanguageTag
    }
add my own function for this with translations as key on the remember call
Copy code
@Composable
public fun <T> rememberStrings(
    translations: Map<LanguageTag, T>,
    defaultLanguageTag: LanguageTag = "en",
    currentLanguageTag: LanguageTag = Locale.current.toLanguageTag()
): Lyricist<T> =
    remember(translations) {
        Lyricist(defaultLanguageTag, translations)
    }.apply {
        languageTag = currentLanguageTag
    }