Skip to content

How to load a localized string resource from a string #856

Description

@buttifabio

Question
Is it possibile to load a localized string without using the autogenerated MR.strings directly?
It would be nice to be able to do it directly in commonMain.

Use case
I have a fixed list of items with descriptions which are already localized in app and I receive the localization key from remote (API or push notification) and I would like to load the localized String.

Example
I have itemX_description key localizable from commonMain using MR.strings.itemX_description.localized().
From an API i receive the key itemY_description and I would like to retrieve the corresponding localized String but I can't find a way to easily do it.
I tried with StringDesc.Raw("itemY_description").toString(LocalContext.current) in a JetpackCompose environment but it returns simply itemY_description so I don't think the Raw path is the right one.
Should I use StringDesc.Resource but how can I convert my string to the StringResource?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions