Repository navigation
feat: translate without an instance, and keep project settings in the config file - #109
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
With no
QUASO_HOSTNAMEand nohostnamein the config (or with--local),quaso translatetranslates 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/serviceon an in-memorynode:sqlitedatabase 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:sqliteis loaded only when translating locally, so other commands are unaffected. For that, the SQLite adapter is split:node_sqlite.tsopens a database,node_sqlite_database.tswraps one and imports only types.quaso.lock.jsonThe 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.jsonA new
settingsfield 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 fromcore/src/api.tstocore/src/settings.tsso the config schema can share them.quaso uploadstores 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.quaso uploadfirst 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-runor--yes.Decisions to review
upload-scope key can now change settings, including the model and the prompt, as it already can change contexts. The docs say so.<file>.quaso, as they already were, not<file>.context.quaso.hostnameneeds--local.Limits of local translation
translateworks without an instance.Testing
npm run checkpasses (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:checkand the site build.