-
Notifications
You must be signed in to change notification settings - Fork 1
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
[WIP] Script for ReportNodes internationalization #121
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Naledi EL CHEIKH <[email protected]>
Signed-off-by: Naledi EL CHEIKH <[email protected]>
Signed-off-by: Naledi EL CHEIKH <[email protected]>
Signed-off-by: Naledi EL CHEIKH <[email protected]>
Signed-off-by: Naledi EL CHEIKH <[email protected]>
Signed-off-by: Naledi EL CHEIKH <[email protected]>
Could you also add the "u+x" permission on your scripts? |
Signed-off-by: Naledi EL CHEIKH <[email protected]>
Signed-off-by: Naledi EL CHEIKH <[email protected]>
scripts/get_message_templates.sh
Outdated
function getMessageTemplates() { | ||
grep -R "\\.withMessageTemplate" --exclude="*Test*" --exclude="*.class" "$path" | awk -F'"' '{sub(/[ \t]+$/, "", $2); sub(/[ \t]+$/, "", $3); print $2, $3, $4}' | sort -g | uniq -u | sed "s/,/=/g" > dictionary.properties | ||
echo "==== Duplicated lines ====" | ||
grep -R "\\.withMessageTemplate" --exclude="*Test*" --exclude="*.class" "$path" | awk -F'"' '{sub(/[ \t]+$/, "", $2); sub(/[ \t]+$/, "", $3); print $2, $3, $4}' | sort -g | uniq -d -c | sed "s/,/=/g" |
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.
It would be better to look for the duplicated keys.
If the same key is used several times, there's a huge probability that the associated template will be different.
For instance, in the file you accidentally pushed, validationWarning
was used 2 times with different templates.
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.
So, if I look for the keys, should I only print them in the console ? Or should I print the whole line including the duplicated key ?
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.
I think you can either:
- just print the key
- print the whole line, with the path.
Signed-off-by: Naledi EL CHEIKH <[email protected]>
|
|
||
path="$1" | ||
function getMessageTemplates() { | ||
grep -R "\\.withMessageTemplate" --exclude="*Test*" --include="*.java" "$path" | awk -F'"' '{sub(/[ \t]+$/, "", $2); sub(/[ \t]+$/, "", $3); print $2, $3, $4}' | sort -g | sed 's/,/=/' > temp.properties |
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.
The "exclude" and "include" should be switched in order to really exclude the test java files.
|
||
path="$1" | ||
function getReportNode() { | ||
grep --color='auto' -R "\\.withMessageTemplate" --exclude="*Test*" --exclude="*Reports.java" "$path" |
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.
Could you also add the --include="*.java"
option in this script?
|
||
path="$1" | ||
function getMessageTemplates() { | ||
grep -R "\\.withMessageTemplate" --exclude="*Test*" --include="*.java" "$path" | awk -F'"' '{sub(/[ \t]+$/, "", $2); sub(/[ \t]+$/, "", $3); print $2, $3, $4}' | sort -g | sed 's/,/=/' > temp.properties |
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.
I have missed it, but in the resulting dictionary, some keys have no message.
In fact, in the source code, the message can be on another line. For instance, in powsybl-core we have:
protected void reportOnInconclusiveDryRun(ReportNode reportNode, String cause) {
reportNode.newReportNode()
.withMessageTemplate("networkModificationDryRun-failure",
"Dry-run failed for ${networkModification}. The issue is: ${dryRunError}")
.withUntypedValue("dryRunError", cause)
.withUntypedValue("networkModification", getName())
.add();
}
Please check if the PR fulfills these requirements
Does this PR already have an issue describing the problem?
Allows to get any ReportNodes that aren't written in the right files and generate a file with the keys of messageTemplate and the corresponding message.
What kind of change does this PR introduce?
It will allow code cleanup and message templates translation.
Does this PR introduce a new Powsybl Action implying to be implemented in simulators or pypowsybl?
Does this PR introduce a breaking change or deprecate an API?