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:
@@ -33,9 +33,9 @@
|
||||
<button class="btn btn--icon btn--sm topbar__rename" type="button"
|
||||
hx-patch="/api/chats/{{ chat.id }}" hx-swap="none"
|
||||
data-prompt="What should this chat be called?"
|
||||
data-prompt-title="Rename chat" data-prompt-field="title"
|
||||
data-prompt-title="{{ t('Rename chat') }}" data-prompt-field="title"
|
||||
data-prompt-value="{{ chat.title }}"
|
||||
aria-label="Rename chat" title="Rename chat">
|
||||
aria-label="{{ t('Rename chat') }}" title="{{ t('Rename chat') }}">
|
||||
{{ icon("pencil", "icon--sm") }}
|
||||
</button>
|
||||
{% endif %}
|
||||
@@ -43,9 +43,7 @@
|
||||
it. The way out of it is Keep, in the overflow menu. #}
|
||||
{% if chat and chat.temporary %}
|
||||
<span class="badge badge--warning"
|
||||
title="Not listed in the sidebar, and removed 24 hours after the last message.">
|
||||
Temporary
|
||||
</span>
|
||||
title="{{ t('Not listed in the sidebar, and removed 24 hours after the last message.') }}">{{ t("Temporary") }}</span>
|
||||
{% endif %}
|
||||
</h1>
|
||||
|
||||
@@ -72,7 +70,7 @@
|
||||
{% if not chat and can.get("chat.create") %}
|
||||
<a class="btn btn--icon {{ 'is-active' if starting_temporary }}"
|
||||
href="{{ '/chat' if starting_temporary else '/chat?temporary=1' }}"
|
||||
aria-label="Temporary chat"
|
||||
aria-label="{{ t('Temporary chat') }}"
|
||||
title="{% if starting_temporary %}Starting a temporary chat. Click to go back to a normal one.{% else %}Start a temporary chat: not listed in the sidebar, and removed after a day.{% endif %}">
|
||||
{{ icon("clock") }}
|
||||
</a>
|
||||
@@ -97,8 +95,8 @@
|
||||
most likely to be open beside it. All three share one slot: at
|
||||
1280px the sidebar plus two panels leaves about seventy pixels of
|
||||
chat. #}
|
||||
<button class="btn btn--icon" type="button" aria-label="Canvas"
|
||||
title="Open a file beside the conversation"
|
||||
<button class="btn btn--icon" type="button" aria-label="{{ t('Canvas') }}"
|
||||
title="{{ t('Open a file beside the conversation') }}"
|
||||
{% if not chat %}data-agent-only hidden{% endif %}
|
||||
aria-expanded="false" data-toggle="#canvas" data-toggle-group="side">
|
||||
{{ icon("file-text") }}
|
||||
@@ -108,7 +106,7 @@
|
||||
{% if terminal_enabled %}
|
||||
{# To the left of the inspector, and never open beside it: see the
|
||||
toggle group in app.js. #}
|
||||
<button class="btn btn--icon" type="button" aria-label="Terminal"
|
||||
<button class="btn btn--icon" type="button" aria-label="{{ t('Terminal') }}"
|
||||
title="Open a shell on {{ agent_profile.name if agent_profile else 'this connection' }}"
|
||||
{% if not chat %}data-agent-only hidden{% endif %}
|
||||
aria-expanded="false" data-toggle="#terminal" data-toggle-group="side">
|
||||
@@ -117,8 +115,8 @@
|
||||
{% endif %}
|
||||
|
||||
{% if chat and user.is_admin %}
|
||||
<button class="btn btn--icon" type="button" aria-label="Inspect this chat"
|
||||
title="Inspect this chat" aria-expanded="false" data-toggle="#inspector"
|
||||
<button class="btn btn--icon" type="button" aria-label="{{ t('Inspect this chat') }}"
|
||||
title="{{ t('Inspect this chat') }}" aria-expanded="false" data-toggle="#inspector"
|
||||
data-toggle-group="side">
|
||||
{{ icon("search") }}
|
||||
</button>
|
||||
@@ -136,21 +134,19 @@
|
||||
<div class="picker" data-picker>
|
||||
<button class="btn btn--icon" type="button" data-picker-toggle
|
||||
aria-haspopup="menu" aria-expanded="false"
|
||||
aria-label="More" title="More">
|
||||
aria-label="{{ t('More') }}" title="{{ t('More') }}">
|
||||
{{ icon("dots") }}
|
||||
</button>
|
||||
|
||||
<div class="picker__menu picker__menu--compact" data-picker-menu role="menu"
|
||||
hidden aria-label="More">
|
||||
hidden aria-label="{{ t('More') }}">
|
||||
{% if chat.temporary %}
|
||||
<button class="picker__option" type="button" role="menuitem"
|
||||
hx-post="/api/chats/{{ chat.id }}/keep" hx-swap="none">
|
||||
{{ icon("pin", "icon--sm") }}
|
||||
<span class="picker__option-body">
|
||||
<span class="picker__option-name">Keep this chat</span>
|
||||
<span class="picker__option-note">
|
||||
Temporary — removed 24 hours after the last message
|
||||
</span>
|
||||
<span class="picker__option-name">{{ t("Keep this chat") }}</span>
|
||||
<span class="picker__option-note">{{ t("Temporary — removed 24 hours after the last message") }}</span>
|
||||
</span>
|
||||
</button>
|
||||
{% endif %}
|
||||
@@ -160,8 +156,8 @@
|
||||
data-toggle="#chat-settings">
|
||||
{{ icon("sliders", "icon--sm") }}
|
||||
<span class="picker__option-body">
|
||||
<span class="picker__option-name">Chat settings</span>
|
||||
<span class="picker__option-note">Prompt, knowledge, sampling</span>
|
||||
<span class="picker__option-name">{{ t("Chat settings") }}</span>
|
||||
<span class="picker__option-note">{{ t("Prompt, knowledge, sampling") }}</span>
|
||||
</span>
|
||||
</button>
|
||||
{% endif %}
|
||||
@@ -174,10 +170,8 @@
|
||||
onclick="window.lembasCommands && window.lembasCommands.run('compact')">
|
||||
{{ icon("archive", "icon--sm") }}
|
||||
<span class="picker__option-body">
|
||||
<span class="picker__option-name">Compact</span>
|
||||
<span class="picker__option-note">
|
||||
Summarise the earlier turns so they stop costing context
|
||||
</span>
|
||||
<span class="picker__option-name">{{ t("Compact") }}</span>
|
||||
<span class="picker__option-note">{{ t("Summarise the earlier turns so they stop costing context") }}</span>
|
||||
</span>
|
||||
</button>
|
||||
{% endif %}
|
||||
@@ -198,7 +192,7 @@
|
||||
|
||||
{% if can.get("chat.system_prompt") %}
|
||||
<div class="field">
|
||||
<label class="field__label" for="system-prompt">System prompt</label>
|
||||
<label class="field__label" for="system-prompt">{{ t("System prompt") }}</label>
|
||||
<textarea class="textarea" id="system-prompt" name="system_prompt" rows="3"
|
||||
placeholder="{{ inherited_prompt or 'Instructions that apply to every message in this chat.' }}"
|
||||
hx-patch="/api/chats/{{ chat.id }}" hx-swap="none"
|
||||
@@ -217,7 +211,7 @@
|
||||
{# Which bases this chat draws on. None ticked means everything you can
|
||||
see, which is what a chat with nothing chosen should do. #}
|
||||
<div class="field">
|
||||
<label class="field__label">Knowledge</label>
|
||||
<label class="field__label">{{ t("Knowledge") }}</label>
|
||||
<form hx-patch="/api/chats/{{ chat.id }}" hx-swap="none" hx-trigger="change">
|
||||
{# Always submitted, so unticking the last box still says something.
|
||||
An absent checkbox carries no signal of its own. #}
|
||||
@@ -247,7 +241,7 @@
|
||||
{# Who else answers. Nothing ticked is every chat that has ever existed:
|
||||
one model, answering on its own. #}
|
||||
<div class="field">
|
||||
<label class="field__label">Crowd</label>
|
||||
<label class="field__label">{{ t("Crowd") }}</label>
|
||||
<form hx-patch="/api/chats/{{ chat.id }}" hx-swap="none" hx-trigger="change">
|
||||
{# Always submitted, for the reason the bases above are. #}
|
||||
<input type="hidden" name="crowd_model_ids" value="">
|
||||
@@ -292,31 +286,28 @@
|
||||
{% if can.get("chat.params") %}
|
||||
<div class="grid grid--3">
|
||||
<div class="field">
|
||||
<label class="field__label" for="temperature">Temperature</label>
|
||||
<label class="field__label" for="temperature">{{ t("Temperature") }}</label>
|
||||
<input class="input" id="temperature" name="temperature" type="number"
|
||||
min="0" max="2" step="0.05" placeholder="default"
|
||||
min="0" max="2" step="0.05" placeholder="{{ t('default') }}"
|
||||
value="{{ chat.params_json.get('temperature') if chat.params_json.get('temperature') is not none else '' }}"
|
||||
hx-patch="/api/chats/{{ chat.id }}" hx-swap="none" hx-trigger="change">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field__label" for="top-p">Top-p</label>
|
||||
<label class="field__label" for="top-p">{{ t("Top-p") }}</label>
|
||||
<input class="input" id="top-p" name="top_p" type="number"
|
||||
min="0" max="1" step="0.05" placeholder="default"
|
||||
min="0" max="1" step="0.05" placeholder="{{ t('default') }}"
|
||||
value="{{ chat.params_json.get('top_p') if chat.params_json.get('top_p') is not none else '' }}"
|
||||
hx-patch="/api/chats/{{ chat.id }}" hx-swap="none" hx-trigger="change">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field__label" for="max-tokens">Max tokens</label>
|
||||
<label class="field__label" for="max-tokens">{{ t("Max tokens") }}</label>
|
||||
<input class="input" id="max-tokens" name="max_tokens" type="number"
|
||||
min="1" step="1" placeholder="default"
|
||||
min="1" step="1" placeholder="{{ t('default') }}"
|
||||
value="{{ chat.params_json.get('max_tokens') if chat.params_json.get('max_tokens') is not none else '' }}"
|
||||
hx-patch="/api/chats/{{ chat.id }}" hx-swap="none" hx-trigger="change">
|
||||
</div>
|
||||
</div>
|
||||
<p class="field__hint">
|
||||
Leave a field empty to let the provider decide. Values outside the
|
||||
allowed range are ignored rather than clamped.
|
||||
</p>
|
||||
<p class="field__hint">{{ t("Leave a field empty to let the provider decide. Values outside the allowed range are ignored rather than clamped.") }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</section>
|
||||
@@ -326,7 +317,7 @@
|
||||
{# Every fresh install lands here, so it points at the fix. #}
|
||||
<div class="empty">
|
||||
{{ icon("server", "empty__mark") }}
|
||||
<h2 class="empty__title">No models available</h2>
|
||||
<h2 class="empty__title">{{ t("No models available") }}</h2>
|
||||
<p class="empty__text">
|
||||
{% if user.is_admin %}
|
||||
Add an OpenAI-compatible connection and {{ brand.name }} will load its models.
|
||||
@@ -347,7 +338,7 @@
|
||||
{% if not messages %}
|
||||
<div class="thread__intro">
|
||||
{{ mark(cls="empty__mark", uid="intro") }}
|
||||
<h2 class="empty__title">What would you ask?</h2>
|
||||
<h2 class="empty__title">{{ t("What would you ask?") }}</h2>
|
||||
<p class="empty__text">{{ brand.text.chat_empty }}</p>
|
||||
|
||||
{# Only on a chat that does not exist yet. An empty chat someone
|
||||
|
||||
Reference in New Issue
Block a user