Bug 580454 - Localize console timestamps, r+a=dietrich

This commit is contained in:
Patrick Walton 2010-09-10 15:08:05 -03:00
Родитель 8b12be5ffe
Коммит 370c01e636
5 изменённых файлов: 48 добавлений и 17 удалений

Просмотреть файл

@ -49,7 +49,7 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
var EXPORTED_SYMBOLS = ["HUDService"];
var EXPORTED_SYMBOLS = ["HUDService", "ConsoleUtils"];
XPCOMUtils.defineLazyServiceGetter(this, "scriptError",
"@mozilla.org/scripterror;1",
@ -4625,23 +4625,11 @@ ConsoleUtils = {
*/
timestampString: function ConsoleUtils_timestampString(ms)
{
// TODO: L10N see bug 568656
var d = new Date(ms ? ms : null);
function pad(n, mil)
{
if (mil) {
return n < 100 ? "0" + n : n;
}
else {
return n < 10 ? "0" + n : n;
}
}
return pad(d.getHours()) + ":"
+ pad(d.getMinutes()) + ":"
+ pad(d.getSeconds()) + ":"
+ pad(d.getMilliseconds(), true);
let hours = d.getHours(), minutes = d.getMinutes();
let seconds = d.getSeconds(), milliseconds = d.getMilliseconds();
let parameters = [ hours, minutes, seconds, milliseconds ];
return HUDService.getFormatStr("timestampFormat", parameters);
},
/**

Просмотреть файл

@ -50,6 +50,7 @@ _BROWSER_TEST_FILES = \
browser_webconsole_bug_585237_line_limit.js \
browser_webconsole_bug_586388_select_all.js \
browser_webconsole_bug_588967_input_expansion.js \
browser_webconsole_bug_580454_timestamp_l10n.js \
browser_webconsole_netlogging.js \
browser_webconsole_bug_593003_iframe_wrong_hud.js \
browser_webconsole_bug_581231_close_button.js \

Просмотреть файл

@ -54,6 +54,16 @@ XPCOMUtils.defineLazyGetter(this, "HUDService", function () {
}
});
XPCOMUtils.defineLazyGetter(this, "ConsoleUtils", function () {
Cu.import("resource://gre/modules/HUDService.jsm");
try {
return ConsoleUtils;
}
catch (ex) {
dump(ex + "\n");
}
});
let log = function _log(msg) {
dump("*** HUD Browser Test Log: " + msg + "\n");
};

Просмотреть файл

@ -0,0 +1,29 @@
/* vim:set ts=2 sw=2 sts=2 et: */
/* ***** BEGIN LICENSE BLOCK *****
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*
* Contributor(s):
* Patrick Walton <pcwalton@mozilla.com>
*
* ***** END LICENSE BLOCK ***** */
// Tests that appropriately-localized timestamps are printed.
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/HUDService.jsm");
function test() {
const TEST_TIMESTAMP = 12345678;
let date = new Date(TEST_TIMESTAMP);
let localizedString = ConsoleUtils.timestampString(TEST_TIMESTAMP);
isnot(localizedString.indexOf(date.getHours()), -1, "the localized " +
"timestamp contains the hours");
isnot(localizedString.indexOf(date.getMinutes()), -1, "the localized " +
"timestamp contains the minutes");
isnot(localizedString.indexOf(date.getSeconds()), -1, "the localized " +
"timestamp contains the seconds");
isnot(localizedString.indexOf(date.getMilliseconds()), -1, "the localized " +
"timestamp contains the milliseconds");
}

Просмотреть файл

@ -65,6 +65,9 @@ copyCmd.label=Copy
copyCmd.accesskey=C
selectAllCmd.label=Select All
selectAllCmd.accesskey=A
# LOCALIZATION NOTE (timestampFormat): %1$02S = hours (24-hour clock),
# %2$02S = minutes, %3$02S = seconds, %4$03S = milliseconds.
timestampFormat=%02S:%02S:%02S.%03S
helperFuncUnsupportedTypeError=Can't call pprint on this type of object.
# LOCALIZATION NOTE (networkUrlWithStatus):