From 3a0da012c8890ea663eb177b6b2cdeffbeaa978e Mon Sep 17 00:00:00 2001 From: troyeguo <13820674+troyeguo@users.noreply.github.com> Date: Sat, 30 Jul 2022 17:50:02 +0800 Subject: [PATCH] fix bug Former-commit-id: 2d6be7ea2d98f21801cd5189fd5ddde4a37c6a4e --- package.json | 4 + src/assets/locales/pl/translation.json | 342 ++++++++++++++++++ src/components/background/index.tsx | 2 +- src/components/bookCardItem/component.tsx | 2 +- src/components/bookCardItem/index.tsx | 4 +- src/components/bookCoverItem/component.tsx | 2 +- src/components/bookCoverItem/index.tsx | 2 +- src/components/bookListItem/component.tsx | 2 +- src/components/bookListItem/index.tsx | 4 +- src/components/colorOption/index.tsx | 2 +- src/components/deleteIcon/index.tsx | 2 +- src/components/dialogs/aboutDialog/index.tsx | 2 +- src/components/dialogs/actionDialog/index.tsx | 2 +- src/components/dialogs/addDialog/index.tsx | 8 +- src/components/dialogs/backupDialog/index.tsx | 2 +- .../dialogs/deleteDialog/component.tsx | 2 +- src/components/dialogs/deleteDialog/index.tsx | 2 +- src/components/dialogs/deletePopup/index.tsx | 2 +- src/components/dialogs/editDialog/index.tsx | 2 +- .../popups/popupOption/component.tsx | 9 + .../popups/popupTrans/component.tsx | 110 ++++-- .../popups/popupTrans/interface.tsx | 1 + .../popups/popupTrans/popupTrans.css | 2 +- src/constants/settingList.tsx | 1 + src/constants/translationList.tsx | 220 +++++++++++ src/containers/lists/bookList/component.tsx | 8 +- .../lists/deletedBookList/component.tsx | 16 +- src/i18n.tsx | 4 + src/router/index.tsx | 2 + src/utils/syncUtils/sftp.tsx | 116 ++++++ yarn.lock | 246 ++++++++++++- 31 files changed, 1063 insertions(+), 62 deletions(-) create mode 100644 src/assets/locales/pl/translation.json create mode 100644 src/utils/syncUtils/sftp.tsx diff --git a/package.json b/package.json index c96510c1..ed0704b4 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,10 @@ "private": false, "dependencies": { "@types/i18next": "^13.0.0", + "@vitalets/google-translate-api": "^8.0.0", "adm-zip": "^0.5.2", "axios": "^0.19.2", + "bing-translate-api": "^2.6.0", "chardet": "^1.3.0", "chinese-s2t": "^1.0.0", "copy-text-to-clipboard": "^2.2.0", @@ -25,10 +27,12 @@ "electron-store": "^8.0.1", "font-list": "^1.4.5", "fs-extra": "^9.1.0", + "http2": "^3.3.7", "iconv-lite": "^0.6.2", "macaddress": "^0.5.2", "react-hot-toast": "^2.1.1", "request": "^2.88.2", + "ssh2-sftp-client": "^9.0.2", "underscore": "^1.11.0", "webdav": "^3.6.2", "webdav-fs": "^3.0.0", diff --git a/src/assets/locales/pl/translation.json b/src/assets/locales/pl/translation.json new file mode 100644 index 00000000..3b50c099 --- /dev/null +++ b/src/assets/locales/pl/translation.json @@ -0,0 +1,342 @@ +{ + "Books": "Książki", + "Recent": "Ostatnie", + "Bookmarks": "Zakładki", + "Favorites": "Ulubione", + "Notes": "Notatki", + "Highlights": "Zaznaczenia", + "Shelf": "Półka", + "Left": "Z lewej", + "Justify": "Wyśrodkowany", + "Right": "Z prawej", + "Text Align": "Wyrównanie tekstu", + "Sync Successfully": "Pomyślna synchronizacja", + "Permanently Delete": "Usuń trwale", + "Default search engine": "Domyślna wyszukiwarka", + "Built-in font": "Wbudowana czcionka", + "Cover": "Okładka", + "Bold": "Pogrubienie", + "Sort by": "Sortuj według", + "Italic": "Kursywa", + "Text underline": "Podkreślenie tekstu", + "Text shadow": "Cień tekstu", + "Import Failed": "Niepowodzenie importowania", + "New Version Available": "Dostępna nowa wersja", + "New Version": "Nowa wersja", + "Customize": "Dostosuj", + "Auto open book in fullscreen": "Automatyczne otwieranie książek na pełnym ekranie", + "System Font": "Czcionka systemu", + "Access token expired, refetching token": "Token dostępu wygasł, ponowne pobranie tokena", + "Access token received, please continue": "Otrzymano token dostępu, kontynuuj", + "Changelog": "Dziennik zmian", + "Update Complete": "Aktualizacja ukończona", + "Fetching acess token failed": "Nie udało się pobrać tokena dostępu", + "Authorizing, please wait": "Autoryzowanie, proszę czekać", + "Downloading, please wait": "Pobieranie, proszę czekać", + "Uploading, please wait": "Wgrywanie, proszę czekać", + "Import": "Importuj", + "Backup": "Kopia zapasowa", + "Search my library": "Przeszukaj moją bibliotekę", + "Search my notes": "Przeszukaj moje notatki", + "Search my highlights": "Przeszukaj moje oznaczenia", + "Card": "Karta", + "List": "Lista", + "Work": "Praca", + "Entertainment": "Zabawa", + "Study": "Nauka", + "Author": "Autor", + "Duplicate Shelf": "Zduplikowana półka", + "Reading Time": "Czas czytania", + "Content": "Zawartośc", + "Voice": "Głos", + "Speed": "Szybkość", + "Bookmark": "Zakładki", + "Single-Page Mode": "Pojedyncza", + "Double-Page Mode": "Podwójna", + "Background Color": "Kolor tła", + "Font Size": "Wielkość czcionki", + "Font Family": "Rodzina czcionki", + "Default": "Domyślna", + "Small": "Mała", + "Medium": "Średnia", + "Large": "Duża", + "Cancel Successfully": "Anulowano pomyślnie", + "Only supported by desktop version": "Obsługiwane tylko przez wersję komputerową", + "Hide mimical background": "Ukryj tło naśladujące", + "Auto hide cursor when reading": "Automatyczne ukrywanie kursora podczas czytania", + "Disable update notification": "Wyłącz powiadomienie o aktualizacji", + "Roadmap": "Przyszły rozwój", + "Paragraph Spacing": "Odstępy między akapitami", + "Unlock": "Odblokuj", + "Lock": "Zablokuj", + "Reading Option": "Opcje czytania", + "Progress": "Postęp", + "Exit": "Wyjdź", + "Language": "Język", + "Enter Fullscreen": "Pełny ekran", + "Exit Fullscreen": "Pełny ekran", + "Add Bookmark": "Zakładka", + "Add to Shelf": "Dodaj na półkę", + "New Shelf": "Nowa półka", + "New": "Nowa", + "Cancel": "Anuluj", + "Confirm": "Potwierdź", + "Delete": "Usuń", + "Delete This Book": "Usuń tą książkę", + "Edit Book": "Edytuj książkę", + "Edit Successfully": "Edycja zakończona pomyślnie", + "Book Name": "Nazwą książki", + "Sort by Date": "Datą dodania", + "Descend": "Malejąco", + "Ascend": "Rosnąco", + "Sort by Name": "Nazwą", + "Token": "Token", + "Book not exist": "Książka nie istnieje", + "Please authorize your account, and fill the following box with the token": "Autoryzuj swoje konto i wypełnij poniższe pole tokenem", + "Copy Link": "Kopiuj link", + "Copy Token": "Kopiuj token", + "Copied": "Skopiowano", + "Chinese Coversion": "Chińska konwersja", + "Simplified To Traditional": "Uproszczony do tradycyjnego", + "Traditional To Simplified": "Od tradycyjnego do uproszczonego", + "Shelf Title is Empty": "Nazwa półki jest pusta", + "Copy Link Successfully": "Pomyślnie skopiowano link", + "Add Successfully": "Dodano pomyślnie", + "Select": "Wybierz", + "Coming Soon": "Wkrótce", + "Understand": "Rozumieć", + "Authorize Successfully": "Pomyślna autoryzacja", + "Authorize Failed": "Autoryzacja nieudana", + "Choose your operation": "Wybierz swoją operację", + "Where is your data?": "Gdzie są Twoje dane?", + "Where to keep your data?": "Gdzie przechowywać Twoje dane?", + "I want to backup": "Kopia zapasowa", + "I want to restore": "Przywróć", + "Delete this shelf": "Usuń tą półkę", + "This action will clear and remove this shelf": "Ta czynność wyczyści i usunie tę półkę", + "Delete this tag": "Usuń ten znacznik", + "This action will clear and remove this tag": "Ta czynność wyczyści i usunie ten znacznik", + "Backup Successfully": "Backup wykonany pomyślnie", + "Restore Successfully": "Przywracanie wykonane pomyslnie", + "Try refresh or restart": "Spróbuj odświeżyć albo zrestartować", + "Search the book": "Przeszukaj książkę", + "Theme Color": "Kolor motywu", + "Turn on text-to-speech": "Włącz zamianę tekstu na mowę", + "Scroll Mode": "Tryb przewijania", + "Loading": "Ładowanie", + "Note": "Notatka", + "Page Width": "Szerokość strony", + "Digest": "Streszczenie", + "Auto expand content": "Automatycznie rozwijaj zawartość", + "Hide footer": "Ukryj stopkę", + "Hide header": "Ukryj nagłówek", + "Book size is over 20M": "Rozmiar książki przekracza 20MB", + "Current Font Size": "Aktualna wielkość czcionki", + "Current Chapter": "Aktualny rozdział", + "Turn off text-to-speech": "Wyłącz zamianę tekstu na mowę", + "Warning": "Ostrzeżenie", + "All Tags": "Wszystkie znaczniki", + "Turn On Successfully": "Włączono pomyślnie", + "Turn Off Successfully": "Wyłączono pomyślnie", + "Turn off touch screen mode": "Wyłącz tryb ekranu dotykowego (zapobiegając przypadkowemu dotknięciu)", + "Use built-in font": "Użyj wbudowanej czcionki", + "Setting": "Ustawienia", + "Turn on touch screen mode": "Włącz tryb ekranu dotykowego", + "Auto open last-read book": "Automatycznie otwieraj ostatnio czytaną książkę", + "About Project": "O projekcie", + "Developer": "Deweloper", + "Please import less than 10 books": "Proszę zaimportować mniej niż 10 książek", + "Please delete some books before import": "Usuń niektóre książki przed importem", + "For better user experince, please visit this site on a computer": "Aby uzyskać lepsze wrażenia użytkownika, odwiedź tę witrynę na komputerze", + "Wrong bookmark": "Błędna zakładka", + "Last Step": "Ostatni krok", + "Next Step": "Nastepny krok", + "Go To": "Idź do", + "It seems like you're lost": "Wygląda na to, że się zgubiłeś", + "Return to home": "Powrót na stronę główną", + "Only desktop support this format": "Tylko komputery obsługują ten format", + "Only desktop support this service": "Tylko komputery obsługują tą usługę", + "Delete from Shelf": "Usuń z półki", + "Delete Successfully": "Usunięto pomyślnie", + "This action will move this book and its the notes, bookmarks and highlights of this book to the recycle bin": "Ta czynność przeniesie książkę wraz z notatkami, zakładkami i zaznaczeniami do kosza", + "This action won't delete the original book": "Ta czynność nie spowoduje usunięcia oryginalnej książki", + "From": "Z", + "Duplicate Book": "Zduplikowana książka", + "Unknown Chapter": "Nieznany rozdział", + "Unknown Authur": "Nieznany autor", + "Minute": "Minuta", + "Empty": "Pusto", + "Next Chapter": "Następny rozdział", + "Prev Chapter": "Poprzedni rozdział", + "Less": "Mniej", + "Current Reading Time": "Czas czytania: {{count}} minut", + "Finish Reading Time": "Pozostały czas:{{count}} minut", + "Book Page": "Strona {{count}}", + "Total books": "Łącznie {{count}} książek", + "Pages": "Stron", + "Chapters": "Rozdziałów", + "Translate": "Przetłumacz", + "Continuous": "Ciągły", + "Scroll": "Przewiń", + "Show in the book": "Pokaż w książce", + "More Notes": "Więcej notatek", + "Pick Color": "Wybierz kolor", + "Highlight Successfully": "Pomyślnie oznaczono", + "Take Note": "Zrób notatkę", + "Highlight": "Oznacz", + "Copy Successfully": "Skopiowano pomyślnie", + "Copy ": "Kopiuj", + "Text Color": "Kolor tekstu", + "Export": "Eksportuj", + "Restore": "Przywróć", + "Publisher": "Wydawca", + "Added at": "Dodano w", + "Margin": "Margines", + "Do you want to open this link in browser": "Czy chcesz otworzyć ten link w przeglądarce", + "Webdav Info": "Webdav to łatwe w użyciu i wydajne rozwiązanie do tworzenia kopii zapasowych, zalecamy korzystanie z usługi webdav dostarczanej przez NextCloud", + "Please Wait a moment": "Proszę czekać", + "Server Address": "Adres serwera", + "Username": "Nazwa użytkownika", + "Password": "Hasło", + "Description": "Opis", + "Sort by Recent": "Obecnie czytane", + "Collapse sidebar": "Zwiń pasek boczny", + "Show sidebar": "Pokaż pasek boczny", + "Sync": "Synchronizuj", + "Help": "Dokument", + "Feedback": "Opinia", + "Github Repo": "Repozytorium Github", + "Speak the text": "Przeczytaj tekst", + "Search on the internet": "Wyszukaj w internecie", + "Search in the book": "Wyszukaj w książce", + "Change storage location": "Zmień miejsce przechowywania", + "Change location": "Zmień", + "Change Successfully": "Zmieniono pomyślnie", + "Too many images": "Książka zawiera zbyt wiele obrazów", + "Export Successfully": "Pomyślnie wyeksportowano", + "Change Failed": "Zmiana nie powiodła się", + "You successfully update to": "Udało Ci się zaktualizować do", + "Deleted Books": "Kosz", + "Delete All Books": "Usuń wszystkie książki", + "Sort by Duration": "Czasie czytania", + "Sort by Author": "Autorze", + "Audio is not ready yet": "Zamiana tekstu na mowę nie jest jeszcze gotowa", + "Drop your books here": "Upuść tutaj swoje książki", + "Sort by Percentage": "Postęp czytania", + "This action will remove all the books in recycle bin,together with their notes, bookmarks and digests": "Ta czynność spowoduje trwałe usunięcie wszystkich książek z kosza wraz z ich notatkami, zakładkami i skrótami", + "Batch import only support epub or pdf files": "Import wsadowy obsługuje tylko pliki epub lub pdf", + "The deleted books will show up here": "Usunięte książki pojawią się tutaj", + "Empty Recycle Bin": "Opróżnij kosz", + "Skip": "Pomiń", + "Local": "Lokalny", + "Tips": "Wskazówki", + "Brightness": "Jasność", + "How sync works": "Jak działa synchronizacja", + "You need to manually change the storage location to the same sync folder on different computers. When you click the sync button, Koodo Reader will automatically upload or download the data from this folder according the timestamp.": "Musisz zmienić miejsce przechowywania na ten sam folder dysku w chmurze na innych komputerach. Po kliknięciu przycisku synchronizacji, Koodo Reader automatycznie prześle lub pobierze dane z tego folderu i zsynchronizuje dane na wszystkich komputerach. Odwiedź naszą dokumentację, aby uzyskać więcej instrukcji.", + "Line Height": "Wysokość linii", + "Please turn off open books in the main window first": "Proszę najpierw wyłączyć otwarte książki w oknie głównym", + "Please turn off merge with word first": "Wyłącz najpierw scalanie ze słowem", + "Please choose an empty folder": "Proszę wybrać pusty folder", + "Data change detected, whether to update?": "Wykryto zmianę danych, czy zaktualizować?", + "Empty Library": "Pusta biblioteka", + "Download": "Pobierz", + "Use the fonts from your local computer": "Użyj lokalnych czcionek", + "Backup your data with Webdav": "Utwórz kopię zapasową swoich danych za pomocą Webdav", + "Click the import button to add books": "Kliknij przycisk importu, aby dodać książki", + "Turn on night mode": "Włącz tryb nocny", + "Turn on auto update": "Włącz automatyczne aktualizacje", + "Auto Update relys on Github Release for package hosting, if your internet doesn't have stable connection to Github, we highly recommand you to turn off this option": "Auto Update polega na Github Release dla hostingu pakietów, jeśli twój internet nie ma stabilnego połączenia z Github, zalecamy wyłączenie tej opcji.", + "File size": "Wielkość pliku", + "Take effect at next startup": "Wejdź w życie przy następnym uruchomieniu", + "View Mode": "Tryb widoku", + "Download Desktop Version": "Pobierz wersję komputerową", + "No Favorite Books": "Brak ulubionych książek", + "Move your mouse on the top of any book, click the heart icon to add it to your favorite books": "Najedź myszką na dowolną książkę, kliknij ikonę serca, aby dodać ją do ulubionych", + "Empty Reading Records": "Puste zapisy czytania", + "Empty Bookmark": "Brak zakładek", + "Empty Note": "Pusta notatka", + "Select any text and click the Note button on the popup menu": "Wybierz dowolny tekst i kliknij przycisk Notatka w menu podręcznym", + "Empty Highlight": "Puste oznaczenie", + "Select any text and click the Highlight button on the popup menu": "Wybierz dowolny tekst i kliknij przycisk Oznacz w menu podręcznym", + "Invert color": "Odwróć kolor", + "Empty Shelf": "Pusta półka", + "Move your mouse on top of any book, then click the more icon to add the book to the shelf": "Najedź myszką na dowolną książkę, a następnie kliknij ikonę więcej, aby dodać książkę na półkę", + "Download failed, network problem or no backup": "Pobieranie nie powiodło się, problem z siecią lub brak kopii zapasowej", + "Upload failed, check your connection": "Przesyłanie nie powiodło się, sprawdź połączenie", + "Version": "Wersja: ", + "Not supported yet": "Jeszcze nieobsługiwane", + "Update to": "Aktualizuj do", + "Date": "Data: ", + "Blue": "Niebieski", + "Red": "Czerwony", + "Green": "Zielony", + "Purple": "Fioletowy", + "Unauthorize": "Cofnij autoryzację", + "Remember window's size": "Zapamiętaj wielkość okna", + "Letter Spacing": "Odstępy między literami", + "Unauthorize Successfully": "Pomyślnie cofnięto autoryzacje", + "Download Demo Book": "Pobierz książkę demonstracyjną", + "Extra Large": "Bardzo duża", + "Ultra Large": "Ultra duża", + "Disable analytics service": "Wyłącz usługę analityczną", + "Hide navigation button": "Ukryj przycisk nawigacyjny", + "More": "Więcej", + "Collect": "Zbierz", + "Copy": "Kopiuj", + "Hi! Stranger": "Cześć! Nieznajomy", + "Sync data from storage": "Synchronizuj dane z pamięci", + "Click on any book to read": "Kliknij dowolną książkę, aby przeczytać", + "Move your mouse on the top edge of the reader": "Najedź myszą na górną krawędź czytnika", + "Download failed,network problem or no backup": "Pobieranie nie powiodło się, problem z siecią lub brak kopii zapasowej", + "Choose your action to this book": "Wybierz swoją akcję dla tej książki", + "Edit": "Edytuj", + "Add": "Dodaj", + "Survey": "Ankieta", + "What's new about this version": "Co nowego w tej wersji", + "Our Website": "Nasza strona", + "What's New": "Co nowego", + "What's been fixed": "Co zostanie naprawione", + "Target": "Cel", + "Select All": "Zaznacz wszystko", + "Excute Successfully": "Wykonano pomyślnie", + "Disable screen blanking": "Wyłącz wygaszanie ekranu", + "When Koodo is running, your computer won't enter sleep mode": "Gdy Koodo działa, komputer nie przechodzi w tryb uśpienia", + "Prevent accidental trigger": "Zapobiegaj przypadkowemu uruchomieniu", + "Import books as link": "Importuj książki jako link", + "Close main window while reading": "Zamknij główne okno podczas czytania", + "Merge reader into Word": "Połącz czytnik z Wordem", + "Get rid of window frame, make reader hide into Word or any text editor, and can't be detected. You need to set up the reader's position, size and style first.": "Pozbądź się ramki okna, spraw, że czytnik ukryje się w Wordzie lub dowolnym edytorze tekstu i nie będzie można go wykryć. Musisz najpierw ustawić pozycję, rozmiar i styl czytnika.", + "The imported books will not be copied to library, only linked to the original book path": "Importowane książki nie zostaną skopiowane do biblioteki, a jedynie połączone z oryginalną ścieżką książki", + "Reader menu will not be triggered by hovering but clicking on the area": "Menu czytnika nie będzie wywoływane przez najechanie, lecz kliknięcie na obszar", + "Gesture and UI optimization for touch screen": "Optymalizacja gestów i UI dla ekranów dotykowych", + "The book that you read from last time will be open automatically when launching": "Ostatnio czytana książka otworzy się automatycznie po uruchomieniu", + "All the folded content will be expanded in the navigation panel": "Wszystkie zwinięte treści zostaną wyświetlone w panelu nawigacyjnym", + "Reader window will be maximized to fit the screen when opening a book": "Okno czytnika zostanie zmaksymalizowane, aby pasowało do ekranu podczas otwierania książki", + "Open books in the main window": "Otwórz książki w głównym oknie", + "Book won't be opened in a seperate window but directly opened in the main window": "Książka nie zostanie otwarta w osobnym oknie, ale bezpośrednio w oknie głównym", + "Book not exsits": "Książka nie istnieje", + "Reach frequency limit": "Osiągnij limit częstotliwości", + "Error happens": "Występuje błąd", + "Text Indent": "Wcięcie tekstu", + "Deselect All": "Odznacz wszystkie", + "Authorize": "Autoryzuj", + "Open book without adding it to library": "Otwórz książkę bez dodawania jej do biblioteki", + "When opening books in the file manager with Koodo, the opened books won't be added to the library": "Podczas otwierania książek w menedżerze plików za pomocą Koodo otwarte książki nie zostaną dodane do biblioteki", + "Hide menu button": "Ukryj przycisk menu", + "Manage": "Zarządzaj", + "Sliding Animation": "Animacja przewijania", + "Please turn off open books in the main window": "Wyłącz otwarte książki w głównym oknie", + "This action will delete all the notes, bookmarks and digests of this book": "Ta czynność spowoduje usunięcie wszystkich notatek, zakładek i streszczeń tej książki", + "More formats supported": "Więcej obsługiwanych formatów", + "Koodo Reader's web version are limited by the browser, for more powerful features, please download the desktop version.": "Wersja internetowa Koodo Reader jest ograniczona przez przeglądarkę, aby uzyskać bardziej zaawansowane funkcje, pobierz wersję na komputer.", + "Chinese Conversion": "Chińska konwersja", + "Use first page as PDF cover": "Użyj pierwszej strony jako okładki PDF", + "You may see this error when the book you're importing is not supported by Koodo Reader, try converting it with Calibre": "Możesz zobaczyć ten błąd, gdy importowana książka nie jest obsługiwana przez Koodo Reader, spróbuj przekonwertować ją za pomocą Calibre", + "Shelf title can't be pure number": "Tytuł półki nie może być samą liczbą", + "Open Console": "Otwórz konsolę", + "Appearance": "Wygląd", + "Light Mode": "Tryb jasny", + "Night Mode": "Tryb ciemny", + "Follow OS": "Śledź system operacyjny", + "Open url with built-in browser": "Otwórz adres url za pomocą wbudowanej przeglądarki" +} \ No newline at end of file diff --git a/src/components/background/index.tsx b/src/components/background/index.tsx index 6a82bbd6..f02b3904 100644 --- a/src/components/background/index.tsx +++ b/src/components/background/index.tsx @@ -8,4 +8,4 @@ const mapStateToProps = (state: stateType) => { }; }; const actionCreator = {}; -export default connect(mapStateToProps, actionCreator)(Background); +export default connect(mapStateToProps, actionCreator)(Background as any); diff --git a/src/components/bookCardItem/component.tsx b/src/components/bookCardItem/component.tsx index eee84970..9e31a196 100644 --- a/src/components/bookCardItem/component.tsx +++ b/src/components/bookCardItem/component.tsx @@ -221,4 +221,4 @@ class BookCardItem extends React.Component { ); } } -export default withRouter(BookCardItem); +export default withRouter(BookCardItem as any); diff --git a/src/components/bookCardItem/index.tsx b/src/components/bookCardItem/index.tsx index 5ad06361..4772241f 100644 --- a/src/components/bookCardItem/index.tsx +++ b/src/components/bookCardItem/index.tsx @@ -7,7 +7,7 @@ import { handleSelectedBooks, } from "../../store/actions"; import { withTranslation } from "react-i18next"; -import Book from "./component"; +import BookCardItem from "./component"; import { stateType } from "../../store"; const mapStateToProps = (state: stateType) => { @@ -29,4 +29,4 @@ const actionCreator = { export default connect( mapStateToProps, actionCreator -)(withTranslation()(Book as any)); +)(withTranslation()(BookCardItem as any) as any); diff --git a/src/components/bookCoverItem/component.tsx b/src/components/bookCoverItem/component.tsx index 0308c8d2..63c83e09 100644 --- a/src/components/bookCoverItem/component.tsx +++ b/src/components/bookCoverItem/component.tsx @@ -229,4 +229,4 @@ class BookCoverItem extends React.Component { ); } } -export default withRouter(BookCoverItem); +export default withRouter(BookCoverItem as any); diff --git a/src/components/bookCoverItem/index.tsx b/src/components/bookCoverItem/index.tsx index 870b0cb7..a80c852c 100644 --- a/src/components/bookCoverItem/index.tsx +++ b/src/components/bookCoverItem/index.tsx @@ -30,4 +30,4 @@ const actionCreator = { export default connect( mapStateToProps, actionCreator -)(withTranslation()(BookCoverItem)); +)(withTranslation()(BookCoverItem as any) as any); diff --git a/src/components/bookListItem/component.tsx b/src/components/bookListItem/component.tsx index caedfaf2..7e819c35 100644 --- a/src/components/bookListItem/component.tsx +++ b/src/components/bookListItem/component.tsx @@ -231,4 +231,4 @@ class BookListItem extends React.Component { } } -export default withRouter(BookListItem); +export default withRouter(BookListItem as any); diff --git a/src/components/bookListItem/index.tsx b/src/components/bookListItem/index.tsx index 9307f14a..d8d8a863 100644 --- a/src/components/bookListItem/index.tsx +++ b/src/components/bookListItem/index.tsx @@ -11,7 +11,7 @@ import { import { withTranslation } from "react-i18next"; import { stateType } from "../../store"; -import BookItem from "./component"; +import BookListItem from "./component"; const mapStateToProps = (state: stateType) => { return { isReading: state.book.isReading, @@ -35,4 +35,4 @@ const actionCreator = { export default connect( mapStateToProps, actionCreator -)(withTranslation()(BookItem as any)); +)(withTranslation()(BookListItem as any) as any); diff --git a/src/components/colorOption/index.tsx b/src/components/colorOption/index.tsx index afc77257..caf522a3 100644 --- a/src/components/colorOption/index.tsx +++ b/src/components/colorOption/index.tsx @@ -12,4 +12,4 @@ const actionCreator = { handleColor, handleSelection, }; -export default connect(mapStateToProps, actionCreator)(About); +export default connect(mapStateToProps, actionCreator)(About as any); diff --git a/src/components/deleteIcon/index.tsx b/src/components/deleteIcon/index.tsx index dd2c852c..f84c8ba1 100644 --- a/src/components/deleteIcon/index.tsx +++ b/src/components/deleteIcon/index.tsx @@ -23,4 +23,4 @@ const actionCreator = { export default connect( mapStateToProps, actionCreator -)(withTranslation()(DeleteIcon as any)); +)(withTranslation()(DeleteIcon as any) as any); diff --git a/src/components/dialogs/aboutDialog/index.tsx b/src/components/dialogs/aboutDialog/index.tsx index 4b483694..ba18bd8c 100644 --- a/src/components/dialogs/aboutDialog/index.tsx +++ b/src/components/dialogs/aboutDialog/index.tsx @@ -14,4 +14,4 @@ const actionCreator = { handleSetting, handleAbout, }; -export default connect(mapStateToProps, actionCreator)(AboutDialog); +export default connect(mapStateToProps, actionCreator)(AboutDialog as any); diff --git a/src/components/dialogs/actionDialog/index.tsx b/src/components/dialogs/actionDialog/index.tsx index 650d906d..7c8b3892 100644 --- a/src/components/dialogs/actionDialog/index.tsx +++ b/src/components/dialogs/actionDialog/index.tsx @@ -29,4 +29,4 @@ const actionCreator = { export default connect( mapStateToProps, actionCreator -)(withTranslation()(ActionDialog as any)); +)(withTranslation()(ActionDialog as any) as any); diff --git a/src/components/dialogs/addDialog/index.tsx b/src/components/dialogs/addDialog/index.tsx index 00825cd3..4e4e41d0 100644 --- a/src/components/dialogs/addDialog/index.tsx +++ b/src/components/dialogs/addDialog/index.tsx @@ -3,7 +3,8 @@ import { handleAddDialog, handleActionDialog, handleMode, - handleShelfIndex,handleSelectBook, + handleShelfIndex, + handleSelectBook, handleSelectedBooks, } from "../../../store/actions"; import { stateType } from "../../../store"; @@ -24,7 +25,8 @@ const mapStateToProps = (state: stateType) => { }; const actionCreator = { handleAddDialog, - handleActionDialog,handleSelectBook, + handleActionDialog, + handleSelectBook, handleMode, handleShelfIndex, handleSelectedBooks, @@ -32,4 +34,4 @@ const actionCreator = { export default connect( mapStateToProps, actionCreator -)(withTranslation()(AddDialog as any)); +)(withTranslation()(AddDialog as any) as any); diff --git a/src/components/dialogs/backupDialog/index.tsx b/src/components/dialogs/backupDialog/index.tsx index 99a145ad..8b4860df 100644 --- a/src/components/dialogs/backupDialog/index.tsx +++ b/src/components/dialogs/backupDialog/index.tsx @@ -29,4 +29,4 @@ const actionCreator = { export default connect( mapStateToProps, actionCreator -)(withTranslation()(BackupDialog)); +)(withTranslation()(BackupDialog as any) as any); diff --git a/src/components/dialogs/deleteDialog/component.tsx b/src/components/dialogs/deleteDialog/component.tsx index 154a8ca8..ee047775 100644 --- a/src/components/dialogs/deleteDialog/component.tsx +++ b/src/components/dialogs/deleteDialog/component.tsx @@ -185,4 +185,4 @@ class DeleteDialog extends React.Component { } } -export default withRouter(DeleteDialog); +export default withRouter(DeleteDialog as any); diff --git a/src/components/dialogs/deleteDialog/index.tsx b/src/components/dialogs/deleteDialog/index.tsx index 73d12196..4ed774b3 100644 --- a/src/components/dialogs/deleteDialog/index.tsx +++ b/src/components/dialogs/deleteDialog/index.tsx @@ -38,4 +38,4 @@ const actionCreator = { export default connect( mapStateToProps, actionCreator -)(withTranslation()(DeleteDialog)); +)(withTranslation()(DeleteDialog as any) as any); diff --git a/src/components/dialogs/deletePopup/index.tsx b/src/components/dialogs/deletePopup/index.tsx index 3269724a..36e5e5ce 100644 --- a/src/components/dialogs/deletePopup/index.tsx +++ b/src/components/dialogs/deletePopup/index.tsx @@ -13,4 +13,4 @@ const actionCreator = { export default connect( mapStateToProps, actionCreator -)(withTranslation()(DeletePopup as any)); +)(withTranslation()(DeletePopup as any) as any); diff --git a/src/components/dialogs/editDialog/index.tsx b/src/components/dialogs/editDialog/index.tsx index 2aa2a7c6..b1584a27 100644 --- a/src/components/dialogs/editDialog/index.tsx +++ b/src/components/dialogs/editDialog/index.tsx @@ -24,4 +24,4 @@ const actionCreator = { export default connect( mapStateToProps, actionCreator -)(withTranslation()(EditDialog)); +)(withTranslation()(EditDialog as any) as any); diff --git a/src/components/popups/popupOption/component.tsx b/src/components/popups/popupOption/component.tsx index 944a1378..9cfbfd7e 100644 --- a/src/components/popups/popupOption/component.tsx +++ b/src/components/popups/popupOption/component.tsx @@ -14,6 +14,7 @@ import copy from "copy-text-to-clipboard"; import { getHightlightCoords } from "../../../utils/fileUtils/pdfUtil"; import { getIframeDoc } from "../../../utils/serviceUtils/docUtil"; import { openExternalUrl } from "../../../utils/serviceUtils/urlUtil"; +import { isElectron } from "react-device-detect"; declare var window: any; @@ -51,6 +52,14 @@ class PopupOption extends React.Component { toast.success(this.props.t("Copy Successfully")); }; handleTrans = () => { + if (!isElectron) { + toast( + this.props.t( + "Koodo Reader's web version are limited by the browser, for more powerful features, please download the desktop version." + ) + ); + return; + } this.props.handleMenuMode("trans"); this.props.handleOriginalText(getSelection() || ""); this.handleEdge(); diff --git a/src/components/popups/popupTrans/component.tsx b/src/components/popups/popupTrans/component.tsx index 969af377..8ddd9a3b 100644 --- a/src/components/popups/popupTrans/component.tsx +++ b/src/components/popups/popupTrans/component.tsx @@ -1,16 +1,18 @@ import React from "react"; import "./popupTrans.css"; import { PopupTransProps, PopupTransState } from "./interface"; -import md5 from "md5"; import { Trans } from "react-i18next"; -import { translationList } from "../../../constants/translationList"; +import { + googleTransList, + bingTransList, +} from "../../../constants/translationList"; import StorageUtil from "../../../utils/serviceUtils/storageUtil"; - class PopupTrans extends React.Component { constructor(props: PopupTransProps) { super(props); this.state = { translatedText: "", + translateService: "Google", }; } componentDidMount() { @@ -18,28 +20,43 @@ class PopupTrans extends React.Component { this.handleTrans(originalText); } handleTrans = (text: string) => { - var script = document.createElement("script"); - script.type = "text/javascript"; - script.src = `https://fanyi-api.baidu.com/api/trans/vip/translate?q=${text}&from=auto&to=${ - StorageUtil.getReaderConfig("transTarget") || "auto" - }&appid=20200802000531425&salt=1435660288&sign=${md5( - // eslint-disable-next-line - "20200802000531425" + text + "1435660288" + "sJRHTorJq8j8_ru2GkHl" - )}&callback=handleCallback`; - document.head.appendChild(script); - (window as any).handleCallback = (res: any) => { - if (res.error_code && res.error_code === 54003) { - this.setState({ - translatedText: this.props.t("Reach frequency limit"), + if (StorageUtil.getReaderConfig("transService") === "Bing") { + const { translate } = window.require("bing-translate-api"); + translate( + text, + null, + StorageUtil.getReaderConfig("transTarget") || "en", + false + ) + .then((res) => { + this.setState({ + translatedText: res.translation, + }); + }) + .catch((err) => { + console.error(err); + this.setState({ + translatedText: this.props.t("Error happens"), + }); }); - } else { - this.setState({ - translatedText: res.trans_result - ? res.trans_result[0].dst - : this.props.t("Error happens"), + } else { + const translate = window.require("@vitalets/google-translate-api"); + translate(text, { + to: StorageUtil.getReaderConfig("transTarget") || "en", + tld: navigator.language === "zh-CN" ? "cn" : "com", + }) + .then((res) => { + this.setState({ + translatedText: res.text, + }); + }) + .catch((err) => { + console.log(err); + this.setState({ + translatedText: this.props.t("Error happens"), + }); }); - } - }; + } }; render() { const renderNoteEditor = () => { @@ -48,11 +65,39 @@ class PopupTrans extends React.Component {
{this.state.translatedText}

- Target + Select

+