-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
One of the long-standing irritations in Intl is the redundant information that has to be passed. e.g. a simple call ooks like
String foo(String a, String b) => Intl.message('text with $a and $b', desc: 'arbitrary example', name: 'foo', args: [a, b], examples: const {'a': 'thing one', 'b': 'thing two'});
This is processed in two phases.
- There's a build(-ish) time extraction that parses the text and extracts the information for translators. The description and examples are only used at this time, and even the main text is only used at this time for production purposes. In development it's also used before any translations are available.
- At runtime the name is required as a lookup key for the translation text to use, and the args are required so that they can be interpolated into the translated text. This information is already available in the function definition, but not at run-time.
With transformers, developers could omit name and args and have them filled in automatically. It would be nice to be able to do the same with macros. So it seems like
- An additional annotation for each message? Or is it possible to run a class-level or library level macro that would find all the messages within it.
- More significantly, it's not clear to me how I could provide additional arguments into a method body. I haven't tried to implement it, just looked over the documentation, but I don't see a mechanism, and I don't see a mechanical rewrite that would fix it. About the only thing I can see is if you rewrote the whole statement into an annotation (can these anootations have parameters or a declaration that would be disregarded, e.g.
@intlMessage(['a', 'b'], r'text with $a and $b', 'arbitrary example', {'a': 'thing one', 'b': thing two'}
or
@intlMessage
String _payNoAttentionTofoo(String a, String b) => Intl.message('text with $a and $b', desc: 'arbitrary example', examples: const {'a': 'thing one', 'b': 'thing two'});
which would then produce foo. Neither of these seems great.
munificent
Metadata
Metadata
Assignees
Labels
No labels