DevTools: Update presubmit script to autofix localizable strings that have moved to a different folder
Right now if a localizable string is moved to a different folder, the
autofix tool doesn't move the corresponding grdp message to the new grdp
file. I updated the tool to track which grdp file a localizable string is
supposed to be in, and compare it to the actual grdp file when autofixing
issues. When a string is copied to another folder, the description is
automatically copied over to the new grdp file.
Existing issues are fixed up.
Bug: 941561
Change-Id: Iaf4537a8c51b8947b7edb5d54c15dbf8571060d8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1637590
Reviewed-by: Joel Einbinder <einbinder@chromium.org>
Reviewed-by: Alexei Filippov <alph@chromium.org>
Commit-Queue: Mandy Chen <mandy.chen@microsoft.com>
Cr-Original-Commit-Position: refs/heads/master@{#668185}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 6f01dec7da56367f1cf058a6e5b554c1a540846d
diff --git a/scripts/localization_utils/localization_utils.js b/scripts/localization_utils/localization_utils.js
index 11119c5..8b70379 100644
--- a/scripts/localization_utils/localization_utils.js
+++ b/scripts/localization_utils/localization_utils.js
@@ -189,18 +189,6 @@
return dirPaths;
}
-/**
- * Get the parent grdp file path for the input frontend file path.
- * NOTE: Naming convention of a grdp file is the name of the child directory under
- * devtools/front_end plus _strings.grdp
- */
-function getGRDPFilePath(frontendFilepath, frontendDirs) {
- const frontendDirsLowerCase = frontendDirs.map(dir => dir.toLowerCase());
- const dirpath = path.dirname(frontendFilepath);
- if (frontendDirsLowerCase.includes(dirpath.toLowerCase()))
- return path.resolve(dirpath, `${path.basename(dirpath)}_strings.grdp`);
-}
-
function modifyStringIntoGRDFormat(str, args) {
let sanitizedStr = sanitizeStringIntoGRDFormat(str);
@@ -236,7 +224,7 @@
}
function createGrdpMessage(ids, stringObj) {
- let message = ` <message name="${ids}" desc="">\n`;
+ let message = ` <message name="${ids}" desc="${stringObj.description || ''}">\n`;
message += ` ${modifyStringIntoGRDFormat(stringObj.string, stringObj.arguments)}\n`;
message += ' </message>\n';
return message;
@@ -253,7 +241,6 @@
esprimaTypes,
getChildDirectoriesFromDirectory,
getFilesFromDirectory,
- getGRDPFilePath,
getIDSKey,
getLocalizationCase,
getLocationMessage,