0

ui: don't mangle URLs with --mangle-localized-strings

This debugging switch adds special padding to every localized string,
to make debugging localization layout and clipping issues easier.
Some localized strings shouldn't be mangled though because they aren't
actually prose strings but rather other localized data. This CL has
the mangling logic not mangle URLs.

Bug: 1093821
Change-Id: I50abab16467e7f92098fc766dfbd276bf9519cee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2241500
Reviewed-by: Chris Palmer <palmer@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#777514}
This commit is contained in:
Elly Fong-Jones
2020-06-11 22:05:21 +00:00
committed by Commit Bot
parent 45d487339e
commit b461ba8c07
2 changed files with 8 additions and 0 deletions
ui/base

@ -15,4 +15,5 @@ include_rules = [
"+ui/resources/grit/webui_resources.h",
"+ui/strings/grit/app_locale_settings.h",
"+ui/strings/grit/ui_strings.h",
"+url"
]

@ -46,6 +46,7 @@
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_skia_source.h"
#include "ui/strings/grit/app_locale_settings.h"
#include "url/gurl.h"
#if defined(OS_ANDROID)
#include "base/android/build_info.h"
@ -503,6 +504,12 @@ base::string16 ResourceBundle::MaybeMangleLocalizedString(
if (base::StringToInt(str, &ignored))
return str;
// IDS_WEBSTORE_URL and some other resources are localization "strings" that
// are actually URLs, where the "localized" part is actually just the language
// code embedded in the URL. Don't mangle any URL.
if (GURL(str).is_valid())
return str;
// For a string S, produce [[ --- S --- ]], where the number of dashes is 1/4
// of the number of characters in S. This makes S something around 50-75%
// longer, except for extremely short strings, which get > 100% longer.