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.
7 * @fileoverview Testing stub for messages.
10 goog.provide('cvox.TestMsgs');
12 goog.require('cvox.AbstractMsgs');
13 goog.require('cvox.HostFactory');
14 goog.require('cvox.TestMessages');
20 * @extends {cvox.AbstractMsgs}
22 cvox.TestMsgs = function() {
23 cvox.AbstractMsgs.call(this);
25 goog.inherits(cvox.TestMsgs, cvox.AbstractMsgs);
29 * Return the current locale.
30 * @return {string} The locale.
32 cvox.TestMsgs.prototype.getLocale = function() {
38 * Returns the message with the given message id from the ChromeVox namespace.
40 * @param {string} message_id The id.
41 * @param {Array.<string>} opt_subs Substitution strings.
42 * @return {string} The message.
44 cvox.TestMsgs.prototype.getMsg = function(message_id, opt_subs) {
46 throw Error('Message id required');
48 var message = cvox.TestMessages[('chromevox_' + message_id).toUpperCase()];
49 if (message == undefined) {
50 throw Error('missing-msg: ' + message_id);
53 var messageString = message.message;
55 // Unshift a null to make opt_subs and message.placeholders line up.
56 for (var i = 0; i < opt_subs.length; i++) {
57 messageString = messageString.replace('$' + (i + 1), opt_subs[i]);
65 * Retuns a number formatted correctly.
67 * @param {number} num The number.
68 * @return {string} The number in the correct locale.
70 cvox.TestMsgs.prototype.getNumber = function(num) {
75 * Cosntructor for the host factory.
77 cvox.HostFactory.msgsConstructor = cvox.TestMsgs;