Skip to content

Import from Tolgee through its API, background tasks with progress - #2

Merged
FabioHAraujo merged 1 commit into
mainfrom
feat/tolgee-import
Oct 23, 2026
Merged

FabioHAraujo merged 1 commit into
mainfrom
feat/tolgee-import

Conversation

@FabioHAraujo

Copy link
Copy Markdown
Contributor

Import big Tolgee projects (the target is ~160k keys in 5 languages) straight through Tolgee's API, as a background task with progress.

What changes

  • Background tasks: a job queue in SQLite with two workers. Each batch saves progress and the resume point in the same transaction. Jobs left running at shutdown resume on the next start; failed or cancelled ones can be retried from where they stopped. Endpoints: GET /api/jobs, GET /api/jobs/{id}, POST /api/jobs/{id}/cancel, POST /api/jobs/{id}/retry.
  • Tolgee import (admin): POST /api/tolgee/inspect and POST /api/tolgee/import. Works with a project API key (tgpak_) or a personal token (tgpat_) plus project id; the app URL can be pasted as is. Brings languages, namespaces, descriptions, tags, translated and reviewed texts; 500 keys per page with cursor paging and retries. Into a new project or an existing one (overwrite optional). The key is kept only inside the encrypted job parameters.
  • Machine translation of a whole language is now a job too (no more long HTTP request).
  • UI: Projects → Importar do Tolgee (connect, preview, target), a new Tarefas page (progress, time left, stop, retry), a progress strip on the project page, live progress in the batch translation dialog. Strings in en and pt-BR.
  • Exports stream: texts are read one language at a time and ZIP/CSV are written straight to the response, so a large project stays far under the 256 MB container limit.
  • DB migration 2 (jobs table); verified upgrading the existing dev database.

Verified

  • Unit tests, including a fake Tolgee that fails mid-import: the retry resumes from page 2 without refetching page 1 or duplicating keys.
  • Against a real Tolgee (tolgee/tolgee:latest in Docker, seeded through its own API): 3,000 keys, 5 languages, namespaces, tags, a description and 50 reviewed texts all came across. This caught one real difference, now handled: with a cursor, Tolgee's totalElements counts only the keys left.
  • Load test (LOWLEX_LOAD=160000 go test ./internal/server -run Load): 160,000 keys in ~8 s, key list under 20 ms during the import, nested-JSON and CSV exports of the full project in under 1 s with ~50 MB heap.
  • Deployed to the dev server.

- Background job queue in SQLite with two workers. Each batch saves progress
  and its resume point in the same transaction; jobs left running at shutdown
  resume on the next start, failed or cancelled ones can be retried.
- Tolgee import: project API key or personal token, languages, namespaces,
  descriptions, tags, translated and reviewed texts, 500 keys per page with
  cursor paging and retries. Verified against a real Tolgee server.
- Machine translation of whole languages now runs as a job.
- Tasks page, progress strip on the project page, progress in the batch dialog.
- Exports stream per language (ZIP and CSV written to the response), so large
  projects stay well under the container memory limit.
- Load test: 160,000 keys import in about 8 s.
@FabioHAraujo
FabioHAraujo merged commit 569d532 into main Oct 23, 2026
6 checks passed
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.

1 participant