This check will detect (and autofix) any string resources that are not used in the code anymore. If a developer deletes a localization call but forgets to delete it from the UIStrings structure, the check will warn/remove it.
Testing steps
1. Add the following to the CoverageView.js right after import statements
export const UIStrings = {
/**
*@description Text in Coverage List View of the Coverage tab
*/
perFunction: 'Per function',
/**
*@description Text in Coverage List View of the Coverage tab
*/
perBlock: 'Per block',
};
2. Change:
label: ls`Per function`,
To the Loc V2 API call:
label: i18n.i18n.getLocalizedString(str_, UIStrings.perFunction),
3. Change:
label: ls`Per block`,
To not use any localization API
label: "Per block",
4. Run
node check_localizable_resources.js --autofix
The Loc V1 check would remove the two entries from grdp
The Loc V2 check would remove perBlock entry from UIStrings
See Loc design doc #Presubmit section for details
https://docs.google.com/document/d/1L6TkT2-42MMQ72ZSBMFwUaq7M6mDgA2X0x8oHHKaV_U/edit#heading=h.w1no7qaa0mi0
Bug: 941561
Change-Id: Ic5f3ee6e9c1586bb3226593c32bc7af7e49a547a
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2236544
Commit-Queue: Christy Chen <chrche@microsoft.com>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Reviewed-by: Simon Zünd <szuend@chromium.org>
The localization_utils check a list of excluded directories against the
subdirectories of front_end. However, the list of directories hardcoded
the / separator, which is incorrect on Windows. This led to localization
checks in third_party subdirectories, causing build breakages and
performance regressions. This CL updates the paths to use the node
path.sep value, which in turn means that the string matching works on all\
platforms.
R=tvanderlippe@chromium.org
Change-Id: I5e1f2400b3f331ff4ac7acf953042b2ad900d40b
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2398827
Commit-Queue: Paul Lewis <aerotwist@chromium.org>
Auto-Submit: Paul Lewis <aerotwist@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
When the presubmit moves a message from one grdp file to another, the <ph name=LOCKED> and <ex> tags are lost because all the messages are re-created from the frontend version of the string.
This change preserve the grd version of the strings that contains all the tags and use it when the messages are moving across different grdp files.
To test this:
In DeviceModeToolbar.js Line 351
Change
ls`Close DevTools`
To
'Close DevTools'
In WarningErrorCounter.js Line 163
Change
ls`Issues pertaining to ${issues} operation detected.`
To
ls`Close DevTools`
Run presubmit and see the tags are preserved.
Bug: 1071004
Change-Id: I5c724f0dc025dbfd06963373a8cb5fe7caf52803
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2275727
Commit-Queue: Christy Chen <chrche@microsoft.com>
Reviewed-by: Simon Zünd <szuend@chromium.org>
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Vidal Diazleal <vidorteg@microsoft.com>
While clang-format and eslint support the modern javascript features,
the localizability pipeline did not. It was using esprima, which is
a parser that is not well maintained and does not support modern
features.
For our ESLint configuration, we are using the typescript-eslint
parser, which is compatible with espree, the parser powering ESLint.
Both espree and typescript-eslint have an API that is very similar
to esprima.
Therefore, update the localizability pipeline to use the espree API
with the concrete implementation of the API by typescript-eslint.
In the future, the localizability pipeline should probably be an
ESLint plugin so that we can unify the parsing experience.
A follow-up CL will remove all usages of esprima.
R=jacktfranklin@chromium.org
Fixed: 1068966
Change-Id: Idcffb8d649f006d7cf0b3de0ee0d886cb3848230
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2140939
Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
This CL introduces support for parsing and pulling translations out of
`*.ts` files.
It introduces code to parse a TypeScript AST to look for `ls` calls and
pass them back into the existing GRDP tooling.
As a purposeful limitation, it _only looks for `ls` calls_.
Change-Id: I3f91793165e11f0382d6266f4e2c2443701b299a
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2095295
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Paul Lewis <aerotwist@chromium.org>
As part of the ESM migration, certain function needs to be renamed over
to a different namespace, e.g. Common.UIString becomes
Common.UIString.UIString. As such the script that looks for instances of
Common.UIString for localization fails to identify instances of the
updated calls to Common.UIString.UIString. This CL updates
localization_utils so that it is aware of the updated namespaces, but
treats them in the same way as their legacy counterparts.
Bug: 1006759
Change-Id: I0a7da9109ee969da4caac3283c4ff26f4589f68a
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1985674
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Paul Lewis <aerotwist@chromium.org>