blob: caeea3621311347282ffa7d8b107f44e8e17578e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
/**
* The local strings get injected into the page usig a varaible named
* {@code templateData}. This class provides a simpler interface to access those
* strings.
* @constructor
*/
function LocalStrings() {
}
/**
* Gets a localized string by its id.
* @param {string} s The id of the string we want.
* @return {string} The localized string.
*/
LocalStrings.prototype.getString = function(s) {
return templateData[s] || '';
};
/**
* Returns a formatted localized string (where all %s contents are replaced
* by the second argument).
* @param {string} s The id of the string we want.
* @param {string} d The string to include in the formatted string.
* @return {string} The formatted string.
*/
LocalStrings.prototype.formatString = function(s, d) {
return this.getString(s).replace(/%s/, d);
};
|