The interface speaks Slovak
969 strings, an instance default and a per-person choice, and no half-done corner: the admin prose is translated too. Design and reasoning: LLeMbas.wiki/Translations. KEYED BY THE ENGLISH SENTENCE A missing entry renders the key, which is the English -- so an untranslated string looks as it always did, an English instance is byte-for-byte 1.6.0, and a half-finished catalogue is a half-translated page rather than a page of dotted key names. The cost is that editing an English sentence orphans its translation silently, which is what tests/test_translations.py asserts in both directions. No gettext: .po -> .mo is a build step and this project does not have one. A JINJA GLOBAL, AND THEREFORE A CONTEXTVAR `t()` is a global for the reason `brand` already documents -- render() is bypassed by 25 TemplateResponse calls and 8 get_template().render() calls, the latter being the SSE frames, which have no Request at all. A global is bound once at import and the language is per person, so the active language is a ContextVar set per request. 🚨 `get_current_user` had to become `async def`. FastAPI runs a sync dependency in a threadpool, and anyio copies the context in and discards it on the way out -- so the language was set where nothing could see it and every page rendered in the instance's language whatever anybody had chosen, with no error anywhere. NOT TRANSLATED, ON PURPOSE Everything a model reads: the 60 prompt fragments, and the dates in harness.py, schedule/runner.py and schedule/compile.py. Only `i18n.stamp` is localised, and only where a person reads it -- with the *format* translatable as well as the words, because "26. septembra 2026" is a different pattern rather than the same one with different words in it. A process locale is not an option: global, not thread-safe, two people's pages at once. A second fragment telling models to answer in the reader's language was written during this work and removed: `core.style` has said it since long before, and test_an_empty_override_turns_a_fragment_off caught the duplicate. THE BULK PASS 1213 sites wrapped by a one-off script that only touched patterns it could not misread. It got three wrong in a way that mattered -- `t('…')` inside `attr="…"` where the sentence held an apostrophe, closing the Jinja string and 500ing two pages whose partials no test renders. tests/test_translations.py now compiles all 110 templates. It also wrapped the product's own name, an SSH key header, a keystroke hint and an example URL, all taken back out: a string is not translatable just because it is a string. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,11 +11,11 @@
|
||||
use each tool, what it has been asked to remember. These sit above whichever
|
||||
system prompt was authored for the instance, the model or the chat — that
|
||||
prompt still wins where the two disagree. Clear a box to leave that piece out
|
||||
altogether; press <strong>Use default</strong> to put the built-in wording back.
|
||||
altogether; press <strong>{{ t("Use default") }}</strong> to put the built-in wording back.
|
||||
</p>
|
||||
|
||||
{% if saved %}
|
||||
<div class="alert alert--success">{{ icon("check", "icon--sm") }} <span>Prompts saved.</span></div>
|
||||
<div class="alert alert--success">{{ icon("check", "icon--sm") }} <span>{{ t("Prompts saved.") }}</span></div>
|
||||
{% endif %}
|
||||
|
||||
{#
|
||||
@@ -39,7 +39,7 @@
|
||||
#}
|
||||
<form method="post" action="/admin/prompts" id="prompt-form">
|
||||
<div class="tabs">
|
||||
<div class="tabs__bar" role="radiogroup" aria-label="Prompt groups">
|
||||
<div class="tabs__bar" role="radiogroup" aria-label="{{ t('Prompt groups') }}">
|
||||
{% for key, label, fragments in groups %}
|
||||
<input class="visually-hidden" type="radio" name="prompts-tab"
|
||||
id="tab-{{ key }}" {{ 'checked' if loop.first }}>
|
||||
@@ -61,9 +61,9 @@
|
||||
</div>
|
||||
|
||||
<section class="card">
|
||||
<h2 class="card__title">Length</h2>
|
||||
<h2 class="card__title">{{ t("Length") }}</h2>
|
||||
<div class="field">
|
||||
<label class="field__label" for="max-harness-chars">Preamble character cap</label>
|
||||
<label class="field__label" for="max-harness-chars">{{ t("Preamble character cap") }}</label>
|
||||
<input class="input" id="max-harness-chars" name="max_harness_chars" type="number"
|
||||
min="0" max="100000" value="{{ max_harness_chars }}">
|
||||
<p class="field__hint">
|
||||
@@ -75,22 +75,20 @@
|
||||
</section>
|
||||
|
||||
<div class="form-actions">
|
||||
<button class="btn btn--primary" type="submit">Save settings</button>
|
||||
<button class="btn btn--primary" type="submit">{{ t("Save settings") }}</button>
|
||||
{#
|
||||
data-confirm-button, not data-confirm: this button acts on its own through
|
||||
formaction, and confirming the whole form would also catch plain Save.
|
||||
#}
|
||||
<button class="btn" type="submit" formaction="/admin/prompts/reset"
|
||||
data-confirm-button="Put every prompt back to its built-in wording? Everything you have edited here is lost."
|
||||
data-confirm-title="Restore defaults" data-confirm-label="Restore">
|
||||
Restore all defaults
|
||||
</button>
|
||||
data-confirm-button="{{ t('Put every prompt back to its built-in wording? Everything you have edited here is lost.') }}"
|
||||
data-confirm-title="{{ t('Restore defaults') }}" data-confirm-label="{{ t('Restore') }}">{{ t("Restore all defaults") }}</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
<section class="card">
|
||||
<h2 class="card__title">Variables</h2>
|
||||
<h2 class="card__title">{{ t("Variables") }}</h2>
|
||||
<p class="card__lede">
|
||||
Write these in double braces. Anything in double braces that is not on this
|
||||
list is left exactly as you typed it — variable names are lowercase letters,
|
||||
@@ -105,11 +103,11 @@
|
||||
<span>{{ variable.description }}</span>
|
||||
<span class="ref-row__value">
|
||||
{% if variable.name not in resolved %}
|
||||
<em>only in the title request</em>
|
||||
<em>{{ t("only in the title request") }}</em>
|
||||
{% elif resolved[variable.name] %}
|
||||
{{ resolved[variable.name] | truncate(80) }}
|
||||
{% else %}
|
||||
<em>empty</em>
|
||||
<em>{{ t("empty") }}</em>
|
||||
{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
@@ -124,32 +122,27 @@
|
||||
replaced -- an outerHTML swap would re-fire it and loop forever.
|
||||
#}
|
||||
<section class="card">
|
||||
<h2 class="card__title">Preview</h2>
|
||||
<p class="card__lede">
|
||||
The whole system message, assembled from what is in the boxes below —
|
||||
including changes you have not saved yet. Your own memories and skills are
|
||||
used, because a preview against invented ones cannot tell you whether it
|
||||
reads well against what is actually there.
|
||||
</p>
|
||||
<h2 class="card__title">{{ t("Preview") }}</h2>
|
||||
<p class="card__lede">{{ t("The whole system message, assembled from what is in the boxes below — including changes you have not saved yet. Your own memories and skills are used, because a preview against invented ones cannot tell you whether it reads well against what is actually there.") }}</p>
|
||||
|
||||
<div class="grid grid--2" id="preview-controls">
|
||||
<div class="field">
|
||||
<label class="field__label" for="preview-model">Answering model</label>
|
||||
<label class="field__label" for="preview-model">{{ t("Answering model") }}</label>
|
||||
<select class="select" id="preview-model" name="preview_model">
|
||||
{% for model in models %}
|
||||
<option value="{{ model.label }}">{{ model.label }}</option>
|
||||
{% else %}
|
||||
<option value="">No models configured</option>
|
||||
<option value="">{{ t("No models configured") }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field__label" for="preview-bases">Knowledge bases in scope</label>
|
||||
<label class="field__label" for="preview-bases">{{ t("Knowledge bases in scope") }}</label>
|
||||
<input class="input" id="preview-bases" name="preview_bases" value="Contracts, Recipes">
|
||||
<p class="field__hint">Empty means a chat that can see everything.</p>
|
||||
<p class="field__hint">{{ t("Empty means a chat that can see everything.") }}</p>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field__label" for="preview-documents">Attached files</label>
|
||||
<label class="field__label" for="preview-documents">{{ t("Attached files") }}</label>
|
||||
<input class="input" id="preview-documents" name="preview_documents"
|
||||
value="{{ sample_documents }}">
|
||||
</div>
|
||||
@@ -161,7 +154,7 @@
|
||||
filled when there is one.
|
||||
#}
|
||||
<div class="field">
|
||||
<label class="field__label" for="preview-situation">This chat is</label>
|
||||
<label class="field__label" for="preview-situation">{{ t("This chat is") }}</label>
|
||||
<select class="select" id="preview-situation" name="preview_situation">
|
||||
{% for value, label in situations %}
|
||||
<option value="{{ value }}">{{ label }}</option>
|
||||
@@ -169,7 +162,7 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field__label" for="preview-mode">Agent mode</label>
|
||||
<label class="field__label" for="preview-mode">{{ t("Agent mode") }}</label>
|
||||
<select class="select" id="preview-mode" name="preview_mode">
|
||||
{% for value, label in modes.items() %}
|
||||
<option value="{{ value }}"{{ ' selected' if value == 'edit' }}>{{ label }}</option>
|
||||
@@ -181,7 +174,7 @@
|
||||
</p>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="field__label">Tools offered</span>
|
||||
<span class="field__label">{{ t("Tools offered") }}</span>
|
||||
{% for family in families %}
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" name="preview_family" value="{{ family }}" checked>
|
||||
@@ -206,14 +199,8 @@
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<h2 class="card__title">Tool descriptions</h2>
|
||||
<p class="card__lede">
|
||||
Defined in code — part of the schema sent to the endpoint alongside the
|
||||
prompt, not guidance layered on top of it. They are statements of fact about
|
||||
what each tool does, so they change when the tool does; editing them here
|
||||
would let the text quietly become a lie. A custom tool's description will be
|
||||
editable, because a custom tool is a row rather than a function.
|
||||
</p>
|
||||
<h2 class="card__title">{{ t("Tool descriptions") }}</h2>
|
||||
<p class="card__lede">{{ t("Defined in code — part of the schema sent to the endpoint alongside the prompt, not guidance layered on top of it. They are statements of fact about what each tool does, so they change when the tool does; editing them here would let the text quietly become a lie. A custom tool's description will be editable, because a custom tool is a row rather than a function.") }}</p>
|
||||
<div class="ref-list">
|
||||
{% for tool in registry %}
|
||||
<div class="ref-row">
|
||||
|
||||
Reference in New Issue
Block a user