Bug 1305737 - String changes to handle the cases where we don't have the device name for a sent tab. r=markh

MozReview-Commit-ID: Frt4KzfWPbZ

--HG--
extra : rebase_source : ad1a17290fc43ee16e7f7a1ee4db92ff920dfbc7
This commit is contained in:
Thom Chiovoloni 2016-10-21 15:00:59 -04:00
Родитель e35119fa12
Коммит 195cbc3450
2 изменённых файлов: 44 добавлений и 15 удалений

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

@ -2350,15 +2350,33 @@ BrowserGlue.prototype = {
const deviceName = Weave.Service.clientsEngine.getClientName(URIs[0].clientId);
const bundle = Services.strings.createBundle("chrome://browser/locale/accounts.properties");
if (URIs.length == 1) {
title = bundle.GetStringFromName("tabArrivingNotification.title");
const pageTitle = URIs[0].title || firstTab.linkedBrowser.contentTitle
|| URIs[0].uri;
body = bundle.formatStringFromName("tabArrivingNotification.body", [pageTitle, deviceName], 2);
// Due to bug 1305895, tabs from iOS may not have device information, so
// we have separate strings to handle those cases. (See Also
// unnamedTabsArrivingNotificationNoDevice.body below)
if (deviceName) {
title = bundle.formatStringFromName("tabArrivingNotificationWithDevice.title", [deviceName], 1);
} else {
title = bundle.GetStringFromName("tabArrivingNotification.title");
}
// Use the page URL as the body. We strip the fragment and query to
// reduce size, and also format it the same way that the url bar would.
body = URIs[0].uri.replace(/[?#].*$/, "");
if (win.gURLBar) {
body = win.gURLBar.trimValue(body);
}
} else {
title = bundle.GetStringFromName("tabsArrivingNotification.title");
const tabArrivingBody = URIs.every(URI => URI.clientId == URIs[0].clientId) ?
"unnamedTabsArrivingNotification.body" :
"unnamedTabsArrivingNotificationMultiple.body";
const allSameDevice = URIs.every(URI => URI.clientId == URIs[0].clientId);
const unknownDevice = allSameDevice && !deviceName;
let tabArrivingBody;
if (unknownDevice) {
tabArrivingBody = "unnamedTabsArrivingNotificationNoDevice.body";
} else if (allSameDevice) {
tabArrivingBody = "unnamedTabsArrivingNotification2.body";
} else {
tabArrivingBody = "unnamedTabsArrivingNotificationMultiple2.body"
}
body = bundle.GetStringFromName(tabArrivingBody);
body = PluralForm.get(URIs.length, body);
body = body.replace("#1", URIs.length);

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

@ -39,21 +39,32 @@ deviceDisconnectedNotification.body = This computer has been successfully discon
# Displayed in the Send Tabs context menu when right clicking a tab, a page or a link.
sendTabToAllDevices.menuitem = All Devices
# LOCALIZATION NOTE (tabArrivingNotification.title, tabArrivingNotification.body,
# tabsArrivingNotification.title, tabsArrivingNotification.body)
# LOCALIZATION NOTE (tabArrivingNotification.title, tabArrivingNotificationWithDevice.title,
# tabsArrivingNotification.title, unnamedTabsArrivingNotification2.body,
# unnamedTabsArrivingNotificationMultiple2.body, unnamedTabsArrivingNotificationNoDevice.body)
# These strings are used in a notification shown when we're opening tab(s) another device sent us to display.
# LOCALIZATION NOTE (tabArrivingNotification.title, tabArrivingNotificationWithDevice.title)
# The body for these is the URL of the tab recieved
tabArrivingNotification.title = Tab received
# LOCALIZATION NOTE (tabArrivingNotification.body) %1 is the title of the tab and %2 is the device name.
tabArrivingNotification.body = “%1$S” has arrived from %2$S.
# LOCALIZATION NOTE (tabArrivingNotificationWithDevice.title) %S is the device name
tabArrivingNotificationWithDevice.title = Tab from %S
tabsArrivingNotification.title = Multiple tabs received
# LOCALIZATION NOTE (unnamedTabsArrivingNotification.body):
# LOCALIZATION NOTE (unnamedTabsArrivingNotification2.body):
# Semi-colon list of plural forms.
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
# #1 is the number of tabs received and #2 is the device name.
unnamedTabsArrivingNotification.body = #1 tab has arrived from #2.;#1 tabs have arrived from #2.
# LOCALIZATION NOTE (unnamedTabsArrivingNotificationMultiple.body):
unnamedTabsArrivingNotification2.body = #1 tab has arrived from #2;#1 tabs have arrived from #2
# LOCALIZATION NOTE (unnamedTabsArrivingNotificationMultiple2.body):
# Semi-colon list of plural forms.
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
# #1 is the number of tabs received.
unnamedTabsArrivingNotificationMultiple.body = #1 tab has arrived from your connected devices.;#1 tabs have arrived from your connected devices.
unnamedTabsArrivingNotificationMultiple2.body = #1 tab has arrived from your connected devices;#1 tabs have arrived from your connected devices
# LOCALIZATION NOTE (unnamedTabsArrivingNotificationNoDevice.body):
# Semi-colon list of plural forms.
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
# #1 is the number of tabs received
# This version is used when we don't know any device names.
unnamedTabsArrivingNotificationNoDevice.body = #1 tab has arrived;#1 tabs have arrived