OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview Defined the convenience function cvox.Msgs.getMsg. | 6 * @fileoverview Defined the convenience function cvox.Msgs.getMsg. |
7 */ | 7 */ |
8 | 8 |
9 goog.provide('cvox.AbstractMsgs'); | 9 goog.provide('cvox.AbstractMsgs'); |
10 | 10 |
11 | 11 |
12 | 12 |
13 /** | 13 /** |
14 * @constructor | 14 * @constructor |
15 */ | 15 */ |
16 cvox.AbstractMsgs = function() { }; | 16 cvox.AbstractMsgs = function() { |
17 /** | |
18 * @type {Object.<string, string>} | |
19 * @private | |
20 */ | |
21 this.localeNameDict_ = null; | |
22 }; | |
17 | 23 |
18 | 24 |
19 | 25 |
20 /** | 26 /** |
21 * Return the current locale. | 27 * Return the current locale. |
22 * @return {string} The locale. | 28 * @return {string} The locale. |
23 */ | 29 */ |
24 cvox.AbstractMsgs.prototype.getLocale = function() { }; | 30 cvox.AbstractMsgs.prototype.getLocale = function() { }; |
25 | 31 |
26 | 32 |
(...skipping 12 matching lines...) Expand all Loading... | |
39 | 45 |
40 | 46 |
41 /** | 47 /** |
42 * Retuns a number formatted correctly. | 48 * Retuns a number formatted correctly. |
43 * | 49 * |
44 * @param {number} num The number. | 50 * @param {number} num The number. |
45 * @return {string} The number in the correct locale. | 51 * @return {string} The number in the correct locale. |
46 */ | 52 */ |
47 cvox.AbstractMsgs.prototype.getNumber = function(num) { | 53 cvox.AbstractMsgs.prototype.getNumber = function(num) { |
48 }; | 54 }; |
55 | |
56 | |
57 /** | |
David Tseng
2014/09/19 23:13:39
Kind of odd to put this here. Why not place in Chr
| |
58 * Gets a localized display name for a locale. | |
59 * NOTE: Only a subset of locale identifiers are supported. See the | |
60 * |CHROMEVOX_LOCALE_DICT| message. | |
61 * @param {string} locale On the form |ll| or |ll_CC|, where |ll| is | |
62 * the language code and |CC| the country code. | |
63 * @return {string} The display name. | |
64 */ | |
65 cvox.AbstractMsgs.prototype.getLocaleDisplayName = function(locale) { | |
66 if (!this.localeNameDict_) { | |
67 this.localeNameDict_ = /** @type {Object.<string, string>} */( | |
68 JSON.parse(this.getMsg('locale_dict'))); | |
69 } | |
70 var name = this.localeNameDict_[locale]; | |
71 if (!name) { | |
72 throw Error('Unsupported locale identifier: ' + locale); | |
73 } | |
74 return name; | |
75 }; | |
OLD | NEW |