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:
@@ -6,28 +6,23 @@
|
||||
{% block heading %}Web search{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
<p class="admin-lede">
|
||||
Lets a model look things up while it answers. It is offered as a tool the
|
||||
model chooses to call, so nothing changes for a question that does not need
|
||||
it — and it is only offered to models marked as supporting tools, because
|
||||
sending a tool list to one that does not fails the whole request.
|
||||
</p>
|
||||
<p class="admin-lede">{{ t("Lets a model look things up while it answers. It is offered as a tool the model chooses to call, so nothing changes for a question that does not need it — and it is only offered to models marked as supporting tools, because sending a tool list to one that does not fails the whole request.") }}</p>
|
||||
|
||||
{% if saved %}
|
||||
<div class="alert alert--success">{{ icon("check", "icon--sm") }} <span>Search settings saved.</span></div>
|
||||
<div class="alert alert--success">{{ icon("check", "icon--sm") }} <span>{{ t("Search settings saved.") }}</span></div>
|
||||
{% endif %}
|
||||
|
||||
<form method="post" action="/admin/search">
|
||||
<section class="card">
|
||||
<h2 class="card__title">
|
||||
Web search
|
||||
{% if values.enabled %}<span class="badge badge--success">on</span>
|
||||
{% else %}<span class="badge">off</span>{% endif %}
|
||||
{% if values.enabled %}<span class="badge badge--success">{{ t("on") }}</span>
|
||||
{% else %}<span class="badge">{{ t("off") }}</span>{% endif %}
|
||||
</h2>
|
||||
<div class="field">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" name="enabled" value="true" {{ 'checked' if values.enabled }}>
|
||||
<span>Offer web search to models that support tools</span>
|
||||
<span>{{ t("Offer web search to models that support tools") }}</span>
|
||||
</label>
|
||||
<p class="field__hint">
|
||||
Who may use it is a permission — <code>tools.web_search</code> under
|
||||
@@ -37,7 +32,7 @@
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<h2 class="card__title">Provider</h2>
|
||||
<h2 class="card__title">{{ t("Provider") }}</h2>
|
||||
<div class="field">
|
||||
{% for provider in providers %}
|
||||
<label class="checkbox" style="align-items: flex-start">
|
||||
@@ -45,7 +40,7 @@
|
||||
{{ 'checked' if values.provider == provider.key }}>
|
||||
<span>
|
||||
<strong>{{ provider.label }}</strong>
|
||||
{% if not provider.needs_setup %}<span class="badge">no setup</span>{% endif %}
|
||||
{% if not provider.needs_setup %}<span class="badge">{{ t("no setup") }}</span>{% endif %}
|
||||
<div class="text-xs faint">{{ provider.description }}</div>
|
||||
{% if problems[provider.key] %}
|
||||
<div class="text-xs" style="color: var(--danger)">{{ problems[provider.key] }}</div>
|
||||
@@ -57,13 +52,13 @@
|
||||
|
||||
<div class="grid grid--3">
|
||||
<div class="field">
|
||||
<label class="field__label" for="max-results">Results per search</label>
|
||||
<label class="field__label" for="max-results">{{ t("Results per search") }}</label>
|
||||
<input class="input" id="max-results" name="max_results" type="number"
|
||||
min="1" max="20" value="{{ values.max_results }}">
|
||||
<p class="field__hint">A ceiling — a model asking for more gets this.</p>
|
||||
<p class="field__hint">{{ t("A ceiling — a model asking for more gets this.") }}</p>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field__label" for="safesearch">Safe search</label>
|
||||
<label class="field__label" for="safesearch">{{ t("Safe search") }}</label>
|
||||
<select class="select" id="safesearch" name="safesearch">
|
||||
{% for option in safesearch_options %}
|
||||
<option value="{{ option }}" {{ 'selected' if option == values.safesearch }}>
|
||||
@@ -73,16 +68,16 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field__label" for="timeout">Timeout (seconds)</label>
|
||||
<label class="field__label" for="timeout">{{ t("Timeout (seconds)") }}</label>
|
||||
<input class="input" id="timeout" name="timeout" type="number"
|
||||
min="5" max="120" step="1" value="{{ values.timeout }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="field__label" for="region">DuckDuckGo region</label>
|
||||
<label class="field__label" for="region">{{ t("DuckDuckGo region") }}</label>
|
||||
<input class="input" id="region" name="region" maxlength="16"
|
||||
value="{{ values.region }}" placeholder="wt-wt">
|
||||
value="{{ values.region }}" placeholder="{{ t('wt-wt') }}">
|
||||
<p class="field__hint">
|
||||
<code>wt-wt</code> is no region at all. <code>uk-en</code>,
|
||||
<code>de-de</code> and so on bias results to a country.
|
||||
@@ -91,15 +86,12 @@
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<h2 class="card__title">SearXNG</h2>
|
||||
<p class="card__lede">
|
||||
Only used when SearXNG is the chosen provider. Your own instance, so no
|
||||
third party sees the queries.
|
||||
</p>
|
||||
<h2 class="card__title">{{ t("SearXNG") }}</h2>
|
||||
<p class="card__lede">{{ t("Only used when SearXNG is the chosen provider. Your own instance, so no third party sees the queries.") }}</p>
|
||||
<div class="field">
|
||||
<label class="field__label" for="searxng-base-url">Instance URL</label>
|
||||
<label class="field__label" for="searxng-base-url">{{ t("Instance URL") }}</label>
|
||||
<input class="input" id="searxng-base-url" name="searxng_base_url" type="url"
|
||||
value="{{ values.searxng_base_url }}" placeholder="http://127.0.0.1:8888">
|
||||
value="{{ values.searxng_base_url }}" placeholder="{{ t('http://127.0.0.1:8888') }}">
|
||||
<p class="field__hint">
|
||||
A stock SearXNG refuses JSON. Add <code>- json</code> under
|
||||
<code>search.formats</code> in its <code>settings.yml</code> and restart
|
||||
@@ -109,16 +101,16 @@
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<h2 class="card__title">Saving links</h2>
|
||||
<h2 class="card__title">{{ t("Saving links") }}</h2>
|
||||
<p class="card__lede">
|
||||
Applies to the composer's <strong>Link</strong> option and to anything the
|
||||
Applies to the composer's <strong>{{ t("Link") }}</strong> option and to anything the
|
||||
model fetches: {{ brand.name }} retrieves the page and keeps its text.
|
||||
</p>
|
||||
<div class="field">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" name="fetch_enabled" value="true"
|
||||
{{ 'checked' if values.fetch_enabled }}>
|
||||
<span>Let a model fetch a page itself</span>
|
||||
<span>{{ t("Let a model fetch a page itself") }}</span>
|
||||
</label>
|
||||
<p class="field__hint">
|
||||
Offers the <code>fetch</code> tool, so a model can read an address it
|
||||
@@ -132,7 +124,7 @@
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" name="allow_private_fetch" value="true"
|
||||
{{ 'checked' if values.allow_private_fetch }}>
|
||||
<span>Allow fetching addresses on this machine and this network</span>
|
||||
<span>{{ t("Allow fetching addresses on this machine and this network") }}</span>
|
||||
</label>
|
||||
<p class="field__hint">
|
||||
Off by default, and worth leaving off. This server can reach your
|
||||
@@ -145,36 +137,36 @@
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<h2 class="card__title">Firecrawl</h2>
|
||||
<h2 class="card__title">{{ t("Firecrawl") }}</h2>
|
||||
<div class="grid grid--2">
|
||||
<div class="field">
|
||||
<label class="field__label" for="firecrawl-base-url">API URL</label>
|
||||
<label class="field__label" for="firecrawl-base-url">{{ t("API URL") }}</label>
|
||||
<input class="input" id="firecrawl-base-url" name="firecrawl_base_url" type="url"
|
||||
value="{{ values.firecrawl_base_url }}"
|
||||
placeholder="https://api.firecrawl.dev">
|
||||
<p class="field__hint">Change only for a self-hosted Firecrawl.</p>
|
||||
placeholder="{{ t('https://api.firecrawl.dev') }}">
|
||||
<p class="field__hint">{{ t("Change only for a self-hosted Firecrawl.") }}</p>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field__label" for="firecrawl-api-key">API key</label>
|
||||
<label class="field__label" for="firecrawl-api-key">{{ t("API key") }}</label>
|
||||
<input class="input" id="firecrawl-api-key" name="firecrawl_api_key" type="password"
|
||||
value="{{ unchanged if masked else '' }}"
|
||||
placeholder="{{ masked or 'fc-...' }}" autocomplete="off">
|
||||
<p class="field__hint">Encrypted at rest. Clear the field to remove it.</p>
|
||||
<p class="field__hint">{{ t("Encrypted at rest. Clear the field to remove it.") }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="form-actions"><button class="btn btn--primary" type="submit">Save settings</button></div>
|
||||
<div class="form-actions"><button class="btn btn--primary" type="submit">{{ t("Save settings") }}</button></div>
|
||||
</form>
|
||||
|
||||
<section class="card">
|
||||
<h2 class="card__title">Try it</h2>
|
||||
<h2 class="card__title">{{ t("Try it") }}</h2>
|
||||
<p class="card__lede">
|
||||
Runs a real search against the <em>saved</em> settings, which is what a chat
|
||||
Runs a real search against the <em>{{ t("saved") }}</em> settings, which is what a chat
|
||||
would do. Save first if you have just changed something.
|
||||
</p>
|
||||
<div class="row" style="gap: var(--sp-2)">
|
||||
<input class="input" id="test-query" name="query" placeholder="mallorn tree"
|
||||
<input class="input" id="test-query" name="query" placeholder="{{ t('mallorn tree') }}"
|
||||
style="flex: 1">
|
||||
<button class="btn" type="button" hx-post="/admin/search/test"
|
||||
hx-include="#test-query" hx-target="#search-test" hx-swap="outerHTML">
|
||||
|
||||
Reference in New Issue
Block a user