[Loc] Add collect-strings step to generate en-US and en-XL.json
This CL hooks up the collect-strings step with presubmit. Any UIStrings in the front_end javascript files will be gathered, and en-US.json and en-XL.json will be generated.
Note: This step has minimum impact on the presubmit performance (<1s)
DISABLE_THIRD_PARTY_CHECK = reason: removing extra loggings from the existing scripts.
Change-Id: I0065449766719a67d0ed604de3941bbc050b3780
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2409193
Reviewed-by: Vidal Diazleal <vidorteg@microsoft.com>
Reviewed-by: Simon Zünd <szuend@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Commit-Queue: Christy Chen <chrche@microsoft.com>
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 74ded97..5662350 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -333,6 +333,30 @@
return _ExecuteSubProcess(input_api, output_api, generate_protocol_resources_path, [], results)
+def _CollectStrings(input_api, output_api):
+ devtools_root = input_api.PresubmitLocalPath()
+ devtools_front_end = input_api.os_path.join(devtools_root, 'front_end')
+ affected_front_end_files = _getAffectedFiles(input_api,
+ [devtools_front_end], ['D'],
+ ['.js'])
+ if len(affected_front_end_files) == 0:
+ return [
+ output_api.PresubmitNotifyResult(
+ 'No affected files to run collect-strings')
+ ]
+
+ results = [
+ output_api.PresubmitNotifyResult('Collecting strings from front_end:')
+ ]
+ script_path = input_api.os_path.join(devtools_root, 'third_party', 'i18n',
+ 'collect-strings.js')
+ results.extend(_checkWithNodeScript(input_api, output_api, script_path))
+ results.append(
+ output_api.PresubmitNotifyResult(
+ 'Please commit en-US.json if changes are generated.'))
+ return results
+
+
def _CheckNoUncheckedFiles(input_api, output_api):
results = []
process = input_api.subprocess.Popen(['git', 'diff', '--exit-code'],
@@ -447,6 +471,8 @@
results = []
results.extend(_CommonChecks(input_api, output_api))
results.extend(_CheckDevtoolsLocalization(input_api, output_api))
+ # Run collectStrings after localization check that cleans up unused strings
+ results.extend(_CollectStrings(input_api, output_api))
return results
@@ -454,6 +480,8 @@
results = []
results.extend(_CommonChecks(input_api, output_api))
results.extend(_CheckDevtoolsLocalization(input_api, output_api, True))
+ # Run collectStrings after localization check that cleans up unused strings
+ results.extend(_CollectStrings(input_api, output_api))
results.extend(input_api.canned_checks.CheckChangeHasDescription(input_api, output_api))
return results