about:startup - handle application brand name and localizable extension names correctly

This commit is contained in:
Daniel Brooks 2010-09-18 17:54:32 -04:00
parent 479c0e8aeb
commit e66665f40c
3 changed files with 31 additions and 29 deletions

View File

@ -5,16 +5,14 @@ let stringsvc = Components.classes["@mozilla.org/intl/stringbundle;1"]
.getService(Components.interfaces.nsIStringBundleService); .getService(Components.interfaces.nsIStringBundleService);
let strings = stringsvc.createBundle("chrome://global/locale/aboutStartup.properties"); let strings = stringsvc.createBundle("chrome://global/locale/aboutStartup.properties");
let branding = stringsvc.createBundle("chrome://branding/locale/brand.properties"); let branding = stringsvc.createBundle("chrome://branding/locale/brand.properties");
let brandShortName = branding.GetStringFromName("brandShortName");
function displayTimestamp(id, µs) document.getElementById(id).textContent = formatstamp(µs); function displayTimestamp(id, µs) document.getElementById(id).textContent = formatstamp(µs);
function displayDuration(id, µs) document.getElementById(id).nextSibling.textContent = formatms(msFromµs(µs)); function displayDuration(id, µs) document.getElementById(id).nextSibling.textContent = formatms(msFromµs(µs));
function formatStr(str, args) strings.formatStringFromName("about.startup."+ str, args, args.length); function formatStr(str, args) strings.formatStringFromName("about.startup."+ str, args, args.length);
function appVersion(version, build) formatStr("appVersion", function appVersion(version, build) formatStr("appVersion", [brandShortName, version, build]);
[branding.getStringFromName("brandShortName"), function formatExtension(str, name, version) formatStr("extension"+str, [name, version]);
// ["Firefox",
version, build]);
function formatExtension(str, id, version) formatStr("extension"+str, [id, version]);
function msFromµs(µs) µs / 1000; function msFromµs(µs) µs / 1000;
function formatstamp(µs) new Date(msFromµs(µs)); function formatstamp(µs) new Date(msFromµs(µs));
@ -207,6 +205,8 @@ function populateEvents()
query.executeAsync({ query.executeAsync({
handleResult: function(results) handleResult: function(results)
{
Application.getExtensions(function (extensions)
{ {
let table = document.getElementById("events-table"); let table = document.getElementById("events-table");
for (let row = results.getNextRow(); row; row = results.getNextRow()) for (let row = results.getNextRow(); row; row = results.getNextRow())
@ -214,10 +214,11 @@ function populateEvents()
hasresults = true; hasresults = true;
let stamp = row.getResultByName("timestamp"), let stamp = row.getResultByName("timestamp"),
id = row.getResultByName("id"), id = row.getResultByName("id"),
name = row.getResultByName("name"), extension = extensions.get(id),
name = extension ? extension.name : row.getResultByName("name"),
version = row.getResultByName("version"), version = row.getResultByName("version"),
action = row.getResultByName("action"); action = row.getResultByName("action");
alert([id, name, row.getResultByName("name")].toSource());
options.grid.markings.push(extensionMark(stamp, formatExtension(action, name, version))); options.grid.markings.push(extensionMark(stamp, formatExtension(action, name, version)));
table.appendChild(tr(td(formatstamp(stamp)), table.appendChild(tr(td(formatstamp(stamp)),
@ -228,6 +229,7 @@ function populateEvents()
} }
if (hasresults) if (hasresults)
$("#events-table > .empty").hide(); $("#events-table > .empty").hide();
});
}, },
handleError: function(error) handleError: function(error)
{ {

View File

@ -58,7 +58,7 @@
<th>&about.startup.extensionID;</th> <th>&about.startup.extensionID;</th>
<th>&about.startup.version;</th> <th>&about.startup.version;</th>
</tr> </tr>
<tr class="empty"><td colspan="2"><i>&about.startup.noevents;</i></td></tr> <tr class="empty"><td colspan="5"><i>&about.startup.noevents;</i></td></tr>
</table> </table>
</div> </div>
<script type="application/javascript;version=1.8" src="chrome://global/content/aboutStartup.js"/> <script type="application/javascript;version=1.8" src="chrome://global/content/aboutStartup.js"/>

View File

@ -4,19 +4,19 @@
about.startup.appVersion=%1$S %2$S (%3$S) about.startup.appVersion=%1$S %2$S (%3$S)
# LOCALIZATION NOTE (about.startup.extensionInstalled): %1$S will be # LOCALIZATION NOTE (about.startup.extensionInstalled): %1$S will be
# the name of an extension, and %2$S will be its version number # the name of an extension, and %2$S will be its version number
about.startup.extensionInstalled=%1$S %1$2 installed about.startup.extensionInstalled=%1$S %2$S installed
# LOCALIZATION NOTE (about.startup.extensionUninstalled): %1$S will be # LOCALIZATION NOTE (about.startup.extensionUninstalled): %1$S will be
# the name of an extension, and %2$S will be its version number # the name of an extension, and %2$S will be its version number
about.startup.extensionUninstalled=%1$S %1$2 uninstalled about.startup.extensionUninstalled=%1$S %2$S uninstalled
# LOCALIZATION NOTE (about.startup.extensionUpgraded): %1$S will be # LOCALIZATION NOTE (about.startup.extensionUpgraded): %1$S will be
# the name of an extension, and %2$S will be its version number # the name of an extension, and %2$S will be its version number
about.startup.extensionUpgraded=%1$S upgraded to %1$2 about.startup.extensionUpgraded=%1$S upgraded to %2$S
# LOCALIZATION NOTE (about.startup.extensionEnabled): %1$S will be the # LOCALIZATION NOTE (about.startup.extensionEnabled): %1$S will be the
# name of an extension, and %2$S will be its version number # name of an extension, and %2$S will be its version number
about.startup.extensionEnabled=%1$S %1$2 enabled about.startup.extensionEnabled=%1$S %2$S enabled
# LOCALIZATION NOTE (about.startup.extensionDisabled): %1$S will be # LOCALIZATION NOTE (about.startup.extensionDisabled): %1$S will be
# the name of an extension, and %2$S will be its version number # the name of an extension, and %2$S will be its version number
about.startup.extensionDisabled=%1$S %1$2 disabled about.startup.extensionDisabled=%1$S %2$S disabled
# LOCALIZATION NOTE (about.startup.milliseconds): formats a number # LOCALIZATION NOTE (about.startup.milliseconds): formats a number
# (%1$S) as milliseconds # (%1$S) as milliseconds
about.startup.milliseconds=%1$S ms about.startup.milliseconds=%1$S ms