0

[Grit] Change 'OTHER'-gender pak files to be just the default file.

Ie, now we'll have "x.pak", "x_FEMININE.pak", "x_MASCULINE.pak", and "x_NEUTER.pak".

Bug: 416291329
Change-Id: Ia9afbb19863993c1a7b57af16ce8bcd6f35a8564
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6546244
Owners-Override: Andrew Grieve <agrieve@chromium.org>
Commit-Queue: Glenn Hartmann <hartmanng@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1460225}
This commit is contained in:
Glenn Hartmann
2025-05-14 10:47:09 -07:00
committed by Chromium LUCI CQ
parent 6143841206
commit 09cc696f7e
17 changed files with 75 additions and 155 deletions
android_webview
build
chrome
android
browser
components
content/shell
device
bluetooth
strings
fido
strings
remoting/resources
services/strings
tools/grit
ui/resources

@ -860,17 +860,10 @@ if (_is_default_toolchain) {
renaming_sources = []
renaming_destinations = []
foreach(_locale, platform_pak_locales) {
if (translate_genders) {
renaming_sources += process_file_template(
all_chrome_genders,
"$root_out_dir/android_webview/locales/${_locale}_{{source_name_part}}.pak")
renaming_destinations += process_file_template(
all_chrome_genders,
"stored-locales/${_locale}_{{source_name_part}}.pak")
} else {
renaming_sources +=
[ "$root_out_dir/android_webview/locales/${_locale}.pak" ]
renaming_destinations += [ "stored-locales/${_locale}.pak" ]
foreach(_gender_suffix, gender_suffixes) {
renaming_sources += [ "$root_out_dir/android_webview/locales/${_locale}${_gender_suffix}.pak" ]
renaming_destinations +=
[ "stored-locales/${_locale}${_gender_suffix}.pak" ]
}
}
treat_as_locale_paks = true

@ -37,7 +37,6 @@ _LOCALES_SUBDIR = 'assets/locales/'
# that Chrome won't crash on startup if its bundle is installed on a device
# with an unsupported system locale (e.g. fur-rIT).
_FALLBACK_LOCALE = 'en-US'
_FALLBACK_LOCALE_WITH_GENDER = 'en-US_OTHER'
# List of split dimensions recognized by this tool.
_ALL_SPLIT_DIMENSIONS = [ 'ABI', 'SCREEN_DENSITY', 'LANGUAGE' ]
@ -297,7 +296,7 @@ def _RewriteLanguageAssetPath(src_path):
else:
android_language = android_locale
if locale in (_FALLBACK_LOCALE, _FALLBACK_LOCALE_WITH_GENDER):
if locale == _FALLBACK_LOCALE:
# Fallback locale .pak files must be placed in a different directory
# to ensure they are always stored in the base module.
result_path = 'assets/fallback-locales/%s.pak' % locale

@ -12,6 +12,13 @@ import("//build/config/chromeos/ui_mode.gni")
# pseudolocales, then use |locales_with_pseudolocales| or
# |locales_without_pseudolocales|.
declare_args() {
# pass the "--translate-genders" flag into GRIT to generate 4 translation
# files per locale ("", "_FEMININE", "_MASCULINE", "_NEUTER") instead of
# one.
translate_genders = false
}
# The following additional platform specific lists are created:
# - |extended_locales| list of locales not shipped on desktop builds
# - |android_bundle_locales_as_resources| locales formatted for XML output names
@ -109,13 +116,19 @@ all_chrome_locales =
"zu",
] + pseudolocales
all_chrome_genders = [
"OTHER",
"MASCULINE",
"FEMININE",
"NEUTER",
all_chrome_gender_suffixes = [
"", # The "OTHER" gender is the default - we omit it from the filename.
"_MASCULINE",
"_FEMININE",
"_NEUTER",
]
if (translate_genders) {
gender_suffixes = all_chrome_gender_suffixes
} else {
gender_suffixes = [ "" ]
}
if (is_ios) {
# Chrome on iOS uses "es-MX" and "pt" for "es-419" and "pt-BR".
all_chrome_locales -= [

@ -1822,17 +1822,9 @@ if (_is_default_toolchain) {
renaming_destinations = []
foreach(_locale, platform_pak_locales) {
if (translate_genders) {
renaming_sources += process_file_template(
all_chrome_genders,
"$target_gen_dir/${_variant}_paks/locales/${_locale}_{{source_name_part}}.pak")
renaming_destinations += process_file_template(
all_chrome_genders,
"locales/${_locale}_{{source_name_part}}.pak")
} else {
renaming_sources +=
[ "$target_gen_dir/${_variant}_paks/locales/${_locale}.pak" ]
renaming_destinations += [ "locales/${_locale}.pak" ]
foreach(_gender_suffix, gender_suffixes) {
renaming_sources += [ "$target_gen_dir/${_variant}_paks/locales/${_locale}${_gender_suffix}.pak" ]
renaming_destinations += [ "locales/${_locale}${_gender_suffix}.pak" ]
}
}
treat_as_locale_paks = true

@ -14,12 +14,6 @@ if (is_android) {
import("//build/config/android/rules.gni")
}
if (translate_genders) {
_gender_suffix = "_OTHER"
} else {
_gender_suffix = ""
}
assert(enable_vr)
component("vr_ui") {
@ -406,9 +400,9 @@ source_set("vr_gl_test_support") {
repack("vr_test_pak") {
sources = [
"$root_gen_dir/chrome/generated_resources_en-US${_gender_suffix}.pak",
"$root_gen_dir/chrome/generated_resources_en-US.pak",
"$root_gen_dir/components/components_resources.pak",
"$root_gen_dir/components/strings/components_strings_en-US${_gender_suffix}.pak",
"$root_gen_dir/components/strings/components_strings_en-US.pak",
]
output = "$root_out_dir/vr_test.pak"

@ -34,12 +34,6 @@ if (is_ios) {
import("//ios/build/config.gni")
}
if (translate_genders) {
_gender_suffix = "_OTHER"
} else {
_gender_suffix = ""
}
if (is_ios) {
bundle_data("components_tests_pak_bundle_data") {
testonly = true
@ -923,11 +917,11 @@ repack("components_tests_pak") {
"$root_gen_dir/components/autofill/core/browser/geo/autofill_address_rewriter_resources.pak",
"$root_gen_dir/components/components_resources.pak",
"$root_gen_dir/components/metrics/metrics_server_urls.pak",
"$root_gen_dir/components/omnibox/resources/omnibox_pedal_synonyms_en-US${_gender_suffix}.pak",
"$root_gen_dir/components/plus_addresses/resources/strings/plus_addresses_strings_en-US${_gender_suffix}.pak",
"$root_gen_dir/components/strings/components_branded_strings_en-US${_gender_suffix}.pak",
"$root_gen_dir/components/strings/components_locale_settings_en-US${_gender_suffix}.pak",
"$root_gen_dir/components/strings/components_strings_en-US${_gender_suffix}.pak",
"$root_gen_dir/components/omnibox/resources/omnibox_pedal_synonyms_en-US.pak",
"$root_gen_dir/components/plus_addresses/resources/strings/plus_addresses_strings_en-US.pak",
"$root_gen_dir/components/strings/components_branded_strings_en-US.pak",
"$root_gen_dir/components/strings/components_locale_settings_en-US.pak",
"$root_gen_dir/components/strings/components_strings_en-US.pak",
]
output = "$root_out_dir/components_tests_resources.pak"

@ -38,12 +38,6 @@ if (is_android) {
import("//content/shell/app/ios/extensions.gni")
}
if (translate_genders) {
_gender_suffix = "_OTHER"
} else {
_gender_suffix = ""
}
# TODO(crbug.com/1336055, spang): Investigate using shell_views with cast builds as
# true.
shell_use_toolkit_views = toolkit_views && !is_castos
@ -539,14 +533,14 @@ repack("pak") {
"$root_gen_dir/third_party/blink/public/resources/blink_resources.pak",
"$root_gen_dir/third_party/blink/public/resources/blink_scaled_resources_100_percent.pak",
"$root_gen_dir/third_party/blink/public/resources/inspector_overlay_resources.pak",
"$root_gen_dir/third_party/blink/public/strings/blink_strings_en-US${_gender_suffix}.pak",
"$root_gen_dir/third_party/blink/public/strings/blink_strings_en-US.pak",
"$root_gen_dir/third_party/blink/public/strings/permission_element_generated_strings.pak",
"$root_gen_dir/third_party/blink/public/strings/permission_element_strings_en-US${_gender_suffix}.pak",
"$root_gen_dir/third_party/blink/public/strings/permission_element_strings_en-US.pak",
"$root_gen_dir/ui/resources/ui_resources_100_percent.pak",
"$root_gen_dir/ui/strings/app_locale_settings_en-US${_gender_suffix}.pak",
"$root_gen_dir/ui/strings/auto_image_annotation_strings_en-US${_gender_suffix}.pak",
"$root_gen_dir/ui/strings/ax_strings_en-US${_gender_suffix}.pak",
"$root_gen_dir/ui/strings/ui_strings_en-US${_gender_suffix}.pak",
"$root_gen_dir/ui/strings/app_locale_settings_en-US.pak",
"$root_gen_dir/ui/strings/auto_image_annotation_strings_en-US.pak",
"$root_gen_dir/ui/strings/ax_strings_en-US.pak",
"$root_gen_dir/ui/strings/ui_strings_en-US.pak",
"$root_gen_dir/ui/webui/resources/webui_resources.pak",
]

@ -13,12 +13,8 @@ grit_strings("strings") {
}
repack("bluetooth_test_strings") {
if (translate_genders) {
sources = [ "$root_gen_dir/device/bluetooth/strings/bluetooth_strings_en-US_OTHER.pak" ]
} else {
sources =
[ "$root_gen_dir/device/bluetooth/strings/bluetooth_strings_en-US.pak" ]
}
sources =
[ "$root_gen_dir/device/bluetooth/strings/bluetooth_strings_en-US.pak" ]
output = "$root_out_dir/bluetooth_test_strings.pak"
deps = [ ":strings" ]
}

@ -13,12 +13,7 @@ grit_strings("strings") {
}
repack("fido_test_strings") {
if (translate_genders) {
sources =
[ "$root_gen_dir/device/fido/strings/fido_strings_en-US_OTHER.pak" ]
} else {
sources = [ "$root_gen_dir/device/fido/strings/fido_strings_en-US.pak" ]
}
sources = [ "$root_gen_dir/device/fido/strings/fido_strings_en-US.pak" ]
output = "$root_out_dir/fido_test_strings.pak"
deps = [ ":strings" ]
}

@ -68,12 +68,9 @@ action("copy_locales") {
# will just expand to the locale name.
inputs = []
foreach(locale, remoting_locales) {
if (translate_genders) {
inputs += process_file_template(
all_chrome_genders,
"$root_gen_dir/remoting/resources/${locale}_{{source_name_part}}.pak")
} else {
inputs += [ "$root_gen_dir/remoting/resources/${locale}.pak" ]
foreach(_gender_suffix, gender_suffixes) {
inputs +=
[ "$root_gen_dir/remoting/resources/${locale}${_gender_suffix}.pak" ]
}
}
@ -83,23 +80,15 @@ action("copy_locales") {
# On mac, use underscores instead of hyphens and put the files in a
# different place.
foreach(locale, remoting_locales_with_underscores) {
if (translate_genders) {
outputs += process_file_template(
all_chrome_genders,
"$root_out_dir/remoting/resources/${locale}_{{source_name_part}}.lproj/locale.pak")
} else {
outputs +=
[ "$root_out_dir/remoting/resources/${locale}.lproj/locale.pak" ]
foreach(_gender_suffix, gender_suffixes) {
outputs += [ "$root_out_dir/remoting/resources/${locale}${_gender_suffix}.lproj/locale.pak" ]
}
}
} else {
foreach(locale, remoting_locales) {
if (translate_genders) {
outputs += process_file_template(
all_chrome_genders,
"$root_out_dir/remoting_locales/${locale}_{{source_name_part}}.pak")
} else {
outputs += [ "$root_out_dir/remoting_locales/${locale}.pak" ]
foreach(_gender_suffix, gender_suffixes) {
outputs +=
[ "$root_out_dir/remoting_locales/${locale}${_gender_suffix}.pak" ]
}
}
}

@ -15,12 +15,7 @@ grit_strings("strings") {
}
repack("services_test_strings") {
if (translate_genders) {
sources =
[ "$root_gen_dir/services/strings/services_strings_en-US_OTHER.pak" ]
} else {
sources = [ "$root_gen_dir/services/strings/services_strings_en-US.pak" ]
}
sources = [ "$root_gen_dir/services/strings/services_strings_en-US.pak" ]
output = "$root_out_dir/services_test_strings.pak"
deps = [ ":strings" ]
}

@ -114,19 +114,19 @@ class OutputNode(base.Node):
def _AddGenderToFilename(self, path):
assert self.GetType() == 'data_package' or self.GetType() == 'android'
if self.GetGender() == constants.DEFAULT_GENDER:
return path
if self.GetType() == 'data_package':
match = DATA_PACKAGE_FILENAME_RE.search(path)
assert match is not None, f'unrecognized data_package path: {path}'
return path.replace(match.group(),
f'{match.group(1)}_{self.GetGender()}.pak')
else: # self.GetType() == 'android'
if self.GetGender() == constants.DEFAULT_GENDER:
return path
else:
match = ANDROID_FILENAME_RE.search(path)
assert match is not None, f'unrecognized android path: {path}'
return path.replace(match.group(1),
f'{match.group(1)}-{self.GetGender()}')
match = ANDROID_FILENAME_RE.search(path)
assert match is not None, f'unrecognized android path: {path}'
return path.replace(match.group(1),
f'{match.group(1)}-{self.GetGender()}')
def MandatoryAttributes(self):
return ['filename', 'type']

@ -215,7 +215,7 @@ class FileNodeUnittest(unittest.TestCase):
'gender': None
},
{
'filename': 'translation_en_OTHER.pak',
'filename': 'translation_en.pak',
'gender': 'OTHER'
},
{
@ -231,7 +231,7 @@ class FileNodeUnittest(unittest.TestCase):
'gender': 'NEUTER'
},
{
'filename': 'resources/es_OTHER.pak',
'filename': 'resources/es.pak',
'gender': 'OTHER'
},
{

@ -82,9 +82,7 @@ class BuildUnittest(unittest.TestCase):
(dep_output_file, deps_string) = line.split(': ')
deps = deps_string.split(' ')
self.assertEqual(
"default_100_percent_OTHER.pak"
if translate_genders else "default_100_percent.pak", dep_output_file)
self.assertEqual("default_100_percent.pak", dep_output_file)
self.assertEqual(deps, [
util.PathFromRoot('grit/testdata/default_100_percent/a.png'),
util.PathFromRoot('grit/testdata/grit_part.grdp'),
@ -483,9 +481,7 @@ class BuildUnittest(unittest.TestCase):
header = output_dir.GetPath('allowlist_test_resources.h')
map_cc = output_dir.GetPath('allowlist_test_resources_map.cc')
map_h = output_dir.GetPath('allowlist_test_resources_map.h')
pak = output_dir.GetPath(
'allowlist_test_resources_OTHER.pak'
if translate_genders else 'allowlist_test_resources.pak')
pak = output_dir.GetPath('allowlist_test_resources.pak')
# Ensure the resource map header and .pak files exist, but don't verify
# their content.

@ -1,14 +1,6 @@
# Copyright 2014 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
declare_args() {
# pass the "--translate-genders" flag into GRIT to generate 4 translation
# files per locale ("_OTHER", "_FEMININE", "_MASCULINE", "_NEUTER") instead of
# one.
translate_genders = false
}
# Instantiate grit. This will produce a script target to run grit (named
# ${target_name}_grit), and a static library that compiles the .cc files.
#
@ -409,9 +401,9 @@ template("grit") {
# # This will expand into many language-and-gender (where applicable) files
# # and be added to |outputs|. For example, the final |outputs| parameter
# # passed into "grit" would look something like:
# # outputs = [ "foo_strings.h", "foo_strings_af_OTHER.pak",
# # outputs = [ "foo_strings.h", "foo_strings_af.pak",
# # "foo_strings_af_FEMININE.pak", "foo_strings_af_MASCULINE.pak",
# # "foo_strings_af_NEUTER.pak", "foo_strings_am_OTHER.pak", ... ]
# # "foo_strings_af_NEUTER.pak", "foo_strings_am.pak", ... ]
# locales = locales_with_pseudolocales
# output_prefix = "foo_strings_"
#
@ -449,12 +441,8 @@ template("grit_strings") {
_outputs = []
}
foreach(locale, _locales) {
if (translate_genders) {
_outputs += process_file_template(
all_chrome_genders,
"${_output_prefix}${locale}_{{source_name_part}}.pak")
} else {
_outputs += [ "${_output_prefix}${locale}.pak" ]
foreach(_gender_suffix, gender_suffixes) {
_outputs += [ "${_output_prefix}${locale}${_gender_suffix}.pak" ]
}
}

@ -148,12 +148,6 @@ template("repack_locales") {
# Collects all targets the loop generates.
_locale_targets = []
if (translate_genders) {
_genders = all_chrome_genders
} else {
_genders = [ "" ]
}
# This loop iterates over the input locales and also keeps a counter so it
# can simultaneously iterate over the output locales (using GN's very
# limited looping capabilities).
@ -161,13 +155,7 @@ template("repack_locales") {
foreach(_input_locale, invoker.input_locales) {
_output_locale = _output_locales[_current_index]
foreach(_gender, _genders) {
if (_gender == "") {
_gender_suffix = ""
} else {
_gender_suffix = "_${_gender}"
}
foreach(_gender_suffix, gender_suffixes) {
# Compute the name of the target for the current file. Save it for the deps.
_current_name = "${target_name}_${_input_locale}${_gender_suffix}"
_locale_targets += [ ":$_current_name" ]

@ -5,12 +5,6 @@
import("//tools/grit/grit_rule.gni")
import("//tools/grit/repack.gni")
if (translate_genders) {
_gender_suffix = "_OTHER"
} else {
_gender_suffix = ""
}
group("resources") {
public_deps = [
":ui_resources_grd",
@ -94,7 +88,7 @@ if (is_apple) {
} else {
copy("ui_test_pak") {
sources = [ "$root_out_dir/ui_test.pak" ]
outputs = [ "$root_out_dir/ui/en-US${_gender_suffix}.pak" ]
outputs = [ "$root_out_dir/ui/en-US.pak" ]
public_deps = [ ":repack_ui_test_pak_100_percent" ]
}
}
@ -120,9 +114,9 @@ repack("repack_ui_test_pak_100_percent") {
sources = [
"$root_gen_dir/mojo/public/js/mojo_bindings_resources.pak",
"$root_gen_dir/ui/resources/ui_resources_100_percent.pak",
"$root_gen_dir/ui/strings/app_locale_settings_en-US${_gender_suffix}.pak",
"$root_gen_dir/ui/strings/ax_strings_en-US${_gender_suffix}.pak",
"$root_gen_dir/ui/strings/ui_strings_en-US${_gender_suffix}.pak",
"$root_gen_dir/ui/strings/app_locale_settings_en-US.pak",
"$root_gen_dir/ui/strings/ax_strings_en-US.pak",
"$root_gen_dir/ui/strings/ui_strings_en-US.pak",
"$root_gen_dir/ui/webui/resources/webui_resources.pak",
]
@ -146,7 +140,7 @@ repack("repack_ui_test_pak_100_percent") {
if (is_chromeos) {
sources += [
"$root_gen_dir/ui/chromeos/resources/ui_chromeos_resources_100_percent.pak",
"$root_gen_dir/ui/chromeos/strings/ui_chromeos_strings_en-US${_gender_suffix}.pak",
"$root_gen_dir/ui/chromeos/strings/ui_chromeos_strings_en-US.pak",
]
deps += [
"//ui/chromeos/resources",
@ -187,9 +181,9 @@ repack("repack_ui_test_mac_locale_pack") {
visibility = [ ":ui_test_pak" ]
sources = [
"$root_gen_dir/ui/strings/app_locale_settings_en-US${_gender_suffix}.pak",
"$root_gen_dir/ui/strings/ax_strings_en-US${_gender_suffix}.pak",
"$root_gen_dir/ui/strings/ui_strings_en-US${_gender_suffix}.pak",
"$root_gen_dir/ui/strings/app_locale_settings_en-US.pak",
"$root_gen_dir/ui/strings/ax_strings_en-US.pak",
"$root_gen_dir/ui/strings/ui_strings_en-US.pak",
]
output = "$root_out_dir/ui/en.lproj/locale.pak"