Skip to content

feat: store a book's language - #36

Merged
itsthisjustin merged 1 commit into
crosspoint-reader:mainfrom
eszter007:feat/document-language
Oct 24, 2026
Merged

itsthisjustin merged 1 commit into
crosspoint-reader:mainfrom
eszter007:feat/document-language

Conversation

@eszter007

Copy link
Copy Markdown
Contributor

The server doesn't know what language a book is in. That matters to me because I read in German, English and Japanese, and I'd like the app and stats to tell them apart. This adds a language field to each book.

Where the language comes from

  • The reader. Progress metadata can now carry "language": "ja", the EPUB's dc:language, next to title and authors. It only fills a blank. A value that isn't a BCP 47 tag is ignored, and the sync still succeeds.
  • By hand. PUT /api/v1/documents/{document}/info takes language. A language set this way stays over later device syncs, and null clears it so the next device sync fills it again.

It's returned in GET /api/v1/documents and GET /api/v1/progress, and a merge fills a blank language from the merged-away book. One new column, documents.language (migration 0034, so it doesn't collide with 0033 in #35). The API docs are updated. No new endpoint: it's a new field on the existing metadata and /info calls.

Why not take it from Hardcover, like genres

Hardcover's search returns books, i.e. the abstract work. Language belongs to an edition: the English original, the German translation and the Japanese paperback are separate editions of one book, each with its own language. The search results carry no language at all, so it would take a second query for the editions, plus a guess at which edition this copy is. That guess is wrong exactly where language matters most: books read in translation. The reader has the actual file in hand, and its EPUB states the language, so the reader is the better source.

Testing

test/document-language.test.ts covers a malformed tag from a device being dropped, the language showing in both book lists, a manual value staying over a later device sync, clearing it back, and a merge filling a blank. Without the change in merge.ts, the merge step fails the test. The full suite passes (675 tests), and so does tsc --noEmit.

The X4 firmware doesn't send language yet. That would be a small follow-up on the CrossPoint side.

Devices send the EPUB's dc:language in progress metadata; PUT /documents/:document/info sets it by hand.
@coderabbitai

coderabbitai Bot commented Oct 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 40 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 72341cfc-eb44-459b-82b2-f21337e77243
Commits

Reviewing files that changed from the base of the PR and between a1447e4 and 8a94092.

Files selected for processing: 7
  • docs/API.md
  • migrations/0034_document_language.sql
  • src/models/merge.ts
  • src/routes/kosync.ts
  • src/routes/v1/documents.ts
  • src/routes/v1/progress.ts
  • test/document-language.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@itsthisjustin
itsthisjustin self-requested a review October 24, 2026 13:30
@eszter007 eszter007 changed the title Store a book's language feat: store a book's language Oct 24, 2026
eszter007 added a commit to eszter007/matcha-reader that referenced this pull request Oct 24, 2026
crosspoint-sync can store a book's language (crosspoint-reader/crosspoint-sync#36). Send
the EPUB's dc:language as "language" in the progress metadata, next to
ISBN and series, when the server is a custom (extended metadata) one.
The value comes from the book cache, so it costs no extra read.
eszter007 added a commit to eszter007/matcha-reader that referenced this pull request Oct 24, 2026
crosspoint-sync can store a book's language
(crosspoint-reader/crosspoint-sync#36). Send the EPUB's dc:language as
"language" in the progress metadata to CrossPoint and custom servers;
plain KOSync has no such field. The value comes from the book cache, so
it costs no extra read.
@itsthisjustin
itsthisjustin merged commit a30c59d into crosspoint-reader:main Oct 24, 2026
1 check passed
@eszter007
eszter007 deleted the feat/document-language branch October 24, 2026 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants