RemafoX icon indicating copy to clipboard operation
RemafoX copied to clipboard

[Feat] Support for LocalizedStringResource

Open ConfusedVorlon opened this issue 1 year ago • 1 comments

Problem Statement

AppIntents require LocalizedStringResource These are essentially lazily loaded localized strings The ergonomics are painful though.

static var title: LocalizedStringResource = LocalizedStringResource("Intent.AskMeAnything") but to use code, I need to use

static var title: LocalizedStringResource = LocalizedStringResource(String.LocalizationValue(stringLiteral: Loc.Intent.AskChatter.tableLookupKey))

Suggested Solution

provide a generated localizedStringResource variable on the enum (or similar)

Additional Considerations

I mentioned before that the generated file could be WAY smaller if it just used a protocol with automated conformance. (at least for simple singular strings) Even more so if there is another property in play.

ConfusedVorlon avatar Apr 03 '23 18:04 ConfusedVorlon

@ConfusedVorlon Thank you for requesting this feature.

When I worked on the generated file, the LocalizedStringResource type wasn't released yet, therefore I didn't figure out if and how it could be included. But it makes sense to support them in the generated file. I will also consider moving to a protocol-based file. As I wrote before, the one thing I need to verify is that auto-completion works just as reliably as with the non-protocol style that I ship currently. If it doesn't, I think I will at least default to the current expanded style but might still provide an option to opt for the protocol instead. Mostly because it's generated code anyways, so it shouldn't really matter how long the file is, developers shouldn't really care about its contents. But as I can see, some still do, so I'll consider it for sure. 😉

Jeehut avatar Apr 04 '23 00:04 Jeehut