Zeedif 61f429896c feat(opds): implement full internationalization and refactor feed gen… (#1405)
* feat(opds): implement full internationalization and refactor feed generation

This commit introduces a comprehensive internationalization (i18n) framework
and significantly refactors the OPDS v1.2 implementation for improved
robustness, spec compliance, and localization.

Key changes:

Internationalization (`i18n`):
- Introduces `LocalizationService` to manage translations:
    - Loads localized strings from JSON files (e.g., `en.json`, `es.json`)
      stored in a new `i18n` data directory.
    - Default `en.json` and `es.json` files are bundled and copied from
      resources on first run if not present.
    - Supports template resolution with `$t()` cross-references, locale
      fallbacks (to "en" by default), and argument interpolation ({{placeholder}}).
- `ServerSetup` now initializes the `i18n` directory and `LocalizationService`.

OPDS Refactor & Enhancements:
- Replaces the previous `Opds.kt` and `OpdsDataClass.kt` with a new
  `OpdsFeedBuilder.kt` and a set of more granular, spec-aligned XML
  models (e.g., `OpdsFeedXml`, `OpdsEntryXml`, `OpdsLinkXml`).
- Integrates `LocalizationService` throughout all OPDS feeds:
    - All user-facing text (feed titles, entry titles, summaries,
      link titles, facet labels for sorting/filtering) is now localized.
    - Adds a `lang` query parameter to all OPDS endpoints to allow
      clients to request a specific UI language.
    - Uses the `Accept-Language` header as a fallback for language detection.
- The OpenSearch description (`/search` endpoint) is now localized and
  its template URL includes the determined language.
- Centralizes OPDS constants (namespaces, link relations, media types)
  in `OpdsConstants.kt`.
- Adds utility classes `OpdsDateUtil.kt`, `OpdsStringUtil.kt`, and
  `OpdsXmlUtil.kt` for common OPDS tasks.
- `MangaDataClass` now includes `sourceLang` to provide the content
  language of the manga in OPDS entries (`<dc:language>`).
- Updates OpenAPI documentation for OPDS endpoints with more detail
  and includes the new `lang` parameter.

Configuration:
- Adds `useBinaryFileSizes` server configuration option. File sizes in
  OPDS feeds now respect this setting (e.g., MiB vs MB), utilized via
  `OpdsStringUtil.formatFileSizeForOpds`.

This major refactor addresses the request for internationalization
originally mentioned in PR #1257 ("it would be great if messages were
adapted based on the user's language settings"). It builds upon the
foundational OPDS work in #1257 and subsequent enhancements in #1262,
#1263, #1278, and #1392, providing a more stable and extensible
OPDS implementation. Features like localized facet titles from #1392
are now fully integrated with the i18n system.

This resolves long-standing requests for better OPDS support (e.g., issue #769)
by making feeds more user-friendly, accessible, and standards-compliant,
also improving the robustness of features requested in #1390 (resolved by #1392)
and addressing underlying data needs for issues like #1265 (related to #1277, #1278).

* fix(opds): revert MIME type to application/xml for browser compatibility

* fix(opds): use chapter index for metadata feed and correct link relation

- Change `getChapterMetadataFeed` to use `chapterIndexFromPath` (sourceOrder)
  instead of `chapterIdFromPath` for fetching chapter data, ensuring
  consistency with how chapters are identified in manga feeds.
- Add error handling for cases where manga or chapter by index is not found.
- Correct OPDS link relation for chapter detail/fetch link in non-metadata
  chapter entries from `alternate` to `subsection` as per OPDS spec
  for navigation to more specific content or views.

* Use Moko-Resources

* Format

* Forgot the Languages.json

* refactor(opds)!: restructure OPDS feeds and introduce data repositories

This commit significantly refactors the OPDS v1.2 implementation by introducing dedicated repository classes for data fetching and by restructuring the feed generation logic for clarity and maintainability. The `chapterId` path parameter for chapter metadata feeds has been changed to `chapterIndex` (sourceOrder) to align with how chapters are identified in manga feeds.

BREAKING CHANGE: The OPDS endpoint for chapter metadata has changed from `/api/opds/v1.2/manga/{mangaId}/chapter/{chapterId}/fetch` to `/api/opds/v1.2/manga/{mangaId}/chapter/{chapterIndex}/fetch`. Clients will need to update to use the chapter's source order (index) instead of its database ID.

Key changes:
- Introduced `MangaRepository`, `ChapterRepository`, and `NavigationRepository` to encapsulate database queries and data transformation logic for OPDS feeds.
- Moved data fetching logic from `OpdsFeedBuilder` to these new repositories.
- `OpdsFeedBuilder` now primarily focuses on constructing the XML feed structure using DTOs provided by the repositories.
- Renamed `OpdsMangaAcqEntry.thumbnailUrl` to `rawThumbnailUrl` for clarity.
- Added various DTOs (e.g., `OpdsRootNavEntry`, `OpdsMangaDetails`, `OpdsChapterListAcqEntry`) to define clear data contracts between repositories and the feed builder.
- Simplified `OpdsV1Controller` by reorganizing feed endpoints into logical groups (Main Navigation, Filtered Acquisition, Item-Specific).
- Updated `OpdsAPI` to reflect the path parameter change for chapter metadata (`chapterIndex` instead of `chapterId`).
- Added `slugify()` utility to `OpdsStringUtil` for creating URL-friendly genre IDs.
- Standardized localization keys for root feed entry descriptions to use `*.entryContent` instead of `*.description`.
- Added `server.generated.BuildConfig` (likely from build process).

* style(opds): apply ktlint fixes

* Delete server/bin

* refactor(i18n): remove custom LocalizationService initialization

* refactor(i18n): remove unused imports from ServerSetup

* refactor(model): remove sourceLang from MangaDataClass

* refactor(opds): rename OPDS binary file size config property

- Rename `useBinaryFileSizes` to `opdsUseBinaryFileSizes` in code and config
- Update related condition check in formatFileSizeForOpds

BREAKING CHANGE: Existing server configurations using `server.useBinaryFileSizes` need to migrate to `server.opdsUseBinaryFileSizes`

* refactor(opds): improve OPDS endpoint structure and documentation

- Restructure endpoint paths for better resource hierarchy
- Add descriptive comments for each feed type and purpose
- Rename `/fetch` endpoint to `/metadata` for clarity
- Standardize feed naming conventions in route definitions

BREAKING CHANGE: Existing OPDS client integrations using old endpoint paths (`/manga/{mangaId}` and `/chapter/{chapterIndex}/fetch`) require updates to new paths (`/manga/{mangaId}/chapters` and `/chapter/{chapterIndex}/metadata`)

* fix(opds): Apply review suggestions for localization and comments

* Fix

* fix(opds): Update chapter links to include 'chapters' and 'metadata' in URLs

---------

Co-authored-by: Syer10 <syer10@users.noreply.github.com>
2025-05-26 20:46:14 -04:00
2025-04-21 13:32:42 -04:00
2023-10-04 22:02:20 -04:00
2024-09-02 21:25:01 -04:00
2025-04-21 13:32:42 -04:00
2021-05-07 19:41:34 +04:30
2024-11-17 12:17:39 -05:00

Build Stable Preview Support Server
CI stable release preview Discord

Table of Content

What is Suwayomi?

drawing

A free and open source manga reader server that runs extensions built for Mihon (Tachiyomi).

Suwayomi is an independent Mihon (Tachiyomi) compatible software and is not a Fork of Mihon (Tachiyomi).

Suwayomi-Server is as multi-platform as you can get. Any platform that runs java and/or has a modern browser can run it. This includes Windows, Linux, macOS, chrome OS, etc. Follow Downloading and Running the app for installation instructions.

You can use Mihon (Tachiyomi) to access your Suwayomi-Server. For more info look here.

Features

Note

These are capabilities of Suwayomi-Server, the actual working support is provided by each front-end app, checkout their respective readme for more info.

  • Installing and executing Mihon (Tachiyomi)'s Extensions, So you'll get the same sources
  • Searching and browsing installed sources
  • A library to save your mangas and categories to put them into
  • Automated library updates to check for new chapters
  • Automated download of new chapters
  • Viewing latest updated chapters
  • Ability to download Manga for offline read
  • Backup and restore support powered by Mihon (Tachiyomi)-compatible Backups
  • Automated backup creations
  • Tracking via MyAnimeList, AniList, MangaUpdates, etc.
  • FlareSolverr support to bypass Cloudflare protection
  • Automated WebUI updates (supports the default WebUI and VUI)
  • OPDS and OPDS-PSE support (endpoint: /api/opds/v1.2)

Suwayomi client projects

You need a client/user interface app as a front-end for Suwayomi-Server, if you Directly Download Suwayomi-Server you'll get a bundled version of Suwayomi-WebUI with it.

Here's a list of known clients/user interfaces for Suwayomi-Server (checkout the respective GitHub repository for their features):

Actively Developed Clients
  • Suwayomi-WebUI: The web front-end that Suwayomi-Server ships with by default.
  • Suwayomi-VUI: A Suwayomi-Server preview focused web frontend built with svelte
  • Tachidesk-VaadinUI: A Web front-end for Suwayomi-Server built with Vaadin.
Inactive Clients (functional but outdated)
  • Tachidesk-JUI: The native desktop front-end for Suwayomi-Server.
  • Tachidesk-Sorayomi: A Flutter front-end for Desktop(Linux, windows, etc.), Web and Android with a User Interface inspired by Mihon (Tachiyomi).
Abandoned Clients (functionality unknown)
  • Tachidesk-qtui: A C++/Qt front-end for mobile devices(Android/linux), feature support is basic.
  • Tachidesk-GTK: A native Rust/GTK desktop client.
  • Equinox: A web user interface made with Vue.js.

Downloading and Running the app

Using Operating System Specific Bundles

To facilitate the use of Suwayomi we provide bundle releases that include The Java Runtime Environment, ElectronJS and the Suwayomi-Launcher.

If a bundle for your operating system or cpu architecture is not provided then refer to Advanced Methods

Windows

Download the latest win64(Windows 64-bit) release from the releases section or a preview one from the preview repository.

Unzip the downloaded file and double-click on one of the launcher scripts.

macOS

Download the latest macOS-x64(older macOS systems) or macOS-arm64(Apple M1 and newer) release from the releases section or a preview one from the preview repository.

Unzip the downloaded file and double-click on one of the launcher scripts.

GNU/Linux

Download the latest linux-x64(x86_64) release from the releases section or a preview one from the preview repository.

tar xvf the downloaded file and double-click on one of the launcher scripts or run them using the terminal.

Other methods of getting Suwayomi

Docker

Check our Official Docker release Suwayomi Container for running Suwayomi Server in a docker container. Source code for our container is available at docker-tachidesk, an example compose file can also be found there. By default, the server will be running on http://localhost:4567 open this url in your browser.

Arch Linux

You can install Suwayomi from the AUR:

yay -S tachidesk

Debian/Ubuntu

Download the latest deb package from the release section.

Caution

These options are outdated and unmaintained (relevant issue)

MPR

git clone https://mpr.makedeb.org/tachidesk-server.git
cd tachidesk-server
makedeb -si

Ubuntu

sudo add-apt-repository ppa:suwayomi/tachidesk-server
sudo apt update
sudo apt install tachidesk-server

NixOS

You can deploy Suwayomi on NixOS using the module services.suwayomi-server in your configuration:

{
  services.suwayomi-server = {
    enable = true;
  };
}

For more information, see the NixOS manual.

You can also directly use the package from nixpkgs.

Advanced Methods

Running the jar release directly

In order to run the app you need the following:

  • The jar release of Suwayomi-Server
  • The Java Runtime Environment(JRE) 21 or newer
  • A Browser like Google Chrome, Firefox, Edge, etc.
  • ElectronJS (optional)

Download the latest .jar release from the releases section or a preview jar build from the preview repository.

Make sure you have The Java Runtime Environment installed on your system, Double-click on the jar file or run java -jar Suwayomi-Server-vX.Y.Z-rxxxx.jar from a Terminal/Command Prompt window to run the app which will open a new browser window automatically.

Using Suwayomi Remotely

You can run Suwayomi on your computer or a server and connect to it remotely through one of our clients or the bundled web interface with a web browser. This method of using Suwayomi is requiring a bit of networking/firewall/port forwarding/server configuration/etc. knowledge on your side, if you can run a Minecraft server and configure it, then you are good to go.

Check out this wiki page for a guide on configuring Suwayomi-Server.

If you face issues with your setup then we are happy to provide help, just join our discord server(a discord badge is on the top of the page, you are just a click-clack away!).

Syncing With Mihon (Tachiyomi)

The Suwayomi extension and tracker

  • You can install the Suwayomi extension inside Mihon (Tachiyomi).
  • The extension will load your Suwayomi library.
  • By manipulating extension search filters you can browse your categories.
  • You can enable the Suwayomi tracker to track reading progress with your Suwayomi server.
    • Note: to sync from
      • Mihon (Tachiyomi) to Suwayomi: Mihon (Tachiyomi) automatically updates the chapters read status when it's updating the tracker (e.g. while reading)
      • Suwayomi to Mihon (Tachiyomi): To sync Mihon (Tachiyomi) with Suwayomi, you have to open the manga's track information, then, Mihon (Tachiyomi) will automatically update its chapter list with the state from Suwayomi

Other methods

Checkout this issue for tracking progress.

Troubleshooting and Support

See this troubleshooting wiki page.

Contributing and Technical info

See CONTRIBUTING.md.

Credit

This project is a spiritual successor of TachiWeb-Server, Many of the ideas and the groundwork adopted in this project comes from TachiWeb.

The AndroidCompat module was originally developed by @null-dev for TachiWeb-Server and is licensed under Apache License Version 2.0 and Copyright 2019 Andy Bao and contributors.

Parts of Mihon (Tachiyomi) is adopted into this codebase, also licensed under Apache License Version 2.0 and Copyright 2015 Javier Tomás.

You can obtain a copy of Apache License Version 2.0 from http://www.apache.org/licenses/LICENSE-2.0

Changes to both codebases is licensed under MPL v. 2.0 as the rest of this project.

License

Copyright (C) Contributors to the Suwayomi project

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.

Disclaimer

The developer of this application does not have any affiliation with the content providers available.

Languages
Java 61.5%
Kotlin 38%
Shell 0.3%
HTML 0.1%