-
Notifications
You must be signed in to change notification settings - Fork 27
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
feat: add XML validation and quickfix for hardcoded UI text #491
base: master
Are you sure you want to change the base?
Conversation
This is a validator that warns the user of hardcoded UI texts that could be externalized to a resource bundle. Includes a quick fix for the warning, where externalized strings from the project's i18n.properties file (if existent) may be suggested as replacements.
This pull request introduces 1 alert when merging 5c5968d into 9d0c89c - view on LGTM.com new alerts:
|
@fausto-m the build matrix fails, can you please fix so I can start the review process. @petermuessig WDYT of this feature? |
This pull request introduces 1 alert when merging 930cd5f into 9d0c89c - view on LGTM.com new alerts:
|
The quick fix was using the value of a key-value pair in the i18n properties file instead of the key
This pull request introduces 1 alert when merging 70539f8 into 9d0c89c - view on LGTM.com new alerts:
|
lodash find was imported but never used
This pull request introduces 1 alert when merging 44709f1 into 9d0c89c - view on LGTM.com new alerts:
|
Also updates properties-file package dependency to a version that supports node18
This pull request introduces 1 alert when merging a069a2b into 9d0c89c - view on LGTM.com new alerts:
|
…olve conflict Previous attribute conflicted with use-of-hardcoded-string-i18n validation as a GUI text property was used in the test. It was replaced by another deprecated property of m.Page class.
This pull request introduces 1 alert when merging f1335dc into 90807cd - view on LGTM.com new alerts:
|
Hi @bd82, the build matrix issues have been solved now. Node16 failed due to something unrelated to my changes (timeout error from other test). Is there a way to rerun the test without additional commits? I've tried from CircleCI, but the option is disabled for me. |
Hi @fausto-m, I checked out this code and the validation is working fine. However I couldn't get the quick fix to work. Can you explain in a bit more detail how that works? Maybe we should add that to the readme. I wonder if we should have a setting as well to enable or disable this validation, some projects are just in one language and it might seem as a nuisance for them to get these squiggly lines |
Hi @uxkjaer, Thanks for your feedback. You're right, opt-in is probably better for this feature. I'll work on that. Regarding the quick fix part, you're supposed to get them if the (UI) text in a control property matches a value present in the project's resource bundle file. There's a script that locates the nearest i18n.properties file (nearest in relation to the XML view/fragment being displayed) and uses it for fetching suggestions. If needed, I can add more info to the readme file. Here's what it looks like: |
Hi, I have a few more points to add regarding this feature. Similar feature is implemented for annotation files in SAP Fiori Tools - XML Annotation Language Server and I think it would make sense to keep the behaviour as similar as possible across the extensions, since users could be using both in the same project.
"sap.ui5": {
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "sap.fe.cap.travel.i18n.i18n"
}
}
}
}
|
|
1 similar comment
|
This is a validator that warns the user of hardcoded UI texts in XML views/fragments that could be externalized to a resource bundle. Includes a quick fix for the warning, where externalized strings from the project's i18n.properties file (if existent) may be suggested as replacements.