Index: chrome/browser/resources/chromeos/chromevox/host/interface/abstract_msgs.js |
diff --git a/chrome/browser/resources/chromeos/chromevox/host/interface/abstract_msgs.js b/chrome/browser/resources/chromeos/chromevox/host/interface/abstract_msgs.js |
index c23594ff9367f5662453bbec4cefa925404c2e2c..7d82e032f71c1a5d4fbbc527a7a0f08d225fdfd8 100644 |
--- a/chrome/browser/resources/chromeos/chromevox/host/interface/abstract_msgs.js |
+++ b/chrome/browser/resources/chromeos/chromevox/host/interface/abstract_msgs.js |
@@ -13,7 +13,13 @@ goog.provide('cvox.AbstractMsgs'); |
/** |
* @constructor |
*/ |
-cvox.AbstractMsgs = function() { }; |
+cvox.AbstractMsgs = function() { |
+ /** |
+ * @type {Object.<string, string>} |
+ * @private |
+ */ |
+ this.localeNameDict_ = null; |
+}; |
@@ -46,3 +52,24 @@ cvox.AbstractMsgs.prototype.getMsg = function(message_id, opt_subs) { |
*/ |
cvox.AbstractMsgs.prototype.getNumber = function(num) { |
}; |
+ |
+ |
+/** |
David Tseng
2014/09/19 23:13:39
Kind of odd to put this here. Why not place in Chr
|
+ * 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. |
+ */ |
+cvox.AbstractMsgs.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; |
+}; |