mirror of
https://github.com/kevinveenbirkenbach/homepage.veen.world.git
synced 2026-08-24 13:14:32 +00:00
The interface ships translated; page content stays English until a LibreTranslate instance fills app/i18n/content/ through make i18n. A string without a catalogue entry falls back to its English source, so a half-filled catalogue degrades instead of breaking. Translation runs after ConfigurationResolver.resolve_links(), on a copy. resolve_links matches by the `name` field, so translating it beforehand would break every `link:` reference in the configuration. negotiate() normalises to the primary subtag itself. Werkzeug's best_match returns an exact match before it considers a primary-tag fallback, so the Chrome default `de-DE,en;q=0.8` resolves to English there. "/" carries Vary: Accept-Language, without which a shared cache pins the first visitor's language for everyone. The route rule lists the known codes as a converter argument. A bare "/<lang>/" answers /robots.txt and /favicon.ico with a permanently cacheable 308 to their trailing-slash form. Templates gain lang, dir, the RTL stylesheet, a canonical URL and 30 hreflang alternates. Those are the first external URLs in this app: ProxyFix takes the scheme from X-Forwarded-Proto so they do not claim http:// behind a TLS-terminating proxy, X-Forwarded-Host stays untrusted because nginx passes a client-supplied one through, and TRUSTED_HOSTS lets Flask reject a forged Host outright. Flask only autoescapes .html/.htm/.xml/.xhtml/.svg, so every *.html.j2 template interpolated configuration raw. Enabling it changes two lines of the shipped page, both an apostrophe. read_catalog degrades an unreadable catalogue to English rather than serving a 500, and drops non-string entries that would otherwise render as "42". i18n_sync writes atomically, never overwrites an existing entry, refuses to touch a catalogue it could not parse, and leaves the file alone when a run translated nothing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
121 lines
5.2 KiB
Django/Jinja
121 lines
5.2 KiB
Django/Jinja
{% macro render_icon_and_name(item) %}
|
|
<i class="{{ item.icon.class if item.icon is defined and item.icon.class is defined else 'fa-solid fa-link' }}"></i>
|
|
{% if item.name is defined %}
|
|
{{ item.name }}
|
|
{% else %}
|
|
Unnamed Item: {{item}}
|
|
{% endif %}
|
|
{% endmacro %}
|
|
<!-- Template for children -->
|
|
{% macro render_children(children) %}
|
|
{% for child in children %}
|
|
{% if child.children %}
|
|
<li class="dropdown-submenu position-relative">
|
|
<a class="dropdown-item dropdown-toggle" title="{{ child.description }}">
|
|
{{ render_icon_and_name(child) }}
|
|
</a>
|
|
<ul class="dropdown-menu">
|
|
{{ render_children(child.children) }}
|
|
</ul>
|
|
</li>
|
|
|
|
{% elif child.identifier or child.warning or child.info %}
|
|
<li>
|
|
<a class="dropdown-item"
|
|
onclick='openDynamicPopup({{ child|tojson|safe }})'
|
|
data-bs-toggle="tooltip"
|
|
title="{{ child.description }}">
|
|
{{ render_icon_and_name(child) }}
|
|
</a>
|
|
</li>
|
|
|
|
{% else %}
|
|
<li>
|
|
<a class="dropdown-item {% if child.iframe %}iframe-link{% endif %}"
|
|
{% if child.onclick %}
|
|
onclick="{{ child.onclick }}"
|
|
{% else %}
|
|
href="{{ child.url }}"
|
|
{% endif %}
|
|
target="{{ child.target|default('_blank') }}"
|
|
data-bs-toggle="tooltip"
|
|
title="{{ child.description }}">
|
|
{{ render_icon_and_name(child) }}
|
|
</a>
|
|
</li>
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% endmacro %}
|
|
|
|
<!-- Navigation Bar -->
|
|
<nav class="navbar navbar-expand-lg navbar-light bg-light menu-{{menu_type}} mb-0">
|
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav{{menu_type}}" aria-controls="navbarNav{{menu_type}}" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
<div class="collapse navbar-collapse" id="navbarNav{{menu_type}}">
|
|
{% if menu_type == "header" %}
|
|
<a class="navbar-brand align-items-center d-flex js-restore" id="navbar_logo" href="#">
|
|
<img
|
|
src="{{ asset_src(platform.logo) }}"
|
|
alt="{{ platform.titel }}"
|
|
class="d-inline-block align-text-top"
|
|
style="height:2rem">
|
|
<div class="ms-2 d-flex flex-column">
|
|
<span class="fs-4 fw-bold mb-0">{{ platform.titel }}</span>
|
|
{# <small class="fs-7 text-muted">{{ platform.subtitel }}</small> #}
|
|
</div>
|
|
{% endif %}
|
|
</a>
|
|
<ul class="navbar-nav {% if menu_type == 'header' %}ms-auto{% endif %} btn-group">
|
|
{% for item in navigation[menu_type].children %}
|
|
{% if item.url or item.onclick %}
|
|
<li class="nav-item">
|
|
<a class="nav-link btn btn-light {% if item.iframe %}iframe-link{% endif %}"
|
|
{% if item.onclick %}
|
|
onclick="{{ item.onclick }}"
|
|
{% else %}
|
|
href="{{ item.url }}"
|
|
{% endif %}
|
|
target="{{ item.target|default('_blank') }}"
|
|
data-bs-toggle="tooltip"
|
|
title="{{ item.description }}">
|
|
{{ render_icon_and_name(item) }}
|
|
</a>
|
|
</li>
|
|
{% else %}
|
|
<!-- Dropdown Menu -->
|
|
<li class="nav-item dropdown">
|
|
<a class="nav-link dropdown-toggle btn btn-light" id="navbarDropdown{{ loop.index }}" role="button" data-bs-toggle="dropdown" data-bs-display="dynamic" aria-expanded="false">
|
|
{% if item.icon is defined and item.icon.class is defined %}
|
|
{{ render_icon_and_name(item) }}
|
|
{% else %}
|
|
<p>Missing icon in item: {{ item }}</p>
|
|
{% endif %}
|
|
</a>
|
|
<ul class="dropdown-menu">
|
|
{{ render_children(item.children) }}
|
|
</ul>
|
|
</li>
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% if menu_type == "header" %}
|
|
<li class="nav-item dropdown">
|
|
<a class="nav-link dropdown-toggle btn btn-light" id="navbarDropdownLanguage" role="button" data-bs-toggle="dropdown" data-bs-display="dynamic" aria-expanded="false" title="{{ t('Language') }}">
|
|
<i class="fa-solid fa-language"></i> {{ languages[lang] }}
|
|
</a>
|
|
<ul class="dropdown-menu">
|
|
{% for code, endonym in languages.items() %}
|
|
<li>
|
|
<a class="dropdown-item {% if code == lang %}active{% endif %}"
|
|
href="{{ url_for('localized_index', lang=code) }}"
|
|
hreflang="{{ code }}"
|
|
lang="{{ code }}">{{ endonym }}</a>
|
|
</li>
|
|
{% endfor %}
|
|
</ul>
|
|
</li>
|
|
{% endif %}
|
|
</ul>
|
|
</div>
|
|
</nav>
|