зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1011093 - wordsmith webapp update notifications to reduce fear factor; r=blassey, f=ibarlow
--HG-- extra : rebase_source : c3af39a2d274d4fab1218ae8760761ad019591bb
This commit is contained in:
Родитель
6899d83b0c
Коммит
dc5f91d8f6
|
@ -8,27 +8,29 @@ checkingForUpdatesMessage=Checking for updates to your apps
|
|||
noUpdatesTitle=No updates available
|
||||
noUpdatesMessage=There are no updates to your apps
|
||||
|
||||
# LOCALIZATION NOTE (downloadUpdateTitle): Semi-colon list of plural forms.
|
||||
# LOCALIZATION NOTE (retrieveUpdateTitle): Semi-colon list of plural forms.
|
||||
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
|
||||
# #1 is the number of updates.
|
||||
# example: 3 new updates
|
||||
downloadUpdateTitle=#1 new update;#1 new updates
|
||||
# example: 3 new updates available
|
||||
retrieveUpdateTitle=#1 new update available;#1 new updates available
|
||||
|
||||
# LOCALIZATION NOTE (downloadUpdateMessage):
|
||||
# %S is a comma-separated list of apps for which to download an update.
|
||||
# example: Touch to download Foo, Bar, Baz.
|
||||
downloadUpdateMessage=Touch to download %S
|
||||
# LOCALIZATION NOTE (retrieveUpdateMessage): Semi-colon list of plural forms.
|
||||
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
|
||||
# %1$S is a comma-separated list of apps for which to retrieve an update.
|
||||
# example: Touch to retrieve updates for Foo, Bar, Baz
|
||||
retrieveUpdateMessage=Touch to retrieve update for %1$S;Touch to retrieve updates for %1$S
|
||||
|
||||
# LOCALIZATION NOTE (downloadingUpdateTitle): Semi-colon list of plural forms.
|
||||
# LOCALIZATION NOTE (retrievingUpdateTitle): Semi-colon list of plural forms.
|
||||
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
|
||||
# #1 is the number of updates.
|
||||
# example: Downloading 3 updates…
|
||||
downloadingUpdateTitle=Downloading #1 update…;Downloading #1 updates…
|
||||
# example: Retrieving 3 updates…
|
||||
retrievingUpdateTitle=Retrieving #1 update…;Retrieving #1 updates…
|
||||
|
||||
# LOCALIZATION NOTE (downloadingUpdateMessage):
|
||||
# %S is a comma-separated list of apps for which we're downloading updates.
|
||||
# example: Downloading Foo, Bar, Baz.
|
||||
downloadingUpdateMessage=Downloading %S
|
||||
# LOCALIZATION NOTE (retrievingUpdateMessage): Semi-colon list of plural forms.
|
||||
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
|
||||
# %1$S is a comma-separated list of apps for which we're retrieving updates.
|
||||
# example: Retrieving updates for Foo, Bar, Baz
|
||||
retrievingUpdateMessage=Retrieving update for %1$S; Retrieving updates for %1$S
|
||||
|
||||
# LOCALIZATION NOTE (installUpdateTitle): Semi-colon list of plural forms.
|
||||
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
|
||||
|
@ -36,18 +38,20 @@ downloadingUpdateMessage=Downloading %S
|
|||
# example: 3 updates downloaded
|
||||
installUpdateTitle=#1 update downloaded;#1 updates downloaded
|
||||
|
||||
# LOCALIZATION NOTE (installUpdateMessage):
|
||||
# %S is a comma-separated list of apps for which to install an update.
|
||||
# example: Touch to install Foo, Bar, Baz.
|
||||
installUpdateMessage=Touch to install %S
|
||||
# LOCALIZATION NOTE (installUpdateMessage2): Semi-colon list of plural forms.
|
||||
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
|
||||
# %1$S is a comma-separated list of apps for which to install an update.
|
||||
# example: Touch to install updates for Foo, Bar, Baz
|
||||
installUpdateMessage2=Touch to install update for %1$S;Touch to install updates for %1$S
|
||||
|
||||
# LOCALIZATION NOTE (downloadFailedTitle): Semi-colon list of plural forms.
|
||||
# LOCALIZATION NOTE (retrievalFailedTitle): Semi-colon list of plural forms.
|
||||
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
|
||||
# #1 is the number of updates.
|
||||
# example: 3 downloads failed
|
||||
downloadFailedTitle=#1 download failed;#1 downloads failed
|
||||
# example: 3 updates failed
|
||||
retrievalFailedTitle=#1 update failed;#1 updates failed
|
||||
|
||||
# LOCALIZATION NOTE (downloadFailedMessage):
|
||||
# %S is a comma-separated list of apps for which a download failed.
|
||||
# example: Failed to download Foo, Bar, Baz.
|
||||
downloadFailedMessage=Failed to download %S
|
||||
# LOCALIZATION NOTE (retrievalFailedMessage): Semi-colon list of plural forms.
|
||||
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
|
||||
# %1$S is a comma-separated list of apps for which retrieval failed.
|
||||
# example: Failed to retrieve updates for Foo, Bar, Baz
|
||||
retrievalFailedMessage=Failed to retrieve update for %1$S;Failed to retrieve updates for %1$S
|
||||
|
|
|
@ -29,6 +29,31 @@ XPCOMUtils.defineLazyGetter(this, "Strings", function() {
|
|||
return Services.strings.createBundle("chrome://browser/locale/webapp.properties");
|
||||
});
|
||||
|
||||
/**
|
||||
* Get the formatted plural form of a string. Escapes semicolons in arguments
|
||||
* to provide to the formatter before formatting the string, then unescapes them
|
||||
* after getting its plural form, to avoid tripping up the plural form getter
|
||||
* with a semicolon in one of the formatter's arguments, since the plural forms
|
||||
* of localized strings are delimited by semicolons.
|
||||
*
|
||||
* Ideally, we'd get the plural form first and then format the string,
|
||||
* so we wouldn't have to escape/unescape the semicolons; but that would require
|
||||
* changes to nsIStringBundle and PluralForm.jsm.
|
||||
*
|
||||
* @param stringName {String} the string to get the formatted plural form of
|
||||
* @param formatterArgs {Array} of {String} args to provide to the formatter
|
||||
* @param pluralNum {Number} the number that determines the plural form
|
||||
* @returns {String} the formatted plural form of the string
|
||||
*/
|
||||
function getFormattedPluralForm(stringName, formatterArgs, pluralNum) {
|
||||
// Escape semicolons by replacing them with ESC characters.
|
||||
let escapedArgs = [arg.replace(/;/g, String.fromCharCode(0x1B)) for (arg of formatterArgs)];
|
||||
let formattedString = Strings.formatStringFromName(stringName, escapedArgs, escapedArgs.length);
|
||||
let pluralForm = PluralForm.get(pluralNum, formattedString);
|
||||
let unescapedString = pluralForm.replace(String.fromCharCode(0x1B), ";", "g");
|
||||
return unescapedString;
|
||||
}
|
||||
|
||||
let Log = Cu.import("resource://gre/modules/AndroidLog.jsm", {}).AndroidLog;
|
||||
let debug = Log.d.bind(null, "WebappManager");
|
||||
|
||||
|
@ -319,9 +344,9 @@ this.WebappManager = {
|
|||
} else {
|
||||
let names = [manifestUrlToApp[url].name for (url of outdatedApps)].join(", ");
|
||||
let accepted = yield this._notify({
|
||||
title: PluralForm.get(outdatedApps.length, Strings.GetStringFromName("downloadUpdateTitle")).
|
||||
title: PluralForm.get(outdatedApps.length, Strings.GetStringFromName("retrieveUpdateTitle")).
|
||||
replace("#1", outdatedApps.length),
|
||||
message: Strings.formatStringFromName("downloadUpdateMessage", [names], 1),
|
||||
message: getFormattedPluralForm("retrieveUpdateMessage", [names], outdatedApps.length),
|
||||
icon: "drawable://alert_app",
|
||||
}).dismissed;
|
||||
|
||||
|
@ -403,9 +428,9 @@ this.WebappManager = {
|
|||
// Notify the user that we're in the progress of downloading updates.
|
||||
let downloadingNames = [app.name for (app of aApps)].join(", ");
|
||||
let notification = this._notify({
|
||||
title: PluralForm.get(aApps.length, Strings.GetStringFromName("downloadingUpdateTitle")).
|
||||
title: PluralForm.get(aApps.length, Strings.GetStringFromName("retrievingUpdateTitle")).
|
||||
replace("#1", aApps.length),
|
||||
message: Strings.formatStringFromName("downloadingUpdateMessage", [downloadingNames], 1),
|
||||
message: getFormattedPluralForm("retrievingUpdateMessage", [downloadingNames], aApps.length),
|
||||
icon: "drawable://alert_download_animation",
|
||||
// TODO: make this a determinate progress indicator once we can determine
|
||||
// the sizes of the APKs and observe their progress.
|
||||
|
@ -435,9 +460,9 @@ this.WebappManager = {
|
|||
if (downloadFailedApps.length > 0) {
|
||||
let downloadFailedNames = [app.name for (app of downloadFailedApps)].join(", ");
|
||||
this._notify({
|
||||
title: PluralForm.get(downloadFailedApps.length, Strings.GetStringFromName("downloadFailedTitle")).
|
||||
title: PluralForm.get(downloadFailedApps.length, Strings.GetStringFromName("retrievalFailedTitle")).
|
||||
replace("#1", downloadFailedApps.length),
|
||||
message: Strings.formatStringFromName("downloadFailedMessage", [downloadFailedNames], 1),
|
||||
message: getFormattedPluralForm("retrievalFailedMessage", [downloadFailedNames], downloadFailedApps.length),
|
||||
icon: "drawable://alert_app",
|
||||
});
|
||||
}
|
||||
|
@ -453,7 +478,7 @@ this.WebappManager = {
|
|||
let accepted = yield this._notify({
|
||||
title: PluralForm.get(downloadedApks.length, Strings.GetStringFromName("installUpdateTitle")).
|
||||
replace("#1", downloadedApks.length),
|
||||
message: Strings.formatStringFromName("installUpdateMessage", [downloadedNames], 1),
|
||||
message: getFormattedPluralForm("installUpdateMessage2", [downloadedNames], downloadedApks.length),
|
||||
icon: "drawable://alert_app",
|
||||
}).dismissed;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче