mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-02 18:11:04 +08:00
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: Yang Guo <yangguo@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#699005} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: c108074d7327d594c73b0f6dc578da42632ba404
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user