Commit 9790bb05 authored by Akihiro Ota's avatar Akihiro Ota Committed by Commit Bot

Fix blank display name for yue-HK in TTS settings page.

This is a temporary fix for the blank display name for yue-HK. The
reason we were returning a blank string is because we were calling
GetDisplayNameForLocale() with the disallow_default parameter. Remove
this parameter so we at least get a return value.

Please see the bug for more context.

readable text label on TTS settings page.

Bug: 1136353
Change-Id: I123c05134782e90c8b297fea6c48287e7fc5dd8c
AX-Relnotes: Fix an issue where the Yue (Hong Kong) voice had no
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2463600
Commit-Queue: Akihiro Ota <akihiroota@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816296}
parent 0abf04ae
...@@ -63,21 +63,26 @@ RequestResult AccessibilityPrivateHooksDelegate::HandleGetDisplayNameForLocale( ...@@ -63,21 +63,26 @@ RequestResult AccessibilityPrivateHooksDelegate::HandleGetDisplayNameForLocale(
const std::string display_locale = const std::string display_locale =
gin::V8ToString(script_context->isolate(), parsed_arguments[1]); gin::V8ToString(script_context->isolate(), parsed_arguments[1]);
std::string locale_result = bool found_valid_result = false;
base::UTF16ToUTF8(l10n_util::GetDisplayNameForLocale( std::string locale_result;
locale, display_locale, true /* is_ui */, if (l10n_util::IsValidLocaleSyntax(locale) &&
true /* disallow_default */)); l10n_util::IsValidLocaleSyntax(display_locale)) {
locale_result = base::UTF16ToUTF8(l10n_util::GetDisplayNameForLocale(
RequestResult result(RequestResult::HANDLED); locale, display_locale, true /* is_ui */));
// Check for valid locales before getting the display name.
// The ICU Locale class returns "und" for undetermined locales, and
// returns the locale string directly if it has no translation.
// Treat these cases as invalid results.
found_valid_result =
locale_result != kUndeterminedLocale && locale_result != locale;
}
// Instead of returning "und", which is what the ICU Locale class returns for // We return an empty string to communicate that we could not determine
// undetermined locales, we would simply like to return an empty string to // the display locale.
// communicate that we could not determine the display locale. In addition, if (!found_valid_result)
// ICU returns the |locale| as |result_locale| if it has no translation for a
// valid locale. Also return an empty string for that case.
if (locale_result == kUndeterminedLocale || locale_result == locale)
locale_result = std::string(); locale_result = std::string();
RequestResult result(RequestResult::HANDLED);
result.return_value = result.return_value =
gin::StringToV8(script_context->isolate(), locale_result); gin::StringToV8(script_context->isolate(), locale_result);
return result; return result;
......
...@@ -9,6 +9,9 @@ var allTests = [function testGetDisplayNameForLocale() { ...@@ -9,6 +9,9 @@ var allTests = [function testGetDisplayNameForLocale() {
chrome.test.assertEq( chrome.test.assertEq(
'English', 'English',
chrome.accessibilityPrivate.getDisplayNameForLocale('en', 'en')); chrome.accessibilityPrivate.getDisplayNameForLocale('en', 'en'));
chrome.test.assertEq(
'yue (Hong Kong)',
chrome.accessibilityPrivate.getDisplayNameForLocale('yue-HK', 'en'));
chrome.test.succeed(); chrome.test.succeed();
}]; }];
chrome.test.runTests(allTests); chrome.test.runTests(allTests);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment