-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Qute type-safe messages - change the default bundle name strategy #31299
Qute type-safe messages - change the default bundle name strategy #31299
Conversation
FYI @FroMage. This PR does not solve your problem but it's a first step ;-). |
🙈 The PR is closed and the preview is expired. |
4fa1221
to
a253656
Compare
Marked as a breaking change because previously the default name |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, I left comment rather out of curiosity whether you know something I don't...
extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/MessageBundleProcessor.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's me, but I find it difficult to use {msg_Views_Index:hello(name)}
in a template.
Here is a suggestion: Would it make sense to use just {msg:hello(name)}
in the template and the resolver perform the Message Bundle lookup based on the same strategy you're proposing here?
You're not the only one - Stef has the same complaints ;-).
There are few problems with this proposal.
That said, it's probably doable but (1) not so easy, (2) I'd prefer to introduce a more general solution (maybe something like "local namespace aliases"?). So this PR is not a final solution but a first step to make it easier to use multiple nested message bundles in your app. |
- use an approach similar to type-safe templates - the default bundle name of a nested class starts with "msg" and includes the simple names of all declaring classes in the hierarchy
a253656
to
709b87b
Compare
✔️ The latest workflow run for the pull request has completed successfully. It should be safe to merge provided you have a look at the other checks in the summary. |
@gastaldi Like I mentioned in the quarkiverse/quarkus-renarde#3 (comment) - I think that a workaround is to use the generated message bundle impl directly (i.e. do not use the namespace at all). |
Errr, the given example is not idiomatic, at least in the case of Renarde. This would be: public class Controller {
@CheckedTemplate
static class Templates {
static native TemplateInstance index(String name);
}
} I'm not sure what the The suggestion I made was rather to group messages in the same class name as the template: public class Controller {
@CheckedTemplate
static class Templates {
static native TemplateInstance index(String name);
@MessageBundle
static class index {
@Message
String greeting();
}
}
} |
But this would result in the bundle name TBH I don't like any of these "nested" proposals. It's a mess... anyway, it's not set in stone yet! So we can definitely change/revert the behavior. |
Well, ideally it'd result in The alternative, to still group messages by view, is: public class Controller {
@CheckedTemplate
static class Templates {
static native TemplateInstance index(String name);
}
@MessageBundle
static class index {
@Message
String greeting();
}
} |
Ok, we could just take all the classes in the hierarchy and do not add the I.e. you would then use @FroMage WDYT? |
For example, the default bundle name of
Messages
from the following class ismsg_Views_Index
and in a template{msg_Views_Index:hello(name)}
.