From 049c1e90c287e1dc819e7a54b840ac475cd0c566 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Wed, 7 Nov 2018 12:53:13 -0500 Subject: [PATCH] Fix localization in Brave web-ui pages Fix https://github.com/brave/brave-browser/issues/2035 --- app/BUILD.gn | 7 +++ app/brave_generated_resources.grd | 56 ++++++++++++++++++ brave_paks.gni | 1 - brave_repack_locales.gni | 14 +++++ components/resources/BUILD.gn | 8 ++- .../resources/brave_components_strings.grd | 59 ++++++++++++++++++- .../chrome-chrome_repack_locales.gni.patch | 28 +++++++++ 7 files changed, 168 insertions(+), 5 deletions(-) create mode 100644 brave_repack_locales.gni create mode 100644 patches/chrome-chrome_repack_locales.gni.patch diff --git a/app/BUILD.gn b/app/BUILD.gn index 11935687d3bc..6fc0362d0e85 100644 --- a/app/BUILD.gn +++ b/app/BUILD.gn @@ -1,4 +1,5 @@ import("//build/config/features.gni") +import("//build/config/locales.gni") import("//tools/grit/grit_rule.gni") source_set("command_ids") { @@ -12,8 +13,14 @@ grit("brave_generated_resources_grit") { output_dir = "$root_gen_dir/brave" outputs = [ "grit/brave_generated_resources.h", + # This is needed for the includes and not the localized messages "brave_generated_resources.pak", ] + + foreach(locale, locales_with_fake_bidi) { + outputs += [ "brave_generated_resources_$locale.pak" ] + } + resource_ids = "//brave/browser/resources/resource_ids" } diff --git a/app/brave_generated_resources.grd b/app/brave_generated_resources.grd index be62eb05c9aa..3eed76887480 100644 --- a/app/brave_generated_resources.grd +++ b/app/brave_generated_resources.grd @@ -6,6 +6,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/brave_paks.gni b/brave_paks.gni index fe7fb7a30dba..fd832c11a1f7 100644 --- a/brave_paks.gni +++ b/brave_paks.gni @@ -58,7 +58,6 @@ template("brave_extra_paks") { "$root_gen_dir/brave/brave_unscaled_resources.pak", "$root_gen_dir/brave/browser/resources/brave_settings_resources.pak", "$root_gen_dir/components/brave_components_resources.pak", - "$root_gen_dir/components/brave_components_strings.pak", "$root_gen_dir/brave/components/brave_rewards/resources/brave_rewards_resources.pak", "$root_gen_dir/brave/components/brave_rewards/resources/extension/brave_rewards_extension_resources.pak", "$target_gen_dir/browser/resources/brave_extension.pak", diff --git a/brave_repack_locales.gni b/brave_repack_locales.gni new file mode 100644 index 000000000000..69e0faeb1b31 --- /dev/null +++ b/brave_repack_locales.gni @@ -0,0 +1,14 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this file, +# You can obtain one at http://mozilla.org/MPL/2.0/. + + +brave_locale_source_patterns = [ + "${root_gen_dir}/components/brave_components_strings_", + "${root_gen_dir}/brave/brave_generated_resources_", +] + +brave_locale_deps = [ + "//brave/app:brave_generated_resources_grit", + "//brave/components/resources:strings", +] diff --git a/components/resources/BUILD.gn b/components/resources/BUILD.gn index 033d777d7470..a6604dcfd89d 100644 --- a/components/resources/BUILD.gn +++ b/components/resources/BUILD.gn @@ -1,5 +1,6 @@ -import("//tools/grit/grit_rule.gni") import("//brave/components/brave_rewards/browser/buildflags/buildflags.gni") +import("//build/config/locales.gni") +import("//tools/grit/grit_rule.gni") if (!is_android) { grit("resources") { @@ -41,9 +42,12 @@ grit("strings") { outputs = [ "grit/brave_components_strings.h", - "brave_components_strings.pak", ] + foreach(locale, locales_with_fake_bidi) { + outputs += [ "brave_components_strings_$locale.pak" ] + } + output_dir = "$root_gen_dir/components" resource_ids = "//brave/browser/resources/resource_ids" } diff --git a/components/resources/brave_components_strings.grd b/components/resources/brave_components_strings.grd index 38ecf9b63d3f..01ac32c3b646 100644 --- a/components/resources/brave_components_strings.grd +++ b/components/resources/brave_components_strings.grd @@ -1,10 +1,65 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/patches/chrome-chrome_repack_locales.gni.patch b/patches/chrome-chrome_repack_locales.gni.patch new file mode 100644 index 000000000000..6212de6c55a8 --- /dev/null +++ b/patches/chrome-chrome_repack_locales.gni.patch @@ -0,0 +1,28 @@ +diff --git a/chrome/chrome_repack_locales.gni b/chrome/chrome_repack_locales.gni +index dd37d98b467ec9bcf5ac5fd59ac56e43412a19fa..5a200e64670e4004041934eec9a23675de6d7e4d 100644 +--- a/chrome/chrome_repack_locales.gni ++++ b/chrome/chrome_repack_locales.gni +@@ -2,6 +2,7 @@ + # Use of this source code is governed by a BSD-style license that can be + # found in the LICENSE file. + ++import("//brave/brave_repack_locales.gni") + import("//build/config/chrome_build.gni") + import("//build/config/features.gni") + import("//build/config/ui.gni") +@@ -35,6 +36,7 @@ template("chrome_repack_locales") { + "${root_gen_dir}/ui/strings/app_locale_settings_", + "${root_gen_dir}/ui/strings/ui_strings_", + ] ++ source_patterns += brave_locale_source_patterns + if (!defined(deps)) { + deps = [] + } +@@ -51,6 +53,7 @@ template("chrome_repack_locales") { + "//ui/strings:app_locale_settings", + "//ui/strings:ui_strings", + ] ++ deps += brave_locale_deps + if (defined(invoker.deps)) { + deps += invoker.deps + }