From 09e65211b4120f2d112bf880470f9cdbe65ffd13 Mon Sep 17 00:00:00 2001 From: Andres Puello <77623794+afrolino02@users.noreply.github.com> Date: Fri, 8 Aug 2025 23:23:18 -0500 Subject: [PATCH] feat: add option to config reading progress format (#1761) * feat: added percentage option and set by default * feat: added decimal percentaje * fix: fixed issue that the function of format didn't look for typeof * fix: Added revision fixes * fix: Added revision fixes and changes * fix: solved about styling code * fix: solved about styling code on book.ts and translation.json * fix: changed lines useEffect line that is escencial to Layoutpanel.tsx, and ProgressInfo.tsx has correct render like last version (Loc.) nd its separator * fix: correct SUPPORTED_LANGS key and disable style reapplication in saveViewSettings * i18n for the progress style config --------- Co-authored-by: Huang Xin --- .../public/locales/ar/translation.json | 9 +++-- .../public/locales/de/translation.json | 9 +++-- .../public/locales/el/translation.json | 9 +++-- .../public/locales/es/translation.json | 9 +++-- .../public/locales/fr/translation.json | 9 +++-- .../public/locales/hi/translation.json | 9 +++-- .../public/locales/id/translation.json | 9 +++-- .../public/locales/it/translation.json | 9 +++-- .../public/locales/ja/translation.json | 9 +++-- .../public/locales/ko/translation.json | 9 +++-- .../public/locales/nl/translation.json | 9 +++-- .../public/locales/pl/translation.json | 9 +++-- .../public/locales/pt/translation.json | 9 +++-- .../public/locales/ru/translation.json | 9 +++-- .../public/locales/th/translation.json | 9 +++-- .../public/locales/tr/translation.json | 9 +++-- .../public/locales/uk/translation.json | 7 ++-- .../public/locales/vi/translation.json | 9 +++-- .../public/locales/zh-CN/translation.json | 9 +++-- .../public/locales/zh-TW/translation.json | 9 +++-- .../app/reader/components/ProgressInfo.tsx | 28 ++++++++-------- .../components/settings/LayoutPanel.tsx | 33 ++++++++++++++----- apps/readest-app/src/components/Select.tsx | 2 +- apps/readest-app/src/services/constants.ts | 3 +- apps/readest-app/src/types/book.ts | 3 +- apps/readest-app/src/utils/progress.ts | 13 ++++++++ 26 files changed, 177 insertions(+), 83 deletions(-) create mode 100644 apps/readest-app/src/utils/progress.ts diff --git a/apps/readest-app/public/locales/ar/translation.json b/apps/readest-app/public/locales/ar/translation.json index 0f9f4096..69a5a71c 100644 --- a/apps/readest-app/public/locales/ar/translation.json +++ b/apps/readest-app/public/locales/ar/translation.json @@ -318,7 +318,6 @@ "Synced at {{time}}": "تمت المزامنة في {{time}}", "Never synced": "لم تتم المزامنة بعد", "Show Remaining Time": "إظهار الوقت المتبقي", - "Show Page Number": "إظهار رقم الصفحة", "{{time}} min left in chapter": "{{time}} دقيقة متبقية حتى نهاية الفصل", "Override Book Color": "تجاوز لون الكتاب", "Login Required": "يتطلب الأمر تسجيل الدخول", @@ -478,5 +477,9 @@ "Privacy Policy": "سياسة الخصوصية", "Disable Double Click": "تعطيل النقر المزدوج", "TTS not supported for this document": "تكنولوجيا تحويل النص إلى كلام غير مدعومة لهذا المستند.", - "Reset Password": "إعادة تعيين" -} \ No newline at end of file + "Reset Password": "إعادة تعيين", + "Show Reading Progress": "إظهار تقدم القراءة", + "Reading Progress Style": "نمط تقدم القراءة", + "Page Number": "رقم الصفحة", + "Percentage": "النسبة المئوية" +} diff --git a/apps/readest-app/public/locales/de/translation.json b/apps/readest-app/public/locales/de/translation.json index 6b356f2f..4582b4a3 100644 --- a/apps/readest-app/public/locales/de/translation.json +++ b/apps/readest-app/public/locales/de/translation.json @@ -310,7 +310,6 @@ "Synced at {{time}}": "Synchronisiert um {{time}}", "Never synced": "Nie synchronisiert", "Show Remaining Time": "Verbleibende Zeit anzeigen", - "Show Page Number": "Seitenzahl anzeigen", "{{time}} min left in chapter": "{{time}} min verbleibend im Kapitel", "Override Book Color": "Farbe des Buches überschreiben", "Login Required": "Anmeldung nötig", @@ -462,5 +461,9 @@ "Privacy Policy": "Datenschutzbestimmungen", "Disable Double Click": "Doppelklick deaktivieren", "TTS not supported for this document": "TTS wird für dieses Dokument nicht unterstützt", - "Reset Password": "Passwort zurücksetzen" -} \ No newline at end of file + "Reset Password": "Passwort zurücksetzen", + "Show Reading Progress": "Lesefortschritt anzeigen", + "Reading Progress Style": "Lesefortschritt-Stil", + "Page Number": "Seitenzahl", + "Percentage": "Prozentsatz" +} diff --git a/apps/readest-app/public/locales/el/translation.json b/apps/readest-app/public/locales/el/translation.json index 92f3316d..af425041 100644 --- a/apps/readest-app/public/locales/el/translation.json +++ b/apps/readest-app/public/locales/el/translation.json @@ -311,7 +311,6 @@ "Synced at {{time}}": "Συγχρονίστηκε στις {{time}}", "Never synced": "Ποτέ δεν συγχρονίστηκε", "Show Remaining Time": "Εμφάνιση υπολειπόμενου χρόνου", - "Show Page Number": "Εμφάνιση αριθμού σελίδας", "{{time}} min left in chapter": "{{time}} λεπτά απομένουν στο κεφάλαιο", "Override Book Color": "Παράκαμψη χρώματος βιβλίου", "Login Required": "Απαιτείται σύνδεση", @@ -462,5 +461,9 @@ "Privacy Policy": "Πολιτική απορρήτου", "Disable Double Click": "Απενεργοποίηση διπλού κλικ", "TTS not supported for this document": "Η τεχνολογία TTS δεν υποστηρίζεται για αυτό το έγγραφο.", - "Reset Password": "Επαναφορά κωδικού" -} \ No newline at end of file + "Reset Password": "Επαναφορά κωδικού", + "Show Reading Progress": "Εμφάνιση προόδου ανάγνωσης", + "Reading Progress Style": "Στυλ προόδου ανάγνωσης", + "Page Number": "Αριθμός σελίδας", + "Percentage": "Ποσοστό" +} diff --git a/apps/readest-app/public/locales/es/translation.json b/apps/readest-app/public/locales/es/translation.json index 44b01f92..ef9cb2d9 100644 --- a/apps/readest-app/public/locales/es/translation.json +++ b/apps/readest-app/public/locales/es/translation.json @@ -313,7 +313,6 @@ "Synced at {{time}}": "Sincronizado a las {{time}}", "Never synced": "Nunca sincronizado", "Show Remaining Time": "Mostrar tiempo restante", - "Show Page Number": "Mostrar número de página", "{{time}} min left in chapter": "{{time}} min restantes en el capítulo", "Override Book Color": "Sobre escribir color del libro", "Login Required": "Iniciar sesión", @@ -466,5 +465,9 @@ "Privacy Policy": "Política de privacidad", "Disable Double Click": "Deshabilitar Doble Clic", "TTS not supported for this document": "TTS no es compatible con este documento.", - "Reset Password": "Restablecer contraseña" -} \ No newline at end of file + "Reset Password": "Restablecer contraseña", + "Reading Progress Style": "Estilo de progreso de lectura", + "Percentage": "Porcentaje", + "Show Reading Progress": "Mostrar progreso de lectura", + "Page Number": "Número de página" +} diff --git a/apps/readest-app/public/locales/fr/translation.json b/apps/readest-app/public/locales/fr/translation.json index 364f2030..b2bc1bfb 100644 --- a/apps/readest-app/public/locales/fr/translation.json +++ b/apps/readest-app/public/locales/fr/translation.json @@ -312,7 +312,6 @@ "Synced at {{time}}": "Synchronisé à {{time}}", "Never synced": "Jamais synchronisé", "Show Remaining Time": "Afficher le temps restant", - "Show Page Number": "Afficher le numéro de page", "{{time}} min left in chapter": "{{time}} min restant dans le chapitre", "Override Book Color": "Remplacer la couleur du livre", "Login Required": "Connexion requise", @@ -466,5 +465,9 @@ "Privacy Policy": "Politique de confidentialité", "Disable Double Click": "Désactiver le double-clic", "TTS not supported for this document": "TTS non pris en charge pour ce document", - "Reset Password": "Nouveau mot de passe" -} \ No newline at end of file + "Reset Password": "Nouveau mot de passe", + "Show Reading Progress": "Afficher la progression", + "Reading Progress Style": "Style de progression", + "Page Number": "Numéro de page", + "Percentage": "Pourcentage" +} diff --git a/apps/readest-app/public/locales/hi/translation.json b/apps/readest-app/public/locales/hi/translation.json index dab6b076..a89836bd 100644 --- a/apps/readest-app/public/locales/hi/translation.json +++ b/apps/readest-app/public/locales/hi/translation.json @@ -311,7 +311,6 @@ "Synced at {{time}}": "{{time}} पर सिंक किया गया", "Never synced": "कभी सिंक नहीं किया गया", "Show Remaining Time": "शेष समय दिखाएं", - "Show Page Number": "पृष्ठ संख्या दिखाएं", "{{time}} min left in chapter": "{{time}} मिनट शेष अध्याय में", "Override Book Color": "पुस्तक रंग ओवरराइड करें", "Login Required": "लॉगिन ज़रूरी", @@ -462,5 +461,9 @@ "Privacy Policy": "गोपनीयता नीति", "Disable Double Click": "डबल क्लिक अक्षम करें", "TTS not supported for this document": "TTS इस दस्तावेज़ के लिए समर्थित नहीं है", - "Reset Password": "पासवर्ड रीसेट करें" -} \ No newline at end of file + "Reset Password": "पासवर्ड रीसेट करें", + "Show Reading Progress": "पढ़ने की प्रगति दिखाएं", + "Reading Progress Style": "पढ़ने की प्रगति शैली", + "Page Number": "पृष्ठ संख्या", + "Percentage": "प्रतिशत" +} diff --git a/apps/readest-app/public/locales/id/translation.json b/apps/readest-app/public/locales/id/translation.json index 0b955f2a..934942ec 100644 --- a/apps/readest-app/public/locales/id/translation.json +++ b/apps/readest-app/public/locales/id/translation.json @@ -309,7 +309,6 @@ "Synced at {{time}}": "Disinkronkan pada {{time}}", "Never synced": "Belum pernah disinkronkan", "Show Remaining Time": "Perlihatkan Waktu Tersisa", - "Show Page Number": "Perlihatkan Nomor Halaman", "{{time}} min left in chapter": "{{time}} menit tersisa di bab", "Override Book Color": "Ubah Warna Buku", "Login Required": "Perlu masuk", @@ -458,5 +457,9 @@ "Privacy Policy": "Kebijakan Privasi", "Disable Double Click": "Nonaktifkan Klik Ganda", "TTS not supported for this document": "TTS tidak didukung untuk dokumen ini", - "Reset Password": "Reset Kata Sandi" -} \ No newline at end of file + "Reset Password": "Reset Kata Sandi", + "Show Reading Progress": "Perlihatkan Progres Membaca", + "Reading Progress Style": "Gaya Progres Membaca", + "Page Number": "Nomor Halaman", + "Percentage": "Persentase" +} diff --git a/apps/readest-app/public/locales/it/translation.json b/apps/readest-app/public/locales/it/translation.json index 74da919d..ec18dd9f 100644 --- a/apps/readest-app/public/locales/it/translation.json +++ b/apps/readest-app/public/locales/it/translation.json @@ -313,7 +313,6 @@ "Synced at {{time}}": "Sincronizzato alle {{time}}", "Never synced": "Mai sincronizzato", "Show Remaining Time": "Mostra tempo rimanente", - "Show Page Number": "Mostra numero pagina", "{{time}} min left in chapter": "{{time}} min rimasti nel capitolo", "Override Book Color": "Override colore libro", "Login Required": "Accesso richiesto", @@ -466,5 +465,9 @@ "Privacy Policy": "Informativa sulla privacy", "Disable Double Click": "Disabilita Doppio Clic", "TTS not supported for this document": "TTS non supportato per questo documento", - "Reset Password": "Reimposta Password" -} \ No newline at end of file + "Reset Password": "Reimposta Password", + "Show Reading Progress": "Mostra Progresso Lettura", + "Reading Progress Style": "Stile di Progresso Lettura", + "Page Number": "Numero di Pagina", + "Percentage": "Percentuale" +} diff --git a/apps/readest-app/public/locales/ja/translation.json b/apps/readest-app/public/locales/ja/translation.json index 24ac334c..55e28375 100644 --- a/apps/readest-app/public/locales/ja/translation.json +++ b/apps/readest-app/public/locales/ja/translation.json @@ -309,7 +309,6 @@ "Synced at {{time}}": "{{time}} に同期済み", "Never synced": "まだ同期されていません", "Show Remaining Time": "残り時間を表示", - "Show Page Number": "ページ番号を表示", "{{time}} min left in chapter": "{{time}}分残り", "Override Book Color": "書籍の色を上書き", "Login Required": "ログイン必須", @@ -458,5 +457,9 @@ "Privacy Policy": "プライバシーポリシー", "Disable Double Click": "ダブルクリック無効", "TTS not supported for this document": "TTSはこのドキュメントではサポートされていません", - "Reset Password": "パスワードをリセット" -} \ No newline at end of file + "Reset Password": "パスワードをリセット", + "Show Reading Progress": "読書進捗を表示", + "Reading Progress Style": "読書進捗スタイル", + "Page Number": "ページ番号", + "Percentage": "パーセンテージ" +} diff --git a/apps/readest-app/public/locales/ko/translation.json b/apps/readest-app/public/locales/ko/translation.json index 6a2e36f0..7d8b59b8 100644 --- a/apps/readest-app/public/locales/ko/translation.json +++ b/apps/readest-app/public/locales/ko/translation.json @@ -309,7 +309,6 @@ "Synced at {{time}}": "{{time}}에 동기화됨", "Never synced": "동기화된 적 없음", "Show Remaining Time": "남은 시간 표시", - "Show Page Number": "페이지 번호 표시", "{{time}} min left in chapter": "{{time}}분 남음", "Override Book Color": "책 색상 덮어쓰기", "Login Required": "로그인 필요", @@ -458,5 +457,9 @@ "Privacy Policy": "개인정보 보호정책", "Disable Double Click": "더블 클릭 비활성화", "TTS not supported for this document": "TTS가 이 문서에서 지원되지 않습니다", - "Reset Password": "비밀번호 재설정" -} \ No newline at end of file + "Reset Password": "비밀번호 재설정", + "Show Reading Progress": "읽기 진행 상황 표시", + "Reading Progress Style": "읽기 진행 상황 스타일", + "Page Number": "페이지 번호", + "Percentage": "백분율" +} diff --git a/apps/readest-app/public/locales/nl/translation.json b/apps/readest-app/public/locales/nl/translation.json index cc269574..c99af9cc 100644 --- a/apps/readest-app/public/locales/nl/translation.json +++ b/apps/readest-app/public/locales/nl/translation.json @@ -311,7 +311,6 @@ "Synced at {{time}}": "Gesynchroniseerd om {{time}}", "Never synced": "Nooit gesynchroniseerd", "Show Remaining Time": "Toon resterende tijd", - "Show Page Number": "Toon paginanummer", "{{time}} min left in chapter": "Nog {{time}} min in hoofdstuk", "Override Book Color": "Boekkleur overschrijven", "Login Required": "Inloggen vereist", @@ -462,5 +461,9 @@ "Privacy Policy": "Privacybeleid", "Disable Double Click": "Dubbelklikken uitschakelen", "TTS not supported for this document": "TTS niet ondersteund voor dit document", - "Reset Password": "Wachtwoord resetten" -} \ No newline at end of file + "Reset Password": "Wachtwoord resetten", + "Show Reading Progress": "Leesvoortgang weergeven", + "Reading Progress Style": "Stijl van leesvoortgang", + "Page Number": "Pagina nummer", + "Percentage": "Percentage" +} diff --git a/apps/readest-app/public/locales/pl/translation.json b/apps/readest-app/public/locales/pl/translation.json index 0e7e2c32..cbe98d1f 100644 --- a/apps/readest-app/public/locales/pl/translation.json +++ b/apps/readest-app/public/locales/pl/translation.json @@ -315,7 +315,6 @@ "Synced at {{time}}": "Sync: {{time}}", "Never synced": "Brak synchronizacji", "Show Remaining Time": "Pokazuj pozostały czas", - "Show Page Number": "Pokaż numer strony", "{{time}} min left in chapter": "{{time}} min pozostało do końca rozdziału", "Override Book Color": "Nadpisz kolor książki", "Login Required": "Wymagane logowanie", @@ -470,5 +469,9 @@ "Privacy Policy": "Polityka prywatności", "Disable Double Click": "Wyłącz podwójne kliknięcie", "TTS not supported for this document": "TTS nie jest obsługiwane dla tego dokumentu", - "Reset Password": "Zresetuj hasło" -} \ No newline at end of file + "Reset Password": "Zresetuj hasło", + "Show Reading Progress": "Pokazuj postęp czytania", + "Reading Progress Style": "Styl postępu czytania", + "Page Number": "Numer strony", + "Percentage": "Procent" +} diff --git a/apps/readest-app/public/locales/pt/translation.json b/apps/readest-app/public/locales/pt/translation.json index 28811b56..6f6e10fa 100644 --- a/apps/readest-app/public/locales/pt/translation.json +++ b/apps/readest-app/public/locales/pt/translation.json @@ -313,7 +313,6 @@ "Synced at {{time}}": "Sincronizado às {{time}}", "Never synced": "Nunca sincronizado", "Show Remaining Time": "Mostrar Tempo Restante", - "Show Page Number": "Mostrar Número da Página", "{{time}} min left in chapter": "{{time}} min restantes no capítulo", "Override Book Color": "Substituir Cor do Livro", "Login Required": "Login necessário", @@ -466,5 +465,9 @@ "Privacy Policy": "Política de Privacidade", "Disable Double Click": "Desativar Clique Duplo", "TTS not supported for this document": "TTS não suportado para este documento", - "Reset Password": "Redefinir Senha" -} \ No newline at end of file + "Reset Password": "Redefinir Senha", + "Show Reading Progress": "Mostrar Progresso de Leitura", + "Reading Progress Style": "Estilo de Progresso de Leitura", + "Page Number": "Número da Página", + "Percentage": "Porcentagem" +} diff --git a/apps/readest-app/public/locales/ru/translation.json b/apps/readest-app/public/locales/ru/translation.json index ad2715c2..643915b8 100644 --- a/apps/readest-app/public/locales/ru/translation.json +++ b/apps/readest-app/public/locales/ru/translation.json @@ -315,7 +315,6 @@ "Synced at {{time}}": "Синхр. в {{time}}", "Never synced": "Не синхр.", "Show Remaining Time": "Показать оставшееся время", - "Show Page Number": "Показать номер страницы", "{{time}} min left in chapter": "{{time}} мин осталось в главе", "Override Book Color": "Переопределить цвет книги", "Login Required": "Требуется вход", @@ -470,5 +469,9 @@ "Privacy Policy": "Политика конфиденциальности", "Disable Double Click": "Отключить двойной клик", "TTS not supported for this document": "TTS не поддерживается для этого документа", - "Reset Password": "Сбросить пароль" -} \ No newline at end of file + "Reset Password": "Сбросить пароль", + "Show Reading Progress": "Показать прогресс чтения", + "Reading Progress Style": "Стиль прогресса чтения", + "Page Number": "Номер страницы", + "Percentage": "Процент" +} diff --git a/apps/readest-app/public/locales/th/translation.json b/apps/readest-app/public/locales/th/translation.json index a57e1a30..a39b1512 100644 --- a/apps/readest-app/public/locales/th/translation.json +++ b/apps/readest-app/public/locales/th/translation.json @@ -237,7 +237,6 @@ "Show Footer": "แสดงท้ายกระดาษ", "Show Remaining Time": "แสดงเวลาที่เหลือ", "Show Remaining Pages": "แสดงหน้าที่เหลือ", - "Show Page Number": "แสดงเลขหน้า", "Apply also in Scrolled Mode": "ใช้ในโหมดเลื่อนด้วย", "Screen": "หน้าจอ", "Orientation": "การวางแนว", @@ -458,5 +457,9 @@ "Privacy Policy": "นโยบายความเป็นส่วนตัว", "Disable Double Click": "ปิดการคลิกสองครั้ง", "TTS not supported for this document": "ไม่รองรับ TTS สำหรับเอกสารนี้", - "Reset Password": "รีเซ็ตพาสเวิร์ด" -} \ No newline at end of file + "Reset Password": "รีเซ็ตพาสเวิร์ด", + "Show Reading Progress": "แสดงความคืบหน้าในการอ่าน", + "Reading Progress Style": "สไตล์ความก้าวหน้าในการอ่าน", + "Page Number": "หมายเลขหน้า", + "Percentage": "เปอร์เซ็นต์" +} diff --git a/apps/readest-app/public/locales/tr/translation.json b/apps/readest-app/public/locales/tr/translation.json index dd55081b..7c04e8f3 100644 --- a/apps/readest-app/public/locales/tr/translation.json +++ b/apps/readest-app/public/locales/tr/translation.json @@ -311,7 +311,6 @@ "Synced at {{time}}": "{{time}}'de eşzlendi", "Never synced": "Hiç eşzlenmedi", "Show Remaining Time": "Kalan Süreyi Göster", - "Show Page Number": "Sayfa Numarasını Göster", "{{time}} min left in chapter": "{{time}} dakika bölümde kaldı", "Override Book Color": "Kitap Rengini Geçersiz Kıl", "Login Required": "Giriş gerekli", @@ -462,5 +461,9 @@ "Privacy Policy": "Gizlilik Politikası", "Disable Double Click": "Çift Tıklamayı Devre Dışı Bırak", "TTS not supported for this document": "TTS bu belge için desteklenmiyor", - "Reset Password": "Şifreyi Sıfırla" -} \ No newline at end of file + "Reset Password": "Şifreyi Sıfırla", + "Show Reading Progress": "Okuma İlerlemesini Göster", + "Reading Progress Style": "Okuma İlerlemesi Stili", + "Page Number": "Sayfa Numarası", + "Percentage": "Yüzde" +} diff --git a/apps/readest-app/public/locales/uk/translation.json b/apps/readest-app/public/locales/uk/translation.json index dc7e7d8f..7a59e41a 100644 --- a/apps/readest-app/public/locales/uk/translation.json +++ b/apps/readest-app/public/locales/uk/translation.json @@ -315,7 +315,6 @@ "Synced at {{time}}": "Синхр. о {{time}}", "Never synced": "Ніколи не синхр.", "Show Remaining Time": "Показати залишок часу", - "Show Page Number": "Показати номер сторінки", "{{time}} min left in chapter": "{{time}} хв до кінця розділу", "Override Book Color": "Перевизначити колір книги", "Login Required": "Потрібен вхід", @@ -470,5 +469,9 @@ "Privacy Policy": "Політика конфіденційності", "Disable Double Click": "Вимкнути подвійне натискання", "TTS not supported for this document": "TTS не підтримується в цьому документі", - "Reset Password": "Скинути пароль" + "Reset Password": "Скинути пароль", + "Show Reading Progress": "Показати прогрес читання", + "Reading Progress Style": "Стиль прогресу читання", + "Page Number": "Номер сторінки", + "Percentage": "Процент" } diff --git a/apps/readest-app/public/locales/vi/translation.json b/apps/readest-app/public/locales/vi/translation.json index 884121a8..9964ae2c 100644 --- a/apps/readest-app/public/locales/vi/translation.json +++ b/apps/readest-app/public/locales/vi/translation.json @@ -309,7 +309,6 @@ "Synced at {{time}}": "Đã đồng bộ lúc {{time}}", "Never synced": "Chưa từng đồng bộ", "Show Remaining Time": "Hiển thị thời gian còn lại", - "Show Page Number": "Hiển thị số trang", "{{time}} min left in chapter": "{{time}} phút còn lại trong chương", "Override Book Color": "Đổi màu sách", "Login Required": "Cần đăng nhập", @@ -458,5 +457,9 @@ "Privacy Policy": "Chính sách bảo mật", "Disable Double Click": "Tắt Nhấp Đôi", "TTS not supported for this document": "TTS không được hỗ trợ cho tài liệu này", - "Reset Password": "Đặt lại mật khẩu" -} \ No newline at end of file + "Reset Password": "Đặt lại mật khẩu", + "Show Reading Progress": "Hiển thị tiến độ đọc", + "Reading Progress Style": "Phong cách tiến độ đọc", + "Page Number": "Số trang", + "Percentage": "Phần trăm" +} diff --git a/apps/readest-app/public/locales/zh-CN/translation.json b/apps/readest-app/public/locales/zh-CN/translation.json index 82ee4150..5a618a8d 100644 --- a/apps/readest-app/public/locales/zh-CN/translation.json +++ b/apps/readest-app/public/locales/zh-CN/translation.json @@ -309,7 +309,6 @@ "Synced at {{time}}": "同步于:{{time}}", "Never synced": "从未同步", "Show Remaining Time": "显示剩余时间", - "Show Page Number": "显示页码", "{{time}} min left in chapter": "本章剩余 {{time}} 分钟", "Override Book Color": "覆盖书籍颜色", "Login Required": "需登录", @@ -458,5 +457,9 @@ "Privacy Policy": "隐私政策", "Disable Double Click": "禁用双击", "TTS not supported for this document": "TTS 不支持此文档", - "Reset Password": "重置密码" -} \ No newline at end of file + "Reset Password": "重置密码", + "Show Reading Progress": "显示阅读进度", + "Reading Progress Style": "阅读进度样式", + "Page Number": "页码", + "Percentage": "百分比" +} diff --git a/apps/readest-app/public/locales/zh-TW/translation.json b/apps/readest-app/public/locales/zh-TW/translation.json index d37abf14..2683700d 100644 --- a/apps/readest-app/public/locales/zh-TW/translation.json +++ b/apps/readest-app/public/locales/zh-TW/translation.json @@ -309,7 +309,6 @@ "Synced at {{time}}": "同步於:{{time}}", "Never synced": "從未同步", "Show Remaining Time": "顯示剩餘時間", - "Show Page Number": "顯示頁碼", "{{time}} min left in chapter": "本章剩餘 {{time}} 分鐘", "Override Book Color": "覆蓋書籍顏色", "Login Required": "需登入", @@ -458,5 +457,9 @@ "Privacy Policy": "隱私政策", "Disable Double Click": "禁用雙擊", "TTS not supported for this document": "TTS 不支援此文件", - "Reset Password": "重設密碼" -} \ No newline at end of file + "Reset Password": "重設密碼", + "Show Reading Progress": "顯示閱讀進度", + "Reading Progress Style": "閱讀進度樣式", + "Page Number": "頁碼", + "Percentage": "百分比" +} diff --git a/apps/readest-app/src/app/reader/components/ProgressInfo.tsx b/apps/readest-app/src/app/reader/components/ProgressInfo.tsx index 7a69b28c..9ec181cf 100644 --- a/apps/readest-app/src/app/reader/components/ProgressInfo.tsx +++ b/apps/readest-app/src/app/reader/components/ProgressInfo.tsx @@ -1,10 +1,11 @@ import clsx from 'clsx'; import React from 'react'; import { Insets } from '@/types/misc'; +import { PageInfo, TimeInfo } from '@/types/book'; import { useEnv } from '@/context/EnvContext'; import { useReaderStore } from '@/store/readerStore'; import { useTranslation } from '@/hooks/useTranslation'; -import { PageInfo, TimeInfo } from '@/types/book'; +import { formatReadingProgress } from '@/utils/progress'; interface PageInfoProps { bookKey: string; @@ -36,18 +37,19 @@ const ProgressInfoView: React.FC = ({ const showDoubleBorder = viewSettings.vertical && viewSettings.doubleBorder; const isScrolled = viewSettings.scrolled; const isVertical = viewSettings.vertical; - const pageInfo = ['PDF', 'CBZ'].includes(bookFormat) - ? section + const { progressStyle: readingProgressStyle } = viewSettings; + + const formatTemplate = + readingProgressStyle === 'fraction' ? isVertical - ? `${section.current + 1} · ${section.total}` - : `${section.current + 1} / ${section.total}` - : '' - : pageinfo && pageinfo.current >= 0 && pageinfo.total > 0 - ? _(isVertical ? '{{currentPage}} · {{totalPage}}' : 'Loc. {{currentPage}} / {{totalPage}}', { - currentPage: pageinfo.current + 1, - totalPage: pageinfo.total, - }) - : ''; + ? '{current} · {total}' + : '{current} / {total}' + : '{percent}%'; + + const progressInfo = ['PDF', 'CBZ'].includes(bookFormat) + ? formatReadingProgress(section?.current, section?.total, formatTemplate) + : formatReadingProgress(pageinfo?.current, pageinfo?.total, formatTemplate); + const timeLeft = timeinfo ? _('{{time}} min left in chapter', { time: Math.round(timeinfo.section) }) : ''; @@ -85,7 +87,7 @@ const ProgressInfoView: React.FC = ({ ) : viewSettings.showRemainingPages ? ( {pageLeft} ) : null} - {viewSettings.showPageNumber && {pageInfo}} + {viewSettings.showProgressInfo && {progressInfo}} ); }; diff --git a/apps/readest-app/src/app/reader/components/settings/LayoutPanel.tsx b/apps/readest-app/src/app/reader/components/settings/LayoutPanel.tsx index 16a7215c..ff0b3d78 100644 --- a/apps/readest-app/src/app/reader/components/settings/LayoutPanel.tsx +++ b/apps/readest-app/src/app/reader/components/settings/LayoutPanel.tsx @@ -18,6 +18,7 @@ import { saveViewSettings } from '../../utils/viewSettingsHelper'; import { getBookDirFromWritingMode, getBookLangCode } from '@/utils/book'; import { MIGHT_BE_RTL_LANGS } from '@/services/constants'; import { SettingsPanelPanelProp } from './SettingsDialog'; +import Select from '@/components/Select'; import NumberInput from './NumberInput'; const LayoutPanel: React.FC = ({ bookKey, onRegisterReset }) => { @@ -66,9 +67,9 @@ const LayoutPanel: React.FC = ({ bookKey, onRegisterRese const [showBarsOnScroll, setShowBarsOnScroll] = useState(viewSettings.showBarsOnScroll!); const [showRemainingTime, setShowRemainingTime] = useState(viewSettings.showRemainingTime!); const [showRemainingPages, setShowRemainingPages] = useState(viewSettings.showRemainingPages!); - const [showPageNumber, setShowPageNumber] = useState(viewSettings.showPageNumber!); + const [showProgressInfo, setShowProgressInfo] = useState(viewSettings.showProgressInfo!); + const [progressStyle, setProgressStyle] = useState(viewSettings.progressStyle); const [screenOrientation, setScreenOrientation] = useState(viewSettings.screenOrientation!); - const resetToDefaults = useResetViewSettings(); const handleReset = () => { @@ -100,7 +101,7 @@ const LayoutPanel: React.FC = ({ bookKey, onRegisterRese showBarsOnScroll: setShowBarsOnScroll, showRemainingTime: setShowRemainingTime, showRemainingPages: setShowRemainingPages, - showPageNumber: setShowPageNumber, + showProgressInfo: setShowProgressInfo, }); }; @@ -319,9 +320,13 @@ const LayoutPanel: React.FC = ({ bookKey, onRegisterRese }, [showRemainingPages]); useEffect(() => { - saveViewSettings(envConfig, bookKey, 'showPageNumber', showPageNumber, false, false); + saveViewSettings(envConfig, bookKey, 'showProgressInfo', showProgressInfo, false, false); // eslint-disable-next-line react-hooks/exhaustive-deps - }, [showPageNumber]); + }, [showProgressInfo]); + + useEffect(() => { + saveViewSettings(envConfig, bookKey, 'progressStyle', progressStyle, false, false); + }, [progressStyle]); useEffect(() => { if (showHeader === viewSettings.showHeader) return; @@ -654,13 +659,25 @@ const LayoutPanel: React.FC = ({ bookKey, onRegisterRese />
- {_('Show Page Number')} + {_('Show Reading Progress')} setShowPageNumber(!showPageNumber)} + onChange={() => setShowProgressInfo(!showProgressInfo)} + /> +
+
+ {_('Reading Progress Style')} +