-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How would I do Intl.message in this system? #24
Comments
I think the way you would need to do this in the current system is with the annotation, yes. I would opt for a variant of the first solution probably, something like this: @IntlMessage(r'text with $a and $b', 'arbitrary example', {'a': 'thing one', 'b': 'thing two'})
external String foo(String a, String b); We are considering allowing statement level macros also, which would be a bit nicer, possibly allowing something like this: String foo(String a, String b) =>
intlMessage('text with $a and $b', 'arbitrary example', {'a': 'thing one', 'b': thing two'}); The advantage would be allowing you to use the actual string interpolation in the user code instead of a weird raw string. This |
Statement level macros would fix a lot of the limitations I see with the current approach. Glad it's being considered! |
Yes, the statement level macros does sound very promising. And more like what "macro" means in other systems. |
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.
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
@intlMessage(['a', 'b'], r'text with $a and $b', 'arbitrary example', {'a': 'thing one', 'b': thing two'}
or
which would then produce
foo
. Neither of these seems great.The text was updated successfully, but these errors were encountered: