Move various item pane strings to Fluent (#4329)
And: - Accept Fluent l10nId/l10nArgs in ItemMessagePane#render() - Reuse existing <description> tag to eliminate l10n flickering
This commit is contained in:
parent
006c6e890a
commit
f79a59f56a
7 changed files with 38 additions and 37 deletions
|
@ -27,7 +27,7 @@
|
||||||
class DuplicatesMergePane extends XULElementBase {
|
class DuplicatesMergePane extends XULElementBase {
|
||||||
content = MozXULElement.parseXULToFragment(`
|
content = MozXULElement.parseXULToFragment(`
|
||||||
<groupbox>
|
<groupbox>
|
||||||
<button id="zotero-duplicates-merge-button" />
|
<button id="zotero-duplicates-merge-button" data-l10n-id="item-pane-duplicates-merge-items" />
|
||||||
</groupbox>
|
</groupbox>
|
||||||
|
|
||||||
<groupbox id="zotero-duplicates-merge-version-select">
|
<groupbox id="zotero-duplicates-merge-version-select">
|
||||||
|
@ -84,7 +84,7 @@
|
||||||
if (itemTypeID != item.itemTypeID) {
|
if (itemTypeID != item.itemTypeID) {
|
||||||
let msg;
|
let msg;
|
||||||
if (displayNumItemsOnTypeError) {
|
if (displayNumItemsOnTypeError) {
|
||||||
msg = Zotero.getString('pane.item.selected.multiple', items.length);
|
msg = { l10nId: 'item-pane-message-items-selected', l10nArgs: { count: items.length } };
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
msg = Zotero.getString('pane.item.duplicates.onlySameItemType');
|
msg = Zotero.getString('pane.item.duplicates.onlySameItemType');
|
||||||
|
@ -136,7 +136,7 @@
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
button.label = Zotero.getString('pane.item.duplicates.mergeItems', (otherItems.length + 1));
|
document.l10n.setArgs(button, { count: otherItems.length + 1 });
|
||||||
versionSelect.hidden = fieldSelect.hidden = !alternatives;
|
versionSelect.hidden = fieldSelect.hidden = !alternatives;
|
||||||
itembox.hiddenFields = alternatives ? [] : ['dateAdded', 'dateModified'];
|
itembox.hiddenFields = alternatives ? [] : ['dateAdded', 'dateModified'];
|
||||||
// Since the header of the collapsible section is hidden, the section has to be opened
|
// Since the header of the collapsible section is hidden, the section has to be opened
|
||||||
|
|
|
@ -37,8 +37,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
render(content) {
|
render(content) {
|
||||||
this._messageBox.textContent = '';
|
|
||||||
if (typeof content == 'string') {
|
if (typeof content == 'string') {
|
||||||
|
this._messageBox.replaceChildren();
|
||||||
let contentParts = content.split("\n\n");
|
let contentParts = content.split("\n\n");
|
||||||
for (let part of contentParts) {
|
for (let part of contentParts) {
|
||||||
let desc = document.createXULElement('description');
|
let desc = document.createXULElement('description');
|
||||||
|
@ -46,8 +46,18 @@
|
||||||
this._messageBox.appendChild(desc);
|
this._messageBox.appendChild(desc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (typeof content === 'object' && 'l10nId' in content) {
|
||||||
|
let { l10nId, l10nArgs } = content;
|
||||||
|
if (this._messageBox.firstElementChild?.localName === 'description') {
|
||||||
|
this._messageBox.replaceChildren(this._messageBox.firstElementChild);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this._messageBox.replaceChildren(document.createXULElement('description'));
|
||||||
|
}
|
||||||
|
document.l10n.setAttributes(this._messageBox.firstElementChild, l10nId, l10nArgs);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
this._messageBox.appendChild(content);
|
this._messageBox.replaceChildren(content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -202,7 +202,7 @@
|
||||||
msg = Zotero.getString('pane.item.duplicates.writeAccessRequired');
|
msg = Zotero.getString('pane.item.duplicates.writeAccessRequired');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
msg = Zotero.getString('pane.item.selected.zero');
|
msg = { l10nId: 'item-pane-message-items-selected', l10nArgs: { count: 0 } };
|
||||||
}
|
}
|
||||||
this.setItemPaneMessage(msg);
|
this.setItemPaneMessage(msg);
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,6 @@
|
||||||
let key;
|
let key;
|
||||||
// In the trash, we have to check the object type
|
// In the trash, we have to check the object type
|
||||||
if (this.collectionTreeRow.isTrash()) {
|
if (this.collectionTreeRow.isTrash()) {
|
||||||
let _obj = this.data[0];
|
|
||||||
if (this.data.every(x => x instanceof Zotero.Collection)) {
|
if (this.data.every(x => x instanceof Zotero.Collection)) {
|
||||||
key = 'item-pane-message-collections-selected';
|
key = 'item-pane-message-collections-selected';
|
||||||
}
|
}
|
||||||
|
@ -244,26 +243,11 @@
|
||||||
else {
|
else {
|
||||||
key = 'item-pane-message-items-selected';
|
key = 'item-pane-message-items-selected';
|
||||||
}
|
}
|
||||||
// TODO: Add mechanism for this to setItemPaneMessage()
|
msg = { l10nId: key, l10nArgs: { count } };
|
||||||
let elem = document.createXULElement('description');
|
|
||||||
document.l10n.setAttributes(elem, key, { count });
|
|
||||||
msg = elem;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let rowCount = this.itemsView.rowCount;
|
let count = this.itemsView.rowCount;
|
||||||
let str = 'pane.item.unselected.';
|
msg = { l10nId: 'item-pane-message-unselected', l10nArgs: { count } };
|
||||||
switch (rowCount) {
|
|
||||||
case 0:
|
|
||||||
str += 'zero';
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
str += 'singular';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
str += 'plural';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
msg = Zotero.getString(str, [rowCount]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setItemPaneMessage(msg);
|
this.setItemPaneMessage(msg);
|
||||||
|
|
|
@ -50,9 +50,11 @@ var Zotero_LocateMenu = new function() {
|
||||||
if(availableEngines.length) {
|
if(availableEngines.length) {
|
||||||
Zotero_LocateMenu.addLocateEngines(locateMenu, availableEngines, null, true);
|
Zotero_LocateMenu.addLocateEngines(locateMenu, availableEngines, null, true);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// add "no items selected"
|
// add "no items selected"
|
||||||
menuitem = _createMenuItem(Zotero.getString("pane.item.selected.zero"), "no-items-selected");
|
menuitem = document.createXULElement("menuitem");
|
||||||
|
document.l10n.setAttributes(menuitem, "item-pane-message-items-selected", { count: 0 });
|
||||||
locateMenu.appendChild(menuitem);
|
locateMenu.appendChild(menuitem);
|
||||||
menuitem.disabled = true;
|
menuitem.disabled = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -585,6 +585,7 @@ item-pane-header-more-options =
|
||||||
.label = More Options
|
.label = More Options
|
||||||
|
|
||||||
item-pane-message-items-selected = { $count ->
|
item-pane-message-items-selected = { $count ->
|
||||||
|
[0] No items selected
|
||||||
[one] { $count } item selected
|
[one] { $count } item selected
|
||||||
*[other] { $count } items selected
|
*[other] { $count } items selected
|
||||||
}
|
}
|
||||||
|
@ -601,6 +602,17 @@ item-pane-message-objects-selected = { $count ->
|
||||||
*[other] { $count } objects selected
|
*[other] { $count } objects selected
|
||||||
}
|
}
|
||||||
|
|
||||||
|
item-pane-message-unselected = { $count ->
|
||||||
|
[0] No items in this view
|
||||||
|
[one] { $count } item in this view
|
||||||
|
*[other] { $count } items in this view
|
||||||
|
}
|
||||||
|
|
||||||
|
item-pane-duplicates-merge-items =
|
||||||
|
.label = { $count ->
|
||||||
|
[one] Merge { $count } item
|
||||||
|
*[other] Merge { $count } items
|
||||||
|
}
|
||||||
|
|
||||||
locate-library-lookup-no-resolver = You must choose a resolver from the { $pane } pane of the { -app-name } settings.
|
locate-library-lookup-no-resolver = You must choose a resolver from the { $pane } pane of the { -app-name } settings.
|
||||||
|
|
||||||
|
|
|
@ -384,14 +384,7 @@ pane.items.interview.twoParticipants = Interview by %S and %S
|
||||||
pane.items.interview.threeParticipants = Interview by %S, %S, and %S
|
pane.items.interview.threeParticipants = Interview by %S, %S, and %S
|
||||||
pane.items.interview.manyParticipants = Interview by %S et al.
|
pane.items.interview.manyParticipants = Interview by %S et al.
|
||||||
|
|
||||||
pane.item.selected.zero = No items selected
|
|
||||||
pane.item.selected.multiple = %S items selected
|
|
||||||
pane.item.unselected.zero = No items in this view
|
|
||||||
pane.item.unselected.singular = %S item in this view
|
|
||||||
pane.item.unselected.plural = %S items in this view
|
|
||||||
|
|
||||||
pane.item.duplicates.selectToMerge = Select items to merge
|
pane.item.duplicates.selectToMerge = Select items to merge
|
||||||
pane.item.duplicates.mergeItems = Merge %S items
|
|
||||||
pane.item.duplicates.writeAccessRequired = Library write access is required to merge items.
|
pane.item.duplicates.writeAccessRequired = Library write access is required to merge items.
|
||||||
pane.item.duplicates.onlyTopLevel = Only top-level full items can be merged.
|
pane.item.duplicates.onlyTopLevel = Only top-level full items can be merged.
|
||||||
pane.item.duplicates.onlySameItemType = Merged items must all be of the same item type.
|
pane.item.duplicates.onlySameItemType = Merged items must all be of the same item type.
|
||||||
|
|
|
@ -131,7 +131,7 @@ describe("ZoteroPane", function() {
|
||||||
// Unselected, with no items in view
|
// Unselected, with no items in view
|
||||||
assert.equal(
|
assert.equal(
|
||||||
doc.getElementById('zotero-item-pane-message-box').textContent,
|
doc.getElementById('zotero-item-pane-message-box').textContent,
|
||||||
Zotero.getString('pane.item.unselected.zero', 0)
|
yield doc.l10n.formatValue('item-pane-message-unselected', { count: 0 })
|
||||||
);
|
);
|
||||||
|
|
||||||
// Unselected, with one item in view
|
// Unselected, with one item in view
|
||||||
|
@ -142,7 +142,7 @@ describe("ZoteroPane", function() {
|
||||||
});
|
});
|
||||||
assert.equal(
|
assert.equal(
|
||||||
doc.getElementById('zotero-item-pane-message-box').textContent,
|
doc.getElementById('zotero-item-pane-message-box').textContent,
|
||||||
Zotero.getString('pane.item.unselected.singular', 1)
|
yield doc.l10n.formatValue('item-pane-message-unselected', { count: 1 })
|
||||||
);
|
);
|
||||||
|
|
||||||
// Unselected, with multiple items in view
|
// Unselected, with multiple items in view
|
||||||
|
@ -153,7 +153,7 @@ describe("ZoteroPane", function() {
|
||||||
});
|
});
|
||||||
assert.equal(
|
assert.equal(
|
||||||
doc.getElementById('zotero-item-pane-message-box').textContent,
|
doc.getElementById('zotero-item-pane-message-box').textContent,
|
||||||
Zotero.getString('pane.item.unselected.plural', 2)
|
yield doc.l10n.formatValue('item-pane-message-unselected', { count: 2 })
|
||||||
);
|
);
|
||||||
|
|
||||||
// Multiple items selected
|
// Multiple items selected
|
||||||
|
|
Loading…
Add table
Reference in a new issue