Create IsKnown* function for LanguageTag subtags [chromium/src : main]

0 views
Skip to first unread message

Greg Thompson (Gerrit)

unread,
Jul 7, 2026, 5:08:09 AM (yesterday) Jul 7
to Danilo Tedeschi, Chromium LUCI CQ, chromium...@chromium.org, jshin...@chromium.org
Attention needed from Danilo Tedeschi

Greg Thompson added 7 comments

File base/i18n/internal/BUILD.gn
Line 97, Patchset 9 (Latest):source_set("bcp47_subtags") {
Greg Thompson . unresolved

Please fix this WARNING reported by autoreview issue finding: It looks like this `source_set` is never used. The generator actions (`:bcp47_languages_gen`, etc.) are already included directly in the `public_deps` of the `"internal"` target above. You can safely remove this leftover target.

File base/i18n/internal/bcp47_known_subtags.h
Line 12, Patchset 9 (Latest):namespace base::i18n::internal {
Greg Thompson . unresolved

`i18n_internal` as per comment in other cl

File base/i18n/internal/bcp47_parser.h
Line 93, Patchset 9 (Latest):constexpr bool AreSubtagsKnown(const ParsedBcp47Tag& parsed_tag) {
Greg Thompson . unresolved

BCP 47 language tags are case-insensitive, but `ParseBcp47Tag` preserves the original case and the `IsKnown*` functions perform exact case-sensitive matches (e.g., `language` must be exactly lowercase, `script` titlecase).\n\nIf a user passes an unnormalized tag like `\"EN-US\"` to `ParseBcp47Tag`, this function will unexpectedly return `false` because `\"EN\"` doesn't match the known `\"en\"`.\n\nIs this intentional? If so, consider documenting that this function explicitly expects case-normalized subtags. Otherwise, we might need a case-insensitive lookup.

Line 14, Patchset 9 (Latest):#include "base/containers/fixed_flat_set.h"
Greg Thompson . unresolved

unused?

File tools/i18n/generate_known_bcp47_subtags.py
File-level comment, Patchset 9 (Latest):
Greg Thompson . unresolved

please:

add a .style.yapf to this directory containing:
```
[style]
based_on_style = pep8
```

and then format this file with git cl format --python --full as per https://chromium.googlesource.com/chromium/src/+/main/styleguide/python/python.md#yapf

and add a PRESUBMIT.py with the usual copyright header and something along the lines of:

```
PRESUBMIT_VERSION = '2.0.0'

def CheckPylint(input_api, output_api):
"""Runs pylint on all directory content and subdirectories."""
return input_api.RunTests(input_api.canned_checks.GetPylint(input_api, output_api, version='3.2'))
```

see agents/shared/PRESUBMIT.py for a recent example. maybe just copy that one as-is.

Line 68, Patchset 9 (Latest): if len(sys.argv) < 4:
print(
"Usage: generate_known_bcp47_subtags.py <output_file> <type> <enable_pseudolocales>"
)
sys.exit(1)

output_file = sys.argv[1]
subtag_type = sys.argv[2]
enable_pseudo = sys.argv[3] == "true"
Greg Thompson . unresolved

could you use `argparse` to do this nicely?

you can use the `description` trick (e.g., [see here](https://source.chromium.org/chromium/chromium/src/+/main:chrome/test/mini_installer/test_chrome_with_chromedriver.py;l=134)) so that the file-level docstring is the help text emitted by the script.

Line 86, Patchset 9 (Latest): subtags += _PSEUDO_REGIONS
Greg Thompson . unresolved

Please fix this WARNING reported by autoreview issue finding: This `+=` mutates the global `_REGIONS` list because `subtags` points to the same list. Although it doesn't affect correctness here since the script doesn't reuse `_REGIONS` and exits shortly after, it's safer to avoid mutating globals by creating a new list:\n```python\n subtags = _REGIONS + _PSEUDO_REGIONS\n```

Open in Gerrit

Related details

Attention is currently required from:
  • Danilo Tedeschi
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: If6786c0bef27109a0252f223c37de6d86492dbf2
Gerrit-Change-Number: 8047380
Gerrit-PatchSet: 9
Gerrit-Owner: Danilo Tedeschi <da...@google.com>
Gerrit-Reviewer: Danilo Tedeschi <da...@google.com>
Gerrit-Reviewer: Greg Thompson <g...@chromium.org>
Gerrit-Attention: Danilo Tedeschi <da...@google.com>
Gerrit-Comment-Date: Tue, 07 Jul 2026 09:07:53 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Danilo Tedeschi (Gerrit)

unread,
Jul 7, 2026, 1:08:46 PM (21 hours ago) Jul 7
to Greg Thompson, Chromium LUCI CQ, chromium...@chromium.org, jshin...@chromium.org
Attention needed from Greg Thompson

Danilo Tedeschi added 7 comments

File base/i18n/internal/BUILD.gn
Line 97, Patchset 9:source_set("bcp47_subtags") {
Greg Thompson . resolved

Please fix this WARNING reported by autoreview issue finding: It looks like this `source_set` is never used. The generator actions (`:bcp47_languages_gen`, etc.) are already included directly in the `public_deps` of the `"internal"` target above. You can safely remove this leftover target.

Danilo Tedeschi

Done

File base/i18n/internal/bcp47_known_subtags.h
Line 12, Patchset 9:namespace base::i18n::internal {
Greg Thompson . resolved

`i18n_internal` as per comment in other cl

Danilo Tedeschi

Done

File base/i18n/internal/bcp47_parser.h
Line 93, Patchset 9:constexpr bool AreSubtagsKnown(const ParsedBcp47Tag& parsed_tag) {
Greg Thompson . resolved

BCP 47 language tags are case-insensitive, but `ParseBcp47Tag` preserves the original case and the `IsKnown*` functions perform exact case-sensitive matches (e.g., `language` must be exactly lowercase, `script` titlecase).\n\nIf a user passes an unnormalized tag like `\"EN-US\"` to `ParseBcp47Tag`, this function will unexpectedly return `false` because `\"EN\"` doesn't match the known `\"en\"`.\n\nIs this intentional? If so, consider documenting that this function explicitly expects case-normalized subtags. Otherwise, we might need a case-insensitive lookup.

Danilo Tedeschi

I will add a comment and maybe add normalization later. I just don't want to end up with GetKnownLanguageTag("EN").tag_string() == "EN"

Line 14, Patchset 9:#include "base/containers/fixed_flat_set.h"
Greg Thompson . resolved

unused?

Danilo Tedeschi

Done

File tools/i18n/generate_known_bcp47_subtags.py
File-level comment, Patchset 9:
Greg Thompson . resolved

please:

add a .style.yapf to this directory containing:
```
[style]
based_on_style = pep8
```

and then format this file with git cl format --python --full as per https://chromium.googlesource.com/chromium/src/+/main/styleguide/python/python.md#yapf

and add a PRESUBMIT.py with the usual copyright header and something along the lines of:

```
PRESUBMIT_VERSION = '2.0.0'

def CheckPylint(input_api, output_api):
"""Runs pylint on all directory content and subdirectories."""
return input_api.RunTests(input_api.canned_checks.GetPylint(input_api, output_api, version='3.2'))
```

see agents/shared/PRESUBMIT.py for a recent example. maybe just copy that one as-is.

Danilo Tedeschi

Done

Line 68, Patchset 9: if len(sys.argv) < 4:

print(
"Usage: generate_known_bcp47_subtags.py <output_file> <type> <enable_pseudolocales>"
)
sys.exit(1)

output_file = sys.argv[1]
subtag_type = sys.argv[2]
enable_pseudo = sys.argv[3] == "true"
Greg Thompson . resolved

could you use `argparse` to do this nicely?

you can use the `description` trick (e.g., [see here](https://source.chromium.org/chromium/chromium/src/+/main:chrome/test/mini_installer/test_chrome_with_chromedriver.py;l=134)) so that the file-level docstring is the help text emitted by the script.

Danilo Tedeschi

Done

Line 86, Patchset 9: subtags += _PSEUDO_REGIONS
Greg Thompson . resolved

Please fix this WARNING reported by autoreview issue finding: This `+=` mutates the global `_REGIONS` list because `subtags` points to the same list. Although it doesn't affect correctness here since the script doesn't reuse `_REGIONS` and exits shortly after, it's safer to avoid mutating globals by creating a new list:\n```python\n subtags = _REGIONS + _PSEUDO_REGIONS\n```

Danilo Tedeschi

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Greg Thompson
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: If6786c0bef27109a0252f223c37de6d86492dbf2
    Gerrit-Change-Number: 8047380
    Gerrit-PatchSet: 10
    Gerrit-Owner: Danilo Tedeschi <da...@google.com>
    Gerrit-Reviewer: Danilo Tedeschi <da...@google.com>
    Gerrit-Reviewer: Greg Thompson <g...@chromium.org>
    Gerrit-Attention: Greg Thompson <g...@chromium.org>
    Gerrit-Comment-Date: Tue, 07 Jul 2026 17:08:34 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Greg Thompson <g...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Greg Thompson (Gerrit)

    unread,
    2:53 AM (7 hours ago) 2:53 AM
    to Danilo Tedeschi, Chromium LUCI CQ, chromium...@chromium.org, jshin...@chromium.org
    Attention needed from Danilo Tedeschi

    Greg Thompson voted Code-Review+1

    Code-Review+1
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Danilo Tedeschi
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: If6786c0bef27109a0252f223c37de6d86492dbf2
      Gerrit-Change-Number: 8047380
      Gerrit-PatchSet: 10
      Gerrit-Owner: Danilo Tedeschi <da...@google.com>
      Gerrit-Reviewer: Danilo Tedeschi <da...@google.com>
      Gerrit-Reviewer: Greg Thompson <g...@chromium.org>
      Gerrit-Attention: Danilo Tedeschi <da...@google.com>
      Gerrit-Comment-Date: Wed, 08 Jul 2026 06:52:59 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      open
      diffy
      Reply all
      Reply to author
      Forward
      0 new messages