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 /** | 6 /** |
7 * @fileoverview Testing stub for messages. | 7 * @fileoverview Testing stub for messages. |
8 */ | 8 */ |
9 | 9 |
10 goog.provide('TestMsgs'); | 10 goog.provide('TestMsgs'); |
(...skipping 28 matching lines...) Expand all Loading... |
39 * @param {string} messageId | 39 * @param {string} messageId |
40 * @param {Array<string>=} opt_subs | 40 * @param {Array<string>=} opt_subs |
41 * @return {string} | 41 * @return {string} |
42 */ | 42 */ |
43 TestMsgs.getMsg = function(messageId, opt_subs) { | 43 TestMsgs.getMsg = function(messageId, opt_subs) { |
44 if (!messageId) { | 44 if (!messageId) { |
45 throw Error('Message id required'); | 45 throw Error('Message id required'); |
46 } | 46 } |
47 var messageString = TestMsgs.Untranslated[messageId.toUpperCase()]; | 47 var messageString = TestMsgs.Untranslated[messageId.toUpperCase()]; |
48 if (messageString === undefined) { | 48 if (messageString === undefined) { |
49 var messageObj = cvox.TestMessages[( | 49 var messageObj = |
50 'chromevox_' + messageId).toUpperCase()]; | 50 cvox.TestMessages[('chromevox_' + messageId).toUpperCase()]; |
51 if (messageObj === undefined) | 51 if (messageObj === undefined) |
52 throw Error('missing-msg: ' + messageId); | 52 throw Error('missing-msg: ' + messageId); |
53 var messageString = messageObj.message; | 53 var messageString = messageObj.message; |
54 var placeholders = messageObj.placeholders; | 54 var placeholders = messageObj.placeholders; |
55 if (placeholders) { | 55 if (placeholders) { |
56 for (name in placeholders) { | 56 for (name in placeholders) { |
57 messageString = messageString.replace( | 57 messageString = |
58 '$' + name + '$', | 58 messageString.replace('$' + name + '$', placeholders[name].content); |
59 placeholders[name].content); | |
60 } | 59 } |
61 } | 60 } |
62 } | 61 } |
63 return Msgs.applySubstitutions_(messageString, opt_subs); | 62 return Msgs.applySubstitutions_(messageString, opt_subs); |
64 }; | 63 }; |
65 | 64 |
66 /** | 65 /** |
67 * @param {number} num | 66 * @param {number} num |
68 * @return {string} | 67 * @return {string} |
69 */ | 68 */ |
70 TestMsgs.getNumber = Msgs.getNumber; | 69 TestMsgs.getNumber = Msgs.getNumber; |
OLD | NEW |