Dispatch translations titles-first across languages

This commit is contained in:
2026-09-03 23:03:47 +00:00
parent e6a0c57446
commit 78f4ddb2f0
+34 -28
View File
@@ -277,34 +277,40 @@ class Dispatcher:
job = None job = None
spans: list[Span] = [] spans: list[Span] = []
original = "" original = ""
for lang in sorted(langs): # Titles before articles — across languages too, so every menu
# Titles first: a page's name in the menu is its most # is named before any article body is worked on (a page's name
# visible string (stable: menu order kept within each kind). # is its most visible string). pending_items emits in menu
for item in sorted( # order, a page's title before its chunks; filtering by kind
pending_items(self.data, lang), key=lambda it: it.kind != "title" # keeps that stable order within each kind.
): pending = {lang: pending_items(self.data, lang) for lang in sorted(langs)}
if (lang, item.key) in inflight or ( for kind in ("title", "chunk"):
lang, for lang in sorted(langs):
item.key, for item in pending[lang]:
) in self.validation_failures: if (
continue item.kind != kind
spans, texts, contexts = split(item.text) or (lang, item.key) in inflight
if not texts: or (lang, item.key) in self.validation_failures
continue # prose that could not be located for splicing ):
original = item.text continue
if item.kind == "title" and item.context: spans, texts, contexts = split(item.text)
# A title's surround is the article's opening prose if not texts:
# (TransItem.context), not its own one-word block. continue # prose that could not be located for splicing
contexts = [item.context] * len(texts) original = item.text
job = Job( if item.kind == "title" and item.context:
lang=lang, # A title's surround is the article's opening prose
key=item.key, # (TransItem.context), not its own one-word block.
texts=texts, contexts = [item.context] * len(texts)
path=item.path, job = Job(
kind=item.kind, lang=lang,
contexts=contexts, key=item.key,
) texts=texts,
break path=item.path,
kind=item.kind,
contexts=contexts,
)
break
if job is not None:
break
if job is not None: if job is not None:
break break
if job is None: if job is None: