Commit Graph
23 Commits
Author SHA1 Message Date
Mandy Chen 167e7ad444 Normalize line ending to LF in localizatioin scripts
TL;DR: When retrieving the file content with localization scripts,
normalize the line ending to LF.

Issue:
When a grdp file containing multi-line strings has CRLF line ending,
the parser doesn't work because the IDS hash is calculated based on the
content of the <message> tag, which expects LF line ending. The multi-
line string ends up having a different expected hash, and the parser
complains about it.

Repro:
Change line ending of front_end/coverage/coverage_strings.grdp to CRLF.

Fix:
Normalize line ending to LF when retrieving the file content.

Change-Id: If3a33978724a4bf9635738c67ada211e5e996e30
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1895994
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Mandy Chen <mandy.chen@microsoft.com>
2019-11-04 18:04:05 +00:00
Mandy Chen 01845077f9 Fix regex in localization parser to recognize CRLF line ending
Update localization script to recognize CRLF line ending.

Change-Id: I80f2789023f281b9630a6943b95c09266789ef9c
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1894551
Reviewed-by: Lorne Mitchell <lomitch@microsoft.com>
Commit-Queue: Mandy Chen <mandy.chen@microsoft.com>
2019-10-31 23:13:42 +00:00
Yang Guo 4fd355cc40 Switch to new repository 2019-10-21 08:08:56 +02:00
Paul Irish e7b977eb54 DevTools: In l10n presubmit, apply ignore list to modified files
Change-Id: I31caa742e32727fcdd3c992fca0f815fefbf9740
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1818609
Auto-Submit: Paul Irish <paulirish@chromium.org>
Reviewed-by: Mandy Chen <mandy.chen@microsoft.com>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#699714}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: ea03feb17d2dac76b800aa9dd586a1812527bc2c
2019-09-25 12:23:38 +00:00
Tim van der Lippe fe98df5af5 Use the version of esprima in devtools-node-modules
We are going to update the version of Esprima to understand dynamic imports, but it turned out that this script was actually using a completely different version of Esprima. Update this path to resolve to our devtools-node-modules instead.

Bug: 1006759
Change-Id: I1f0b791a5afe86e94258b7b3a044f7e756b923f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1821559
Commit-Queue: Tim Van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Auto-Submit: Tim Van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#699302}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: b596ed2ae4fb36ddb4f9682b8c2b93262bc084e7
2019-09-24 12:11:30 +00:00
Mandy Chen 08fdf04698 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
2019-09-23 19:57:20 +00:00
Mandy Chen 5128cc6c7a DevTools: Autofix out-of-date grdp/grd file paths in presubmit
This patch adds the functionality to autofix grdp/grd file paths that are
out of date.

* <part> file entries that reference non-existent grdp files in
devtools_ui_strings.grd are removed.

* Grdp files with the wrong names are renamed (format should be
<folder_name>_strings.grdp) along with the corresponding part file entries
in devtools_ui_strings.grd.

* If more than one grdp files are under a directory, an error is issued to
ask the user to consolidate these grdp files.

This patch will eliminate the need to manually fix grdp/grd inconsistensies
(e.g. https://crrev.com/c/1637591) after unexpected changes (e.g. audits2
renamed to audits: https://crrev.com/c/1614691).

Bug: 941561
Change-Id: Ie413fe070a2f5b4319a12ce07653ec1a79912215
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1703044
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Mandy Chen <mandy.chen@microsoft.com>
Cr-Original-Commit-Position: refs/heads/master@{#698917}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 3329fdbaecd905bf1a98a5ae24893d700571ba70
2019-09-23 16:46:00 +00:00
Christy Chen fc8ed9f851 DevTools: Localize tags for command menu search to work properly
The tags in Module.json are not localized. This change localize them,
so when users type the word in command menu with languages other than
English, the results can show up correctly.

Two scripts edited (check_localized_strings.js, CommandMenu.js).
Grdp changes are generated automatically, with manually added descriptions.

Bug: 941561
Change-Id: I3dc1f8f8b72e21748f5fa84c1c60b9597aa0414a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1809673
Reviewed-by: Yang Guo <yangguo@chromium.org>
Reviewed-by: Mandy Chen <mandy.chen@microsoft.com>
Commit-Queue: Christy Chen <chrche@microsoft.com>
Cr-Original-Commit-Position: refs/heads/master@{#698223}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: b75a4b07ffd26a61fef0344123701241bb75002c
2019-09-19 22:18:44 +00:00
Mandy Chen 436efc76eb DevTools: Improve localization presubmit file parsing error message
Currently, if an unsupported JS feature is used, localization presubmit
checks will fail with the raw error message from esprima, the JS parsing
library. This CL wraps a try-catch block around the parsing call and outputs
a nice error message that specifies the file location and the reason.

Before:
Error: Line 9: Unexpected token =

After:
Error: DevTools localization parser failed:
third_party\blink\renderer\devtools\front_end\security\SecurityPanel.js: Line 9: Unexpected token =
This error is likely due to unsupported JavaScript features. Such features
are not supported by eslint either and will cause presubmit to fail. Please
update the code and use official JavaScript features.


Bug: 941561
Change-Id: If945563f84224232155a7de7cf597c5395a0cbb9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1729729
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Mandy Chen <mandy.chen@microsoft.com>
Cr-Original-Commit-Position: refs/heads/master@{#697675}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 2b4a1abab0661e491ab275768f8f174cf5686c46
2019-09-18 17:43:40 +00:00
Mandy Chen 1e9d87b8f2 DevTools: Create a grdp file for shared strings to avoid confusion
Since the current localization system uses a unique ID for each string that
is calculated based on the the md5 hash of the string, each string
in the grdp files needs to be unique. However, there are strings in the
frontend that appear multiple times. When such strings are moved across
folders, sometimes a seemingly random grdp file is changed by the autofix
script. (See https://crrev.com/c/1683826 for an example)

This CL introduces shared_strings.grdp, a file dedicated for strings that
are shared across folders/grdp files. Instead of putting these strings in
the grdp files that come first when sorted alphabetically, they live in
shared_strings.grdp and have common descriptions among all instances of
such strings. This way if shared strings need to be moved, it's more clear
what's going on.

Note that this CL contains a lot of changes that are generated automatically
(e.g. shared strings are removed from their current locations), so here's
the list of actual changes that need to be reviewed:

* shared_strings.grdp file is added to front_end/langpacks and front_end/langpacks/
devtools_ui_strings.grd
* path to shared_strings.grdp is added to scripts/localization_utils/localization_utils.js
* in scripts/localization_utils/check_localized_strings.js, the parser marks
strings that appear more than once as shared and set the target grdp file to be
shared_strings.grdp
* shared_strings.grdp file is checked by scripts/check_localizability.js for
localizability violations
* shared_strings.grdp messages have common descriptions added

Bug: 941561
Change-Id: I00db23854656509f2f03988e70adc0109b6e09d6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1800918
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Mandy Chen <mandy.chen@microsoft.com>
Cr-Original-Commit-Position: refs/heads/master@{#697667}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: d10bf7c5a97cf9184866c1117935c199bacf7ff3
2019-09-18 17:18:15 +00:00
Tim van der Lippe 63a4d3dcd6 Reland "Convert ui/ARIAUtils.js to an ES module"
This is a reland of b3373919f86df10c190a8672ca828c7ea4b920e5

Original change's description:
> Convert ui/ARIAUtils.js to an ES module
>
> ES modules allow files to explicitly import and export symbols [1].
> This patch migrates ARIAUtils.js to an ES module, while maintaining
> backwards compatibility with existing usages of `window.UI.ARIAUtils`.
>
> The build system is updated to copy these modules verbatim, as it no
> longer require pre-processing to be loaded. The `module.json` no longer
> includes this file as a script, to make sure it is not double-bundled
> into `shell.js`. Instead, it is added to the new field `modules`, which
> contains all modules. By doing so, it becomes clear which files are
> converted to modules already and which require the legacy references
> to the global scope.
>
> This module and future modules will be imported from `root.js`, which is
> added to all existing HTML application files.
>
> Design Doc: https://docs.google.com/document/d/1h9dOy3nNPNfZ2AtZXzB-DwJqG4Oo37WWvKLCuzCcPzo/edit?usp=sharing
>
> [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
>
> TBR=jochen@chromium.org
>
> Change-Id: Ie79c8f2fce3aff96fa28af0b575eae39bfe8e1a5
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1748949
> Reviewed-by: Jochen Eisinger <jochen@chromium.org>
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Commit-Queue: Tim van der Lippe <tvanderlippe@google.com>
> Cr-Commit-Position: refs/heads/master@{#697238}

Change-Id: I7544cbf4364d0b1a3c2f137a4d17a1afdb1d4aed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1810534
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Tim Van der Lippe <tvanderlippe@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#697626}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: ec810baced8e07ca3e9f2b801703be433807d2a2
2019-09-18 15:31:38 +00:00
Takuto Ikuta 4cabd3c98e Revert "Convert ui/ARIAUtils.js to an ES module"
This reverts commit b3373919f86df10c190a8672ca828c7ea4b920e5.

Reason for revert: https://ci.chromium.org/p/chromium/builders/ci/Linux%20Tests/81914

Original change's description:
> Convert ui/ARIAUtils.js to an ES module
> 
> ES modules allow files to explicitly import and export symbols [1].
> This patch migrates ARIAUtils.js to an ES module, while maintaining
> backwards compatibility with existing usages of `window.UI.ARIAUtils`.
> 
> The build system is updated to copy these modules verbatim, as it no
> longer require pre-processing to be loaded. The `module.json` no longer
> includes this file as a script, to make sure it is not double-bundled
> into `shell.js`. Instead, it is added to the new field `modules`, which
> contains all modules. By doing so, it becomes clear which files are
> converted to modules already and which require the legacy references
> to the global scope.
> 
> This module and future modules will be imported from `root.js`, which is
> added to all existing HTML application files.
> 
> Design Doc: https://docs.google.com/document/d/1h9dOy3nNPNfZ2AtZXzB-DwJqG4Oo37WWvKLCuzCcPzo/edit?usp=sharing
> 
> [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
> 
> TBR=jochen@chromium.org
> 
> Change-Id: Ie79c8f2fce3aff96fa28af0b575eae39bfe8e1a5
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1748949
> Reviewed-by: Jochen Eisinger <jochen@chromium.org>
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Commit-Queue: Tim van der Lippe <tvanderlippe@google.com>
> Cr-Commit-Position: refs/heads/master@{#697238}

TBR=yangguo@chromium.org,jochen@chromium.org,aerotwist@chromium.org,mathias@chromium.org,tvanderlippe@google.com

Change-Id: I550f1082755ef4b9e7bc778e3afdaef324dae03a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1808954
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#697355}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 53558661a67dcdf9d11bb2571d43ebca6f504670
2019-09-17 20:55:22 +00:00
Tim van der Lippe 321ff26d6d Convert ui/ARIAUtils.js to an ES module
ES modules allow files to explicitly import and export symbols [1].
This patch migrates ARIAUtils.js to an ES module, while maintaining
backwards compatibility with existing usages of `window.UI.ARIAUtils`.

The build system is updated to copy these modules verbatim, as it no
longer require pre-processing to be loaded. The `module.json` no longer
includes this file as a script, to make sure it is not double-bundled
into `shell.js`. Instead, it is added to the new field `modules`, which
contains all modules. By doing so, it becomes clear which files are
converted to modules already and which require the legacy references
to the global scope.

This module and future modules will be imported from `root.js`, which is
added to all existing HTML application files.

Design Doc: https://docs.google.com/document/d/1h9dOy3nNPNfZ2AtZXzB-DwJqG4Oo37WWvKLCuzCcPzo/edit?usp=sharing

[1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import

TBR=jochen@chromium.org

Change-Id: Ie79c8f2fce3aff96fa28af0b575eae39bfe8e1a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1748949
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Tim van der Lippe <tvanderlippe@google.com>
Cr-Original-Commit-Position: refs/heads/master@{#697238}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: b3373919f86df10c190a8672ca828c7ea4b920e5
2019-09-17 15:56:41 +00:00
Mandy Chen 609679bdac DevTools: Localize geolocations
The city names in settings are not localized because the localization
parser doesn't know about them. Modify the parser to recognize these
strings.

Bug: 941561
Change-Id: If1974dd471b3d646c900dea6932f427a273c19f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1769300
Reviewed-by: Erik Luo <luoe@chromium.org>
Commit-Queue: Mandy Chen <mandy.chen@microsoft.com>
Cr-Original-Commit-Position: refs/heads/master@{#695189}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 6c93ef31f05965de3b56da700067b57890cfd1ef
2019-09-10 16:04:08 +00:00
Mandy Chen d97200bd72 DevTools: Report missing description and placeholder example as localizability violation in presubmit
This patch adds a localizability check to the presubmit script that reports
errors for empty descriptions, after https://crrev.com/c/1688716 adds auto-
generated descriptions.

Example error messages:

third_party/blink/renderer/devtools/front_end/accessibility/accessibility_strings.grdp
Line 36: missing description for message with the name "IDS_DEVTOOLS_185551542d4a950d6ed4a90e0875dfde"
third_party/blink/renderer/devtools/front_end/animation/animation_strings.grdp Line 10:
missing <ex> in <ph> tag with the name "BUTTON_TEXTCONTENT"

This patch also improves error reporting by changing full file path to partial
path from src/ so that it's more consistent with the presubmit error style.

Note: there may be new strings added without a description and/or placeholder
example while this patch is on review. In that case I will fix them so the
check can be enabled without any problem.

Bug: 941561
Change-Id: If609d234b67acb76dfd9c66e2f8880d9875034cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1693028
Commit-Queue: Mandy Chen <mandy.chen@microsoft.com>
Reviewed-by: Joel Einbinder <einbinder@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#681975}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 1404bfcfd225f2963874e37299d890b1f3119e72
2019-07-29 21:13:39 +00:00
Mandy Chen 4a7ad057a2 DevTools: Update presubmit script to remove duplicate grdp messages
Due to the merge timing of patches, sometimes duplicate grdp messages
can be added and co-exist*. This patch updates the presubmit script to
automatically delete duplicate grdp messages.

- Keep the winning grdp message (i.e. the one that corresponds to the
  frontend message that comes first based on its file name when sorted).

- If none of these duplicate messages should be kept, delete them all.

- If none of these duplicate messages should be kept AND the same message
  needs to be created in a different grdp file, preserve the longer
  description.

In addition, this patch removes unnecessary arguments such as isDebug and
file-level dictionary structures.


*: https://crrev.com/c/1580199 and https://crrev.com/c/1633989 both added
a grdp message for "Image from %s".


Bug: 941561
Change-Id: Ic37f1fc410361eabd0ba710ece73a76d78eb8d34
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1656070
Reviewed-by: Joel Einbinder <einbinder@chromium.org>
Commit-Queue: Mandy Chen <mandy.chen@microsoft.com>
Cr-Original-Commit-Position: refs/heads/master@{#677799}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: a0dbe54c77da415cfc79ee99bc0cd9e590ffb6ff
2019-07-16 16:09:29 +00:00
Mandy Chen 81d4fc4e26 DevTools: Autofix grdp messages with the wrong IDS key in presubmit
The ids key (i.e. name value of a <message> tag) of a grdp message is
IDS_DEVTOOLS_<md5 hash of the string>. Currently if you manually modify
the content of a message and modify the corresponding frontend string,
the ids key can be outdated.*

This patch improves the presubmit script to autofix such issues. Actual
fix of the current problem is in another patch:
https://crrev.com/c/1670315.

*: example: https://crrev.com/c/1637046

Bug: 941561
Change-Id: I2f2b044955aa1033f07a054ac2926392d6ff1687
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1661120
Commit-Queue: Mandy Chen <mandy.chen@microsoft.com>
Reviewed-by: Erik Luo <luoe@chromium.org>
Reviewed-by: Alexei Filippov <alph@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#676641}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 36f218b51c5cbc5e1c43e7c42dcf4bd83b50bfdc
2019-07-11 23:12:02 +00:00
Mandy Chen 7a8829be3d DevTools: Parse localizable strings created by Common.UIStringFormat
Modify the presubit script to automatically parse localizable strings
created by new Common.UIStringFormat(). Add existing strings to the grdp
files.

Bug: 941561
Change-Id: I5b4538d1f4df37b4dc3b1796df069c6eaad6f2bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1666484
Reviewed-by: Joel Einbinder <einbinder@chromium.org>
Commit-Queue: Mandy Chen <mandy.chen@microsoft.com>
Cr-Original-Commit-Position: refs/heads/master@{#672286}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 43fedcf2a61b98e024c7417f986769d5b99709dd
2019-06-25 22:13:07 +00:00
Mandy Chen 785526337d DevTools: Add ''' in grdp files for leading and trailing whitespace
Currently the leading and trailing whitespace in grdp messages is trimmed
by the grit tool. I modified grdp message generation scripts to add '''
for these messages so the whitespace is preserved. Existing such messages
are fixed.

Bug: 941561

Change-Id: Ib11a6cac5fc7359958a29474c03c449a62e4116a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1636630
Commit-Queue: Mandy Chen <mandy.chen@microsoft.com>
Reviewed-by: Alexei Filippov <alph@chromium.org>
Reviewed-by: Joel Einbinder <einbinder@chromium.org>
Reviewed-by: Erik Luo <luoe@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#668239}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: bcffd0543b389a4992eab60acaa4d652b6471e9f
2019-06-12 00:55:43 +00:00
Mandy Chen c94d52aa3f 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
2019-06-11 22:51:53 +00:00
Lorne Mitchell c56ff2d968 Reland of "DevTools: Added GRD/GRDP files for all localizable strings in the DevTools."
This is a reland of https://chromium-review.googlesource.com/c/chromium/src/+/1613921/, which was reverted (Bug=966547) because
third_party/blink/renderer/devtools/front_end/langpacks/devtools_ui_strings.grd was being picked up by Google's internal localization pipeline.

Bug=941561

Change-Id: I9a97e16e367716189d34944b76605c9321d47092
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1627921
Reviewed-by: Joel Einbinder <einbinder@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Reviewed-by: Alexei Filippov <alph@chromium.org>
Commit-Queue: Lorne Mitchell <lomitch@microsoft.com>
Cr-Original-Commit-Position: refs/heads/master@{#664013}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 613ca444d07326b6f087c083af79a636a858a7d9
2019-05-28 23:35:03 +00:00
Krishna Govind 897c867a07 Revert "DevTools: Added GRD/GRDP files for all localizable strings in the DevTools."
This reverts commit 2f05fdbf2ab3458b4b3a3f2a86f908a3a7d04f79.

Reason for revert: Breaks chrome translation, crbug 966547

Original change's description:
> DevTools: Added GRD/GRDP files for all localizable strings in the DevTools.
> 
> This change includes...
> * A main GRD file for the DevTools (front_end/langpacks/devtools_ui_strings.grd)
> * GRDP files organized by subfolder
> * A node script that keeps the GRD/GRDP files in sync with the keys in the DevTools frontend
> * A git cl presubmit --upload check that runs the node script
> 
> Note: Subsequent changes will add a build step to generate a .pak file that contains these DevTools strings. You can read about the overall approach here (https://bugs.chromium.org/p/chromium/issues/detail?id=941561).
> 
> 
> Details of this design:
> ======================
> We followed a similar pattern used by WebUI where strings are encoded in GRIT GRD/P files, which are used by a localization service to perform translations. They are also consumed in the build step to generate a .pak file, which is loaded by the browser's resource system.
> 
> Chromium documentation:
> * https://www.chromium.org/developers/tools-we-use-in-chromium/grit/grit-users-guide
> * https://www.chromium.org/developers/design-documents/ui-localization
> 
> Frontend strings:
> -----------------
> These are the localizable strings that are displayed to the user.
> 
> GRDP <message> strings:
> -----------------------
> Each frontend string has a corresponding <message> entry in a GRDP file. These entries are what the localization service will use to perform localizations. It's also the input to the GRIT compiler, which generates a .pak file, which is loaded by the browser's resource_bundle system.
> 
> GRDP <messsage> placeholders:
> ----------------------------
> Frontend strings use placeholders, which are used to substitute in values at runtime.
> For example,
> 'This string has %s two placeholder %.2f.'
> 
> Since the order of the string may change in a different language, we need to encode the order of the placeholders. As such, in the GRDP file you'll find %s replaced with $[1-9].
> 
> For example,
> 'This string has <ph name="ph1">$1s</ph> two placeholder <ph name="ph2">$2.2f</ph>.'
> 
> Also, note that the precision and type of the placeholder is maintained (i.e. .2f).
> 
> Detecting changes:
> -----------------
> The check_localizable_resources.js script performs the following check and generates an error if there are any changes that need to be made to a GRDP file.
> 
> 1. Parses the frontend strings and hashes them.
> 2. Reads the messages from the GRDP files and hashes them.
> 3. Uses a difference between these two sets to report which strings need to be added and/or removed from GRDP files.
> 
> Optionally, the user can specify --autofix and it will automatically update the appropriate GRDP files.
> 
> Presubmit check:
> ---------------
> Running git cl presubmit --upload will run the check_localizable_resources.js script with the --autofix argument.
> 
> If there are any changes, they reported to the user like this.
> 
> ** Presubmit ERRORS **
> Error: Found changes to localizable DevTools strings.
> DevTools localizable resources checker has updated the appropriate grdp file(s).
> Manually write a description for any new <message> entries.
> Use git status to see what has changed.
> 
> BUG=941561
> 
> Change-Id: I5ac1656a037a6aaffeb4f64b103c4daec28be39a
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1613921
> Reviewed-by: Joel Einbinder <einbinder@chromium.org>
> Reviewed-by: Alexei Filippov <alph@chromium.org>
> Commit-Queue: Lorne Mitchell <lomitch@microsoft.com>
> Cr-Commit-Position: refs/heads/master@{#662371}

TBR=alph@chromium.org,einbinder@chromium.org,exterkamp@chromium.org,jeffish@microsoft.com,lomitch@microsoft.com

Change-Id: Ic4ca7d000d10b2bc61b585198469ca30f051dc62
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 941561
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1627943
Reviewed-by: Krishna Govind <govind@chromium.org>
Commit-Queue: Krishna Govind <govind@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#662798}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: ceb872b6f6a02d707783563a225c77bb0c62170a
2019-05-23 20:33:45 +00:00
Lorne Mitchell 072e6f877f DevTools: Added GRD/GRDP files for all localizable strings in the DevTools.
This change includes...
* A main GRD file for the DevTools (front_end/langpacks/devtools_ui_strings.grd)
* GRDP files organized by subfolder
* A node script that keeps the GRD/GRDP files in sync with the keys in the DevTools frontend
* A git cl presubmit --upload check that runs the node script

Note: Subsequent changes will add a build step to generate a .pak file that contains these DevTools strings. You can read about the overall approach here (https://bugs.chromium.org/p/chromium/issues/detail?id=941561).


Details of this design:
======================
We followed a similar pattern used by WebUI where strings are encoded in GRIT GRD/P files, which are used by a localization service to perform translations. They are also consumed in the build step to generate a .pak file, which is loaded by the browser's resource system.

Chromium documentation:
* https://www.chromium.org/developers/tools-we-use-in-chromium/grit/grit-users-guide
* https://www.chromium.org/developers/design-documents/ui-localization

Frontend strings:
-----------------
These are the localizable strings that are displayed to the user.

GRDP <message> strings:
-----------------------
Each frontend string has a corresponding <message> entry in a GRDP file. These entries are what the localization service will use to perform localizations. It's also the input to the GRIT compiler, which generates a .pak file, which is loaded by the browser's resource_bundle system.

GRDP <messsage> placeholders:
----------------------------
Frontend strings use placeholders, which are used to substitute in values at runtime.
For example,
'This string has %s two placeholder %.2f.'

Since the order of the string may change in a different language, we need to encode the order of the placeholders. As such, in the GRDP file you'll find %s replaced with $[1-9].

For example,
'This string has <ph name="ph1">$1s</ph> two placeholder <ph name="ph2">$2.2f</ph>.'

Also, note that the precision and type of the placeholder is maintained (i.e. .2f).

Detecting changes:
-----------------
The check_localizable_resources.js script performs the following check and generates an error if there are any changes that need to be made to a GRDP file.

1. Parses the frontend strings and hashes them.
2. Reads the messages from the GRDP files and hashes them.
3. Uses a difference between these two sets to report which strings need to be added and/or removed from GRDP files.

Optionally, the user can specify --autofix and it will automatically update the appropriate GRDP files.

Presubmit check:
---------------
Running git cl presubmit --upload will run the check_localizable_resources.js script with the --autofix argument.

If there are any changes, they reported to the user like this.

** Presubmit ERRORS **
Error: Found changes to localizable DevTools strings.
DevTools localizable resources checker has updated the appropriate grdp file(s).
Manually write a description for any new <message> entries.
Use git status to see what has changed.

BUG=941561

Change-Id: I5ac1656a037a6aaffeb4f64b103c4daec28be39a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1613921
Reviewed-by: Joel Einbinder <einbinder@chromium.org>
Reviewed-by: Alexei Filippov <alph@chromium.org>
Commit-Queue: Lorne Mitchell <lomitch@microsoft.com>
Cr-Original-Commit-Position: refs/heads/master@{#662371}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 2f05fdbf2ab3458b4b3a3f2a86f908a3a7d04f79
2019-05-22 21:58:44 +00:00