Commit 3724eeec authored by David Tseng's avatar David Tseng Committed by Commit Bot

Remove locale dictionary in ChromeVox

Test: browser_tests --gtest_filter=ChromeVoxBrailleTableTest.*
Bug: b/150635270
Change-Id: I8cb685af0fc84f913711f0b2e4d0e5744669db9b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2109821Reviewed-by: default avatarAkihiro Ota <akihiroota@chromium.org>
Commit-Queue: David Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751801}
parent 1dcf2967
......@@ -115,7 +115,9 @@ BrailleTable.getUncontracted = function(tables, table) {
* @return {string} Localized display name.
*/
BrailleTable.getDisplayName = function(table) {
const localeName = Msgs.getLocaleDisplayName(table.locale);
const localeName = chrome.accessibilityPrivate.getDisplayNameForLocale(
table.locale /* locale to be displayed */,
chrome.i18n.getUILanguage().toLowerCase() /* locale to localize into */);
if (!table.grade && !table.variant) {
return localeName;
} else if (table.grade && !table.variant) {
......
......@@ -42,6 +42,9 @@ TEST_F('ChromeVoxBrailleTableTest', 'testGetDisplayName', function() {
expectEquals('Arabic, Grade 1', BrailleTable.getDisplayName(table));
table = BrailleTable.forId(tables, 'en-UEB-g1');
expectEquals('English (UEB), Grade 1', BrailleTable.getDisplayName(table));
table = BrailleTable.forId(tables, 'en-US-g2');
expectEquals(
'English (United States), Grade 2', BrailleTable.getDisplayName(table));
}));
});
......
......@@ -78,27 +78,6 @@ Msgs = class {
return '' + num;
}
/**
* Gets a localized display name for a locale.
* NOTE: Only a subset of locale identifiers are supported. See the
* |CHROMEVOX_LOCALE_DICT| message.
* @param {string} locale On the form |ll| or |ll_CC|, where |ll| is
* the language code and |CC| the country code.
* @return {string} The display name.
*/
static getLocaleDisplayName(locale) {
if (!Msgs.localeNameDict_) {
Msgs.localeNameDict_ =
/** @type {!Object<string>} */ (
JSON.parse(Msgs.getMsg('locale_dict')));
}
const name = Msgs.localeNameDict_[locale];
if (!name) {
throw Error('Unsupported locale identifier: ' + locale);
}
return name;
}
/**
* Applies substitions of the form $N, where N is a number from 1 to 9, to a
* string. The numbers are one-based indices into |opt_subs|.
......@@ -125,14 +104,6 @@ Msgs = class {
*/
Msgs.NAMESPACE_ = 'chromevox_';
/**
* Dictionary of locale names.
* @type {Object<string>}
* @private
*/
Msgs.localeNameDict_ = null;
/**
* Strings that are displayed in the user interface but don't need
* be translated.
......
......@@ -2482,91 +2482,6 @@
<message desc="Brailled to describe an access key. An access key consists of a single letter. When pressed along with a modifier (usually alt, but depends on platform), a targetted node will be activated. When translating, stick to lower case." name="IDS_CHROMEVOX_ACCESS_KEY_BRL">
access key:<ph name="key">$1</ph>
</message>
<message desc="A dictionary mapping locale identifiers to their corresponding language names. The format is the following: { ..., 'en_US': 'English (United States)', ...}. Translation only needed for the language and country names (e.g. English (United States)). All other strings must be kept as is." name="IDS_CHROMEVOX_LOCALE_DICT">
{"ar": "Arabic",
"as": "Assamese",
"aw": "Awadhi",
"be": "Bengali",
"bg": "Bulgarian",
"bh": "Bihari",
"bo": "Tibetan",
"br": "Braj",
"ca": "Catalan",
"ckb": "Sorani",
"cs": "Czech",
"cy": "Welsh",
"da": "Danish",
"de": "German",
"de_CH": "German (Switzerland)",
"de_DE": "German (Germany)",
"dra": "Dravidian",
"el": "Greek",
"en": "English",
"en_CA": "English (Canada)",
"en_GB": "English (United Kingdom)",
"en_US": "English (United States)",
"eo": "Esperanto",
"es": "Spanish",
"et": "Estonian",
"fa": "Persian",
"fr": "French",
"fr_CA": "French (Canada)",
"fr_FR": "French (France)",
"fi": "Finnish",
"ga": "Irish",
"gd": "Gaelic",
"gon": "Gondi",
"gu": "Gujarati",
"he": "Hebrew",
"hi": "Hindi",
"hr": "Croatian",
"hu": "Hungarian",
"hy": "Armenian",
"is": "Icelandic",
"it": "Italian",
"iu": "Inuktitut",
"ka": "Kannada",
"kh": "Khasi",
"ko": "Korean",
"kok": "Konkani",
"kru": "Kurukh",
"ks": "Kashmiri",
"lt": "Lithuanian",
"lv": "Latvian",
"mao": "Maori",
"ml": "Malayalam",
"mt": "Maltese",
"mwr": "Marwari",
"mn": "Mongolian",
"mun": "Munda",
"nb": "Norwegian Bokmål",
"ne": "Nepali",
"nl": "Dutch",
"no": "Norwegian",
"or": "Oriya",
"pi": "Pali",
"pl": "Polish",
"pt": "Portuguese",
"pu": "Punjabi",
"ro": "Romanian",
"ru": "Russian",
"sa": "Sanskrit",
"si": "Sindhi",
"sin": "Sinhala",
"sk": "Slovak",
"sl": "Slovenian",
"sr": "Serbian",
"sv": "Swedish",
"ta": "Tamil",
"te": "Telugu",
"tr": "Turkish",
"tsn": "Afrikaans",
"uk": "Ukrainian",
"ur": "Urdu",
"vi": "Vietnamese",
"zh": "Chinese",
"zh_TW": "Chinese (Traditional Han)"}
</message>
<message desc="The text to speak when the user moves their cursor to the end of a block of editable text, in verbose mode." name="IDS_CHROMEVOX_END_OF_TEXT_VERBOSE">
End of text
</message>
......
......@@ -116,7 +116,9 @@ cvox.BrailleTable.getUncontracted = function(tables, table) {
* @return {string} Localized display name.
*/
cvox.BrailleTable.getDisplayName = function(table) {
var localeName = Msgs.getLocaleDisplayName(table.locale);
var localeName = chrome.accessibilityPrivate.getDisplayNameForLocale(
table.locale /* locale to be displayed */,
chrome.i18n.getUILanguage().toLowerCase() /* locale to localize into */);
if (!table.grade && !table.variant) {
return localeName;
} else if (table.grade && !table.variant) {
......
......@@ -22,13 +22,6 @@ Msgs = function() {};
*/
Msgs.NAMESPACE_ = 'chromevox_';
/**
* Dictionary of locale names.
* @type {Object<string>}
* @private
*/
Msgs.localeNameDict_ = null;
/**
* Return the current locale.
* @return {string} The locale.
......@@ -95,26 +88,6 @@ Msgs.getNumber = function(num) {
return '' + num;
};
/**
* Gets a localized display name for a locale.
* NOTE: Only a subset of locale identifiers are supported. See the
* |CHROMEVOX_LOCALE_DICT| message.
* @param {string} locale On the form |ll| or |ll_CC|, where |ll| is
* the language code and |CC| the country code.
* @return {string} The display name.
*/
Msgs.getLocaleDisplayName = function(locale) {
if (!Msgs.localeNameDict_) {
Msgs.localeNameDict_ = /** @type {!Object<string>} */(
JSON.parse(this.getMsg('locale_dict')));
}
var name = Msgs.localeNameDict_[locale];
if (!name) {
throw Error('Unsupported locale identifier: ' + locale);
}
return name;
};
/**
* Applies substitions of the form $N, where N is a number from 1 to 9, to a
* string. The numbers are one-based indices into |opt_subs|.
......
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