Localize pdf-reader and note-editor

This commit is contained in:
Martynas Bagdonas 2021-05-20 10:40:38 +03:00
parent 861d5787d8
commit 5497598c63
9 changed files with 197 additions and 46 deletions

View file

@ -75,22 +75,22 @@
-->
<!-- <menuitem label="Switch to Presentation Mode" oncommand="menuCmd('presentationmode')"/>-->
<!-- <menuseparator/>-->
<menuitem label="Go to First Page" oncommand="menuCmd('firstpage')"/>
<menuitem label="Go to Last Page" oncommand="menuCmd('lastpage')"/>
<menuitem label="&zotero.pdfReader.goToFirstPage;" oncommand="menuCmd('firstpage')"/>
<menuitem label="&zotero.pdfReader.goToLastPage;" oncommand="menuCmd('lastpage')"/>
<menuseparator/>
<menuitem label="Rotate Clockwise" oncommand="menuCmd('rotatecw')"/>
<menuitem label="Rotate Counterclockwise" oncommand="menuCmd('rotateccw')"/>
<menuitem label="&zotero.pdfReader.rotateClockwise;" oncommand="menuCmd('rotatecw')"/>
<menuitem label="&zotero.pdfReader.rotateCounterclockwise;" oncommand="menuCmd('rotateccw')"/>
<menuseparator/>
<menuitem label="Text Selection Tool" oncommand="menuCmd('switchcursortool_select')"/>
<menuitem label="Hand Tool" oncommand="menuCmd('switchcursortool_hand')"/>
<menuitem label="&zotero.pdfReader.textSelectionTool;" oncommand="menuCmd('switchcursortool_select')"/>
<menuitem label="&zotero.pdfReader.handTool;" oncommand="menuCmd('switchcursortool_hand')"/>
<menuseparator/>
<menuitem label="Vertical Scrolling" oncommand="menuCmd('switchscrollmode_vertical')"/>
<menuitem label="Horizontal Scrolling" oncommand="menuCmd('switchscrollmode_horizontal')"/>
<menuitem label="Wrapped Scrolling" oncommand="menuCmd('switchscrollmode_wrapped')"/>
<menuitem label="&zotero.pdfReader.verticalScrolling;" oncommand="menuCmd('switchscrollmode_vertical')"/>
<menuitem label="&zotero.pdfReader.horizontalScrolling;" oncommand="menuCmd('switchscrollmode_horizontal')"/>
<menuitem label="&zotero.pdfReader.wrappedScrolling;" oncommand="menuCmd('switchscrollmode_wrapped')"/>
<menuseparator/>
<menuitem label="No Spreads" oncommand="menuCmd('switchspreadmode_none')"/>
<menuitem label="Odd Spreads" oncommand="menuCmd('switchspreadmode_odd')"/>
<menuitem label="Even Spreads" oncommand="menuCmd('switchspreadmode_even')"/>
<menuitem label="&zotero.pdfReader.noSpreads;" oncommand="menuCmd('switchspreadmode_none')"/>
<menuitem label="&zotero.pdfReader.oddSpreads;" oncommand="menuCmd('switchspreadmode_odd')"/>
<menuitem label="&zotero.pdfReader.evenSpreads;" oncommand="menuCmd('switchspreadmode_even')"/>
</menupopup>
</menu>
<!-- <menu label="Tools">-->

View file

@ -221,24 +221,76 @@
label="&viewMenu.label;"
onpopupshowing="ZoteroStandalone.onViewMenuOpen()">
<menupopup id="menu_viewPopup">
<!-- <menuitem class="menu-type-reader" label="Switch to Presentation Mode" oncommand="ZoteroStandalone.onReaderCmd('presentationmode')"/>-->
<!-- <menuseparator class="menu-type-reader"/>-->
<menuitem class="menu-type-reader" label="Go to First Page" oncommand="ZoteroStandalone.onReaderCmd('firstpage')"/>
<menuitem class="menu-type-reader" label="Go to Last Page" oncommand="ZoteroStandalone.onReaderCmd('lastpage')"/>
<!-- <menuitem-->
<!-- class="menu-type-reader"-->
<!-- label="Switch to Presentation Mode"-->
<!-- oncommand="ZoteroStandalone.onReaderCmd('presentationmode')"-->
<!-- />-->
<menuseparator class="menu-type-reader"/>
<menuitem
class="menu-type-reader"
label="&zotero.pdfReader.goToFirstPage;"
oncommand="ZoteroStandalone.onReaderCmd('firstpage')"
/>
<menuitem
class="menu-type-reader"
label="&zotero.pdfReader.goToLastPage;"
oncommand="ZoteroStandalone.onReaderCmd('lastpage')"
/>
<menuseparator class="menu-type-reader"/>
<menuitem class="menu-type-reader" label="Rotate Clockwise" oncommand="ZoteroStandalone.onReaderCmd('rotatecw')"/>
<menuitem class="menu-type-reader" label="Rotate Counterclockwise" oncommand="ZoteroStandalone.onReaderCmd('rotateccw')"/>
<menuitem
class="menu-type-reader"
label="&zotero.pdfReader.rotateClockwise;"
oncommand="ZoteroStandalone.onReaderCmd('rotatecw')"
/>
<menuitem
class="menu-type-reader"
label="&zotero.pdfReader.rotateCounterclockwise;"
oncommand="ZoteroStandalone.onReaderCmd('rotateccw')"
/>
<menuseparator class="menu-type-reader"/>
<menuitem class="menu-type-reader" label="Text Selection Tool" oncommand="ZoteroStandalone.onReaderCmd('switchcursortool_select')"/>
<menuitem class="menu-type-reader" label="Hand Tool" oncommand="ZoteroStandalone.onReaderCmd('switchcursortool_hand')"/>
<menuitem
class="menu-type-reader"
label="&zotero.pdfReader.textSelectionTool;"
oncommand="ZoteroStandalone.onReaderCmd('switchcursortool_select')"
/>
<menuitem
class="menu-type-reader"
label="&zotero.pdfReader.handTool;"
oncommand="ZoteroStandalone.onReaderCmd('switchcursortool_hand')"
/>
<menuseparator class="menu-type-reader"/>
<menuitem class="menu-type-reader" label="Vertical Scrolling" oncommand="ZoteroStandalone.onReaderCmd('switchscrollmode_vertical')"/>
<menuitem class="menu-type-reader" label="Horizontal Scrolling" oncommand="ZoteroStandalone.onReaderCmd('switchscrollmode_horizontal')"/>
<menuitem class="menu-type-reader" label="Wrapped Scrolling" oncommand="ZoteroStandalone.onReaderCmd('switchscrollmode_wrapped')"/>
<menuitem
class="menu-type-reader"
label="&zotero.pdfReader.verticalScrolling;"
oncommand="ZoteroStandalone.onReaderCmd('switchscrollmode_vertical')"
/>
<menuitem
class="menu-type-reader"
label="&zotero.pdfReader.horizontalScrolling;"
oncommand="ZoteroStandalone.onReaderCmd('switchscrollmode_horizontal')"
/>
<menuitem
class="menu-type-reader"
label="&zotero.pdfReader.wrappedScrolling;"
oncommand="ZoteroStandalone.onReaderCmd('switchscrollmode_wrapped')"
/>
<menuseparator class="menu-type-reader"/>
<menuitem class="menu-type-reader" label="No Spreads" oncommand="ZoteroStandalone.onReaderCmd('switchspreadmode_none')"/>
<menuitem class="menu-type-reader" label="Odd Spreads" oncommand="ZoteroStandalone.onReaderCmd('switchspreadmode_odd')"/>
<menuitem class="menu-type-reader" label="Even Spreads" oncommand="ZoteroStandalone.onReaderCmd('switchspreadmode_even')"/>
<menuitem
class="menu-type-reader"
label="&zotero.pdfReader.noSpreads;"
oncommand="ZoteroStandalone.onReaderCmd('switchspreadmode_none')"
/>
<menuitem
class="menu-type-reader"
label="&zotero.pdfReader.oddSpreads;"
oncommand="ZoteroStandalone.onReaderCmd('switchspreadmode_odd')"
/>
<menuitem
class="menu-type-reader"
label="&zotero.pdfReader.evenSpreads;"
oncommand="ZoteroStandalone.onReaderCmd('switchspreadmode_even')"
/>
<menuseparator class="menu-type-reader"/>
<menu id="layout-menu" label="&layout.label;">

View file

@ -104,7 +104,8 @@ class EditorInstance {
dir: Zotero.dir,
font: this._getFont(),
hasBackup: note && !Zotero.Notes.hasSchemaVersion(note)
|| !!await Zotero.NoteBackups.getNote(this._item.id)
|| !!await Zotero.NoteBackups.getNote(this._item.id),
localizedStrings: Zotero.Intl.getPrefixedStrings('noteEditor')
});
}
@ -1251,7 +1252,7 @@ class EditorInstance {
jsonAnnotation.attachmentItemID = attachmentItem.id;
jsonAnnotations.push(jsonAnnotation);
}
let html = `<h1>${Zotero.getString('note.annotationsWithDate', new Date().toLocaleString())}</h1>\n`;
let html = `<h1>${Zotero.getString('noteEditor.annotationsWithDate', new Date().toLocaleString())}</h1>\n`;
let { html: serializedHTML, citationItems } = await editorInstance._serializeAnnotations(jsonAnnotations, true);
html += serializedHTML;
citationItems = encodeURIComponent(JSON.stringify(citationItems));

View file

@ -133,6 +133,24 @@ Zotero.Intl = new function () {
return l10n;
};
/**
* Get all strings with a specified prefix
*
* @param {String} prefix
* @return {Object}
*/
this.getPrefixedStrings = function (prefix) {
let strings = [];
let enumerator = bundle.getSimpleEnumeration();
while (enumerator.hasMoreElements()) {
let entity = enumerator.getNext().QueryInterface(Ci.nsIPropertyElement);
if (entity.key.startsWith(prefix)) {
strings[entity.key] = entity.value;
}
}
return strings;
};
/*
* Compares two strings based on the current collator.
* @param {String} string1

View file

@ -72,7 +72,8 @@ class ReaderInstance {
showItemPaneToggle: this._showItemPaneToggle,
sidebarWidth: this._sidebarWidth,
sidebarOpen: this._sidebarOpen,
bottomPlaceholderHeight: this._bottomPlaceholderHeight
bottomPlaceholderHeight: this._bottomPlaceholderHeight,
localizedStrings: Zotero.Intl.getPrefixedStrings('pdfReader')
}, [buf]);
return true;
}
@ -252,7 +253,7 @@ class ReaderInstance {
let menuitem;
if (data.text) {
menuitem = this._window.document.createElement('menuitem');
menuitem.setAttribute('label', 'Copy');
menuitem.setAttribute('label', Zotero.getString('general.copy'));
menuitem.addEventListener('command', () => {
Zotero.Utilities.Internal.copyTextToClipboard(data.text);
});
@ -262,21 +263,21 @@ class ReaderInstance {
}
// Zoom in
menuitem = this._window.document.createElement('menuitem');
menuitem.setAttribute('label', 'Zoom In');
menuitem.setAttribute('label', Zotero.getString('pdfReader.zoomIn'));
menuitem.addEventListener('command', () => {
this._postMessage({ action: 'popupCmd', cmd: 'zoomIn' });
});
popup.appendChild(menuitem);
// Zoom out
menuitem = this._window.document.createElement('menuitem');
menuitem.setAttribute('label', 'Zoom Out');
menuitem.setAttribute('label', Zotero.getString('pdfReader.zoomOut'));
menuitem.addEventListener('command', () => {
this._postMessage({ action: 'popupCmd', cmd: 'zoomOut' });
});
popup.appendChild(menuitem);
// Zoom 'Auto'
menuitem = this._window.document.createElement('menuitem');
menuitem.setAttribute('label', 'Automatically Resize');
menuitem.setAttribute('label', Zotero.getString('pdfReader.zoomAuto'));
menuitem.setAttribute('checked', data.isZoomAuto);
menuitem.addEventListener('command', () => {
this._postMessage({ action: 'popupCmd', cmd: 'zoomAuto' });
@ -284,7 +285,7 @@ class ReaderInstance {
popup.appendChild(menuitem);
// Zoom 'Page Width'
menuitem = this._window.document.createElement('menuitem');
menuitem.setAttribute('label', 'Zoom to Page Width');
menuitem.setAttribute('label', Zotero.getString('pdfReader.zoomPageWidth'));
menuitem.setAttribute('checked', data.isZoomPageWidth);
menuitem.addEventListener('command', () => {
this._postMessage({ action: 'popupCmd', cmd: 'zoomPageWidth' });
@ -294,7 +295,7 @@ class ReaderInstance {
popup.appendChild(this._window.document.createElement('menuseparator'));
// Next page
menuitem = this._window.document.createElement('menuitem');
menuitem.setAttribute('label', 'Next Page');
menuitem.setAttribute('label', Zotero.getString('pdfReader.nextPage'));
menuitem.setAttribute('disabled', !data.enableNextPage);
menuitem.addEventListener('command', () => {
this._postMessage({ action: 'popupCmd', cmd: 'nextPage' });
@ -302,7 +303,7 @@ class ReaderInstance {
popup.appendChild(menuitem);
// Previous page
menuitem = this._window.document.createElement('menuitem');
menuitem.setAttribute('label', 'Previous Page');
menuitem.setAttribute('label', Zotero.getString('pdfReader.previousPage'));
menuitem.setAttribute('disabled', !data.enablePrevPage);
menuitem.addEventListener('command', () => {
this._postMessage({ action: 'popupCmd', cmd: 'prevPage' });
@ -320,7 +321,7 @@ class ReaderInstance {
let menuitem;
// Add to note
menuitem = this._window.document.createElement('menuitem');
menuitem.setAttribute('label', 'Add to Note');
menuitem.setAttribute('label', Zotero.getString('pdfReader.addToNote'));
let hasActiveEditor = this._window.ZoteroContextPane.getActiveEditor();
menuitem.setAttribute('disabled', !hasActiveEditor);
menuitem.addEventListener('command', () => {
@ -356,7 +357,7 @@ class ReaderInstance {
popup.appendChild(this._window.document.createElement('menuseparator'));
// Delete
menuitem = this._window.document.createElement('menuitem');
menuitem.setAttribute('label', 'Delete');
menuitem.setAttribute('label', Zotero.getString('general.delete'));
menuitem.setAttribute('disabled', readOnly);
menuitem.addEventListener('command', () => {
let data = {
@ -523,7 +524,7 @@ class ReaderInstance {
let crash = message && ['setAnnotation'].includes(message.action);
this._postMessage({
action: crash ? 'crash' : 'error',
message: `An error occurred during '${message ? message.action : ''}'`,
message: `${Zotero.getString('general.error')}: '${message ? message.action : ''}'`,
moreInfo: {
message: e.message,
stack: e.stack,
@ -553,7 +554,7 @@ class ReaderInstance {
/**
* Return item JSON in the pdf-reader ready format
*
*
* @param {Zotero.Item} item
* @returns {Object|null}
*/

View file

@ -335,3 +335,16 @@
<!ENTITY zotero.context.addStandaloneNote "Add Standalone Note">
<!ENTITY zotero.context.addStandaloneNoteFromAnnotations "Add Standalone Note from Annotations">
<!ENTITY zotero.context.editInWindow "Edit in a Separate Window">
<!ENTITY zotero.pdfReader.goToFirstPage "Go to First Page">
<!ENTITY zotero.pdfReader.goToLastPage "Go to Last Page">
<!ENTITY zotero.pdfReader.rotateClockwise "Rotate Clockwise">
<!ENTITY zotero.pdfReader.rotateCounterclockwise "Rotate Counterclockwise">
<!ENTITY zotero.pdfReader.textSelectionTool "Text Selection Tool">
<!ENTITY zotero.pdfReader.handTool "Hand Tool">
<!ENTITY zotero.pdfReader.verticalScrolling "Vertical Scrolling">
<!ENTITY zotero.pdfReader.horizontalScrolling "Horizontal Scrolling">
<!ENTITY zotero.pdfReader.wrappedScrolling "Wrapped Scrolling">
<!ENTITY zotero.pdfReader.noSpreads "No Spreads">
<!ENTITY zotero.pdfReader.oddSpreads "Odd Spreads">
<!ENTITY zotero.pdfReader.evenSpreads "Even Spreads">

View file

@ -66,6 +66,7 @@ general.tryAgain = Try Again
general.tryLater = Try Later
general.showDirectory = Show Directory
general.continue = Continue
general.copy = Copy
general.copyToClipboard = Copy to Clipboard
general.cancel = Cancel
general.clear = Clear
@ -405,8 +406,6 @@ pane.context.itemNotes = Item Notes
pane.context.allNotes = All Notes
pane.context.noNotes = No notes
noteEditor.editNote = Edit Note
itemTypes.note = Note
itemTypes.annotation = Annotation
itemTypes.attachment = Attachment
@ -623,8 +622,6 @@ findPDF.pdfWithMethod = PDF (%S)
findPDF.noPDFsFound = No PDFs found
findPDF.noPDFFound = No PDF found
note.annotationsWithDate = Annotations (%S)
attachment.fullText = Full Text
attachment.acceptedVersion = Accepted Version
attachment.submittedVersion = Submitted Version
@ -1263,3 +1260,72 @@ retraction.citeWarning.text1 = The item you are citing has been retracted. Do yo
retraction.citeWarning.text2 = You can view the item in your library for further details on the retraction.
retraction.citationWarning = A citation in your document has been retracted:
retraction.citationWarning.dontWarn = Dont warn me about this item again
noteEditor.annotationsWithDate = Annotations (%S)
noteEditor.cut = Cut
noteEditor.copy = Copy
noteEditor.paste = Paste
noteEditor.rightToLeft = Right to Left
noteEditor.leftToRight = Left to Right
noteEditor.viewNoteBackup = View Note Backup
noteEditor.updateNotice = This note was edited with a newer version of Zotero.\nPlease update Zotero to make changes.
noteEditor.enterLink = Enter Link
noteEditor.heading1 = Heading 1
noteEditor.heading2 = Heading 2
noteEditor.heading3 = Heading 3
noteEditor.paragraph = Paragraph
noteEditor.monospaced = Monospaced
noteEditor.bulletList = Bulleted List
noteEditor.orderedList = Numbered List
noteEditor.blockquote = Block Quote
noteEditor.formatText = Format Text
noteEditor.bold = Bold
noteEditor.italic = Italic
noteEditor.underline = Underline
noteEditor.returnToNotesList = Return to Notes List
noteEditor.insertLink = Insert Link
noteEditor.clearFormatting = Clear Formatting
noteEditor.align = Align
noteEditor.alignLeft = Align Left
noteEditor.alignCenter = Align Center
noteEditor.alignRight = Align Right
noteEditor.insertCitation = Insert Citation
noteEditor.more = More
noteEditor.search = Search…
noteEditor.replace = Replace…
noteEditor.matchCase = Match Case
noteEditor.wholeWords = Whole Words
noteEditor.previous = Prev
noteEditor.next = Next
noteEditor.replaceNext = Replace
noteEditor.replaceAll = Replace All
noteEditor.goToPage = Go to Page
noteEditor.showItem = Show Item
noteEditor.editCitation = Edit Citation
noteEditor.showOnPage = Show on Page
noteEditor.unlink = Unlink
noteEditor.set = Set
noteEditor.edit = Edit
noteEditor.addCitation = Add Citation
noteEditor.findAndReplace = Find and Replace
noteEditor.showInLibrary = Show in Library
noteEditor.editInWindow = Edit in a Separate Window
pdfReader.annotations = Annotations
pdfReader.showAnnotations = Show Annotations
pdfReader.searchAnnotations = Search Annotations
pdfReader.noAnnotations = Create an annotation to see it in the sidebar
pdfReader.addText = Add extracted text
pdfReader.addComment = Add comment
pdfReader.addTags = Add tags…
pdfReader.highlightText = Highlight Text
pdfReader.addNote = Add Note
pdfReader.selectArea = Select Area
pdfReader.pickColor = Pick a Color
pdfReader.addToNote = Add to Note
pdfReader.zoomIn = Zoom In
pdfReader.zoomOut = Zoom Out
pdfReader.zoomAuto = Automatically Resize
pdfReader.zoomPageWidth = Zoom to Page Width
pdfReader.nextPage = Next Page
pdfReader.previousPage = Previous Page

@ -1 +1 @@
Subproject commit 5834ce05e01b123917521bfd22df7d2c242350e2
Subproject commit 2401d208e00f330c994bfe975b2c15e781a09e82

@ -1 +1 @@
Subproject commit ac0b6bcc362df7691497cdb5c0766ee1fd3f5bf8
Subproject commit 521570fba3302b35ce9984469c579c21c1eace86