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:
@@ -8,8 +8,8 @@
|
||||
{% block admin_content %}
|
||||
<p class="admin-lede">
|
||||
Every model discovered across your connections. The order here is the order
|
||||
users see in the picker. <strong>Pinning</strong> does not reorder anything —
|
||||
it puts a shortcut in the chat sidebar. The <strong>default</strong> is what a
|
||||
users see in the picker. <strong>{{ t("Pinning") }}</strong> does not reorder anything —
|
||||
it puts a shortcut in the chat sidebar. The <strong>{{ t("default") }}</strong> is what a
|
||||
new chat starts with.
|
||||
</p>
|
||||
|
||||
@@ -41,9 +41,9 @@
|
||||
<form class="filter-form" method="get" action="/admin/models">
|
||||
<input type="hidden" name="filter" value="{{ active_filter }}">
|
||||
<input class="input" type="search" name="q" value="{{ q }}"
|
||||
placeholder="Search models…" aria-label="Search models">
|
||||
<select class="select" name="connection" aria-label="Connection">
|
||||
<option value="">All connections</option>
|
||||
placeholder="{{ t('Search models…') }}" aria-label="{{ t('Search models') }}">
|
||||
<select class="select" name="connection" aria-label="{{ t('Connection') }}">
|
||||
<option value="">{{ t("All connections") }}</option>
|
||||
{% for conn in connections %}
|
||||
<option value="{{ conn.id }}" {{ 'selected' if conn.id == connection_id }}>
|
||||
{{ conn.name }}
|
||||
@@ -59,7 +59,7 @@
|
||||
|
||||
{% if not models %}
|
||||
<div class="empty" style="padding: var(--sp-8) 0">
|
||||
<p class="empty__text">Nothing matches that filter.</p>
|
||||
<p class="empty__text">{{ t("Nothing matches that filter.") }}</p>
|
||||
</div>
|
||||
{% else %}
|
||||
|
||||
@@ -67,15 +67,15 @@
|
||||
<div class="bulk-bar">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-select-all="#model-rows"
|
||||
aria-label="Select every model on this page">
|
||||
<span class="bulk-bar__label">Select all</span>
|
||||
aria-label="{{ t('Select every model on this page') }}">
|
||||
<span class="bulk-bar__label">{{ t("Select all") }}</span>
|
||||
</label>
|
||||
<span class="spacer"></span>
|
||||
<span class="bulk-bar__label">With selected:</span>
|
||||
<button class="btn btn--sm" name="action" value="enable" type="submit">Enable</button>
|
||||
<button class="btn btn--sm" name="action" value="disable" type="submit">Disable</button>
|
||||
<button class="btn btn--sm" name="action" value="public" type="submit">Make public</button>
|
||||
<button class="btn btn--sm" name="action" value="private" type="submit">Restrict</button>
|
||||
<span class="bulk-bar__label">{{ t("With selected:") }}</span>
|
||||
<button class="btn btn--sm" name="action" value="enable" type="submit">{{ t("Enable") }}</button>
|
||||
<button class="btn btn--sm" name="action" value="disable" type="submit">{{ t("Disable") }}</button>
|
||||
<button class="btn btn--sm" name="action" value="public" type="submit">{{ t("Make public") }}</button>
|
||||
<button class="btn btn--sm" name="action" value="private" type="submit">{{ t("Restrict") }}</button>
|
||||
</div>
|
||||
|
||||
<div class="model-rows" id="model-rows">
|
||||
@@ -92,11 +92,11 @@
|
||||
<div class="model-row__title">
|
||||
<a class="model-row__name" href="/admin/models/{{ model.id }}/edit">{{ model.label }}</a>
|
||||
{% if model.model_id == default_model %}
|
||||
<span class="badge badge--leaf">default</span>
|
||||
<span class="badge badge--leaf">{{ t("default") }}</span>
|
||||
{% endif %}
|
||||
{% if model.pinned %}<span class="badge">pinned</span>{% endif %}
|
||||
{% if not model.enabled %}<span class="badge badge--danger">disabled</span>{% endif %}
|
||||
{% if not model.public %}<span class="badge">restricted</span>{% endif %}
|
||||
{% if model.pinned %}<span class="badge">{{ t("pinned") }}</span>{% endif %}
|
||||
{% if not model.enabled %}<span class="badge badge--danger">{{ t("disabled") }}</span>{% endif %}
|
||||
{% if not model.public %}<span class="badge">{{ t("restricted") }}</span>{% endif %}
|
||||
{% for name, on in (model.capabilities_json or {}).items() %}
|
||||
{% if on %}<span class="badge badge--leaf">{{ name }}</span>{% endif %}
|
||||
{% endfor %}
|
||||
@@ -106,12 +106,12 @@
|
||||
|
||||
<div class="model-row__actions">
|
||||
{# formaction lets these post elsewhere without nesting a second form. #}
|
||||
<button class="btn btn--icon btn--sm" type="submit" aria-label="Move up"
|
||||
<button class="btn btn--icon btn--sm" type="submit" aria-label="{{ t('Move up') }}"
|
||||
formaction="/admin/models/{{ model.id }}/move" name="direction" value="up"
|
||||
{{ 'disabled' if page == 1 and loop.first }}>
|
||||
{{ icon("arrow-up", "icon--sm") }}
|
||||
</button>
|
||||
<button class="btn btn--icon btn--sm" type="submit" aria-label="Move down"
|
||||
<button class="btn btn--icon btn--sm" type="submit" aria-label="{{ t('Move down') }}"
|
||||
formaction="/admin/models/{{ model.id }}/move" name="direction" value="down"
|
||||
{{ 'disabled' if page == pages and loop.last }}>
|
||||
{{ icon("arrow-down", "icon--sm") }}
|
||||
@@ -135,13 +135,13 @@
|
||||
{% if page > 1 %}
|
||||
<a class="btn btn--sm" href="{{ base }}&page={{ page - 1 }}">Previous</a>
|
||||
{% else %}
|
||||
<span class="btn btn--sm" aria-disabled="true" style="opacity: .45">Previous</span>
|
||||
<span class="btn btn--sm" aria-disabled="true" style="opacity: .45">{{ t("Previous") }}</span>
|
||||
{% endif %}
|
||||
<span class="text-xs faint">Page {{ page }} of {{ pages }}</span>
|
||||
{% if page < pages %}
|
||||
<a class="btn btn--sm" href="{{ base }}&page={{ page + 1 }}">Next</a>
|
||||
{% else %}
|
||||
<span class="btn btn--sm" aria-disabled="true" style="opacity: .45">Next</span>
|
||||
<span class="btn btn--sm" aria-disabled="true" style="opacity: .45">{{ t("Next") }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user