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 3// found in the LICENSE file. 4 5 6/** 7 * @fileoverview Testing stub for messages. 8 */ 9 10goog.provide('cvox.TestMsgs'); 11 12goog.require('cvox.Msgs'); 13goog.require('cvox.TestMessages'); 14 15 16/** 17 * @constructor 18 * @extends {cvox.Msgs} 19 */ 20cvox.TestMsgs = function() { 21 cvox.Msgs.call(this); 22}; 23goog.inherits(cvox.TestMsgs, cvox.Msgs); 24 25 26/** 27 * @override 28 */ 29cvox.TestMsgs.prototype.getLocale = function() { 30 return 'testing'; 31}; 32 33 34/** 35 * @override 36 */ 37cvox.TestMsgs.prototype.getMsg = function(messageId, opt_subs) { 38 if (!messageId) { 39 throw Error('Message id required'); 40 } 41 var message = cvox.TestMessages[('chromevox_' + messageId).toUpperCase()]; 42 if (message == undefined) { 43 throw Error('missing-msg: ' + messageId); 44 } 45 46 var messageString = message.message; 47 if (opt_subs) { 48 // Unshift a null to make opt_subs and message.placeholders line up. 49 for (var i = 0; i < opt_subs.length; i++) { 50 messageString = messageString.replace('$' + (i + 1), opt_subs[i]); 51 } 52 } 53 return messageString; 54}; 55