Commit c108074d authored by Mandy Chen's avatar Mandy Chen Committed by Commit Bot

DevTools: Clean up localization parsing scripts

This CL:

* updates parseLocalizableResourceMaps to return maps of localizable
resources
* removes localizable resources from exports
* fixes non-async functions
* fixes existing parsing error

This CL is in preparation of https://crrev.com/c/1671848.

Bug: 941561
Change-Id: Id18faf3086fb8d9d3c75b110733784ba95cf56e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1814539
Commit-Queue: Mandy Chen <mandy.chen@microsoft.com>
Reviewed-by: default avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699005}
parent cf17005c
......@@ -33,7 +33,7 @@ async function main() {
if (shouldAutoFix)
await autofix(error);
else
await getErrors(error);
getErrors();
} catch (e) {
console.log(e.stack);
console.log(`Error: ${e.message}`);
......@@ -43,11 +43,12 @@ async function main() {
main();
async function getErrors(existingError) {
const toAddError = await checkLocalizedStrings.getAndReportResourcesToAdd();
function getErrors(existingError) {
const toAddError = checkLocalizedStrings.getAndReportResourcesToAdd();
const toModifyError = checkLocalizedStrings.getAndReportIDSKeysToModify();
const toRemoveError = checkLocalizedStrings.getAndReportResourcesToRemove();
let error = `${existingError}\n${toAddError || ''}${toModifyError || ''}${toRemoveError || ''}`;
let error =
`${existingError ? `${existingError}\n` : ''}${toAddError || ''}${toModifyError || ''}${toRemoveError || ''}`;
if (error === '') {
console.log('DevTools localizable resources checker passed.');
......
......@@ -188,6 +188,12 @@ function validateGrdpFile(dir, grdpFiles, grdFileContent, shouldAutoFix, renameF
* Parse localizable resources.
*/
async function parseLocalizableResourceMaps() {
if (frontendStrings.size === 0 && IDSkeys.size === 0)
await parseLocalizableResourceMapsHelper();
return [frontendStrings, IDSkeys];
}
async function parseLocalizableResourceMapsHelper() {
const grdpToFiles = new Map();
const dirs = devtoolsFrontendDirs || await localizationUtils.getChildDirectoriesFromDirectory(devtoolsFrontendPath);
const grdpToFilesPromises = dirs.map(dir => {
......@@ -485,7 +491,7 @@ function addMessage(expectedIDSKey, actualIDSKey, grdpPath, line, description) {
* with grdp <message>s and report error of resources to add,
* remove or modify.
*/
async function getAndReportResourcesToAdd() {
function getAndReportResourcesToAdd() {
const keysToAddToGRD = getMessagesToAdd();
if (keysToAddToGRD.size === 0)
return;
......@@ -625,8 +631,6 @@ function getLongestDescription(messages) {
}
module.exports = {
frontendStrings,
IDSkeys,
parseLocalizableResourceMaps,
getAndReportIDSKeysToModify,
getAndReportResourcesToAdd,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment