1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 const { LocalizationHelper
} = require("resource://devtools/shared/l10n.js");
8 const helper
= new LocalizationHelper(
9 "devtools/client/locales/webconsole.properties"
14 * Generates a formatted timestamp string for displaying in console messages.
16 * @param integer [milliseconds]
17 * Optional, allows you to specify the timestamp in milliseconds since
20 * The timestamp formatted for display.
22 timestampString(milliseconds
) {
23 const d
= new Date(milliseconds
? milliseconds
: null);
24 const hours
= d
.getHours();
25 const minutes
= d
.getMinutes();
26 const seconds
= d
.getSeconds();
27 milliseconds
= d
.getMilliseconds();
28 const parameters
= [hours
, minutes
, seconds
, milliseconds
];
29 return l10n
.getFormatStr("timestampFormat", parameters
);
33 * Retrieve a localized string.
36 * The string name you want from the Web Console string bundle.
38 * The localized string.
42 return helper
.getStr(name
);
44 console
.error("Failed to get string: " + name
);
50 * Retrieve a localized string formatted with values coming from the given
54 * The string name you want from the Web Console string bundle.
56 * The array of values you want in the formatted string.
58 * The formatted local string.
60 getFormatStr(name
, array
) {
62 return helper
.getFormatStr(name
, ...array
);
64 console
.error("Failed to format string: " + name
);
70 module
.exports
= l10n
;