Chromium Code Reviews| Index: chrome/browser/resources/chromeos/chromevox/chromevox/messages/msgs.js |
| diff --git a/chrome/browser/resources/chromeos/chromevox/chromevox/messages/msgs.js b/chrome/browser/resources/chromeos/chromevox/chromevox/messages/msgs.js |
| index 41fa7a2968a972d59d1ac580071165735e37a79d..7f726f08c894e050959a2ee8400f035b36b07a7c 100644 |
| --- a/chrome/browser/resources/chromeos/chromevox/chromevox/messages/msgs.js |
| +++ b/chrome/browser/resources/chromeos/chromevox/chromevox/messages/msgs.js |
| @@ -13,6 +13,11 @@ goog.provide('cvox.Msgs'); |
| * @constructor |
| */ |
| cvox.Msgs = function() { |
| + /** |
| + * @type {Object.<string, string>} |
| + * @private |
| + */ |
| + this.localeNameDict_ = null; |
| }; |
| @@ -82,3 +87,23 @@ cvox.Msgs.prototype.addTranslatedMessagesToDom = function(root) { |
| cvox.Msgs.prototype.getNumber = function(num) { |
| return '' + num; |
| }; |
| + |
| +/** |
| + * Gets a localized display name for a locale. |
| + * NOTE: Only a subset of locale identifiers are supported. See the |
|
David Tseng
2014/09/23 17:41:49
Do we have a test that attempts to retrieve displa
|
| + * |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. |
| + */ |
| +cvox.Msgs.prototype.getLocaleDisplayName = function(locale) { |
| + if (!this.localeNameDict_) { |
| + this.localeNameDict_ = /** @type {Object.<string, string>} */( |
| + JSON.parse(this.getMsg('locale_dict'))); |
| + } |
| + var name = this.localeNameDict_[locale]; |
| + if (!name) { |
| + throw Error('Unsupported locale identifier: ' + locale); |
| + } |
| + return name; |
| +}; |