You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to use PropertyKey in some of my projects in order to control usages of l10n keys in compile time. The issue that I faced is that all my property keys is prefixed with "title" and "detail" values. So that when I create an object (that needs to be localized) I set only the error key without prefix. See the code below for clarification:
// imports omittedpublicfinalclassError {
privatefinalStringerrorKey;
publicStringgetErrorKey() {
returnerrorKey;
}
// would like to ability to set _prefix_ value(s)publicError(@PropertyKey(resourceBundle = "app", prefix={"title.", "detail."}) StringerrorKey) {
this.errorKey = errorKey;
}
}
publicclassErrorHandler{
// somewhere in errorHandlerpublicvoidlocalizeError(Errorerror, ResourceBundleresourceBundle){
// create prefixed keysStringtitleKey = "title." + error.getErrorKey();
StringdetailKey = "detail." + error.getErrorKey();
// localize the errorStringtitle = resourceBundle.getString(titleKey);
Stringdetail = resourceBundle.getString(detailKey);
// print localized messagesSystem.out.println("Localized error title is: " + title);
System.out.println("Localized error detail is: " + detail);
}
}
So, my questions are:
Is it possible to get this functionality in the nearest feature? And could you suggest any workaround for now?
Could I write my own annotation with such functionality? Probably in this case I'm supposed to enhance the IDEA inspections. I've never written customization (plugins or so) for IDEA and I'm afraid it would require a lot of work to implement my simple logic, isn't it?
The text was updated successfully, but these errors were encountered:
Hello!
I'd like to use PropertyKey in some of my projects in order to control usages of l10n keys in compile time. The issue that I faced is that all my property keys is prefixed with "title" and "detail" values. So that when I create an object (that needs to be localized) I set only the error key without prefix. See the code below for clarification:
So, my questions are:
The text was updated successfully, but these errors were encountered: