Skip to content

feat: translate without an instance, and keep project settings in the config file - #109

Merged
explodi merged 2 commits into
mainfrom
feat/cli-local-translate
Nov 19, 2026
Merged

explodi merged 2 commits into
mainfrom
feat/cli-local-translate

Conversation

@explodi

@explodi explodi commented Nov 19, 2026

Copy link
Copy Markdown
Owner

What this adds

A second way to use Quaso, for small projects that need no proofreading and no server: the CLI and an LLM API key.

export GEMINI_API_KEY='your key'   # or ANTHROPIC_API_KEY
npx quaso translate

With no QUASO_HOSTNAME and no hostname in the config (or with --local), quaso translate translates by itself and writes the translation files.

The CLI runs the instance's own code

The CLI does not get a second translation pipeline. It starts @quaso/service on an in-memory node:sqlite database for the length of one command and takes it through an instance's steps: upload the sources with settings and context files, import the translations already in the repository, run a job, export. Prompts, quality checks, retries and batching are therefore the same code in both places (packages/cli/src/local.ts).

  • node:sqlite is loaded only when translating locally, so other commands are unaffected. For that, the SQLite adapter is split: node_sqlite.ts opens a database, node_sqlite_database.ts wraps one and imports only types.
  • The CLI bundle now includes the service: it grows to about 1 MB.
  • Local translation needs Node 22.13 or later; the rest of the CLI still runs on Node 22.

quaso.lock.json

The repository is the only store, so the CLI needs to know which translations are current. The lock records, for each translation, a hash of the source text it was made for. A later run then translates only new and changed strings, keeps translations written by hand, and tells a real translation that equals the source text ("OK") from source text written in place of a missing one. It is meant to be committed.

Settings in quaso.config.json

A new settings field holds the project's name, description, syntax, the LLM settings, and each language's instructions and plural override. It uses the same names as the settings API. The settings schemas moved from core/src/api.ts to core/src/settings.ts so the config schema can share them.

  • Local translation reads them.
  • A full quaso upload stores each setting the config gives over the instance's value, and reports what changed (UploadResult.settings). Settings the config leaves out stay as they are.
  • In a terminal, quaso upload first does a dry run, lists the settings it would replace and the contexts that were edited on the website, and asks. It never asks in CI, through a pipe, with --json, --dry-run or --yes.

Decisions to review

  • Context files keep their rule. The request was for uploads to overwrite the instance's context with the repository's. I kept the rule from the context-files change (a changed file wins; an unchanged file does not undo a website edit), because CI uploads on every push. Settings have no "last uploaded" record, so there the config always wins. Say if contexts should always win too.
  • An upload-scope key can now change settings, including the model and the prompt, as it already can change contexts. The docs say so.
  • Context files are named <file>.quaso, as they already were, not <file>.context.quaso.
  • Local mode is chosen by the absence of an instance. A project whose config names a hostname needs --local.
  • The CLI now asks a question, which it never did. Only at a terminal, and only before replacing something.

Limits of local translation

  • Only translate works without an instance.
  • No glossary, and every translation is green, so the LLM sees no proofread neighbours or identical strings as context.
  • A changed string is translated from scratch; the previous translation is not shown to the LLM as it is on an instance.
  • Generated file context is not kept between runs, so a file without a context file costs a few tokens on each run that translates it.
  • The website has no marker yet for settings that the config file manages.

Testing

npm run check passes (2455 tests). New tests cover local translation end to end with the fake translator (first run, second run, changed source, hand-written translations, settings and context reaching the prompt, --dry-run, --file, --local, a refused key), the upload of settings in the service, and the CLI's question before overwriting.

Not tested: a run against the real Gemini or Anthropic API, and npm run e2e, cf:check and the site build.

…holds the project's settings

Without QUASO_HOSTNAME or a hostname in the config (or with --local), quaso translate
runs the service an instance runs, on a database in memory, with the key in
GEMINI_API_KEY or ANTHROPIC_API_KEY. It reads the config's settings and the context
files, and writes the translation files. quaso.lock.json records the source text each
translation was made for, so a later run translates only new and changed strings.

quaso.config.json gains settings: the project's name, description, syntax, LLM
settings, and each language's instructions and plural override. A full upload stores
each one given over the instance's value. In a terminal, quaso upload first asks
before it replaces settings, or contexts edited on the website; --yes skips it.
@explodi
explodi merged commit 5545c7c into main Nov 19, 2026
27 of 28 checks passed
@explodi
explodi deleted the feat/cli-local-translate branch November 19, 2026 07:30
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