best_engine_ai_helper.i18n module
i18n — this package’s view of locales/i18n.yaml, the human-language source of truth.
Every GUI-visible string and every model-facing prompt template used by this
package is authored once, in locales/i18n.yaml (package root), under two
top-level namespaces:
guiUI strings keyed by a stable semantic name, each with a value per supported locale (
fr/en). Consumed bybest_engine_ai_helper.gui.promptsModel-facing prompt templates (system / user text sent to the local LLM or VLM by
best_engine_ai_helper.ralph,best_engine_ai_helper.validate_llm, andbest_engine_ai_helper.validate_vlm), authored in a single language declared atmeta.model_prompt_locale(English here) rather than translated — seelocales/i18n.yaml’s header andreferences/CODING.mdsection 21.3.3 for why prompt wording is not localized like GUI copy.
Parsing, locale resolution and validation are not done here: they are
os_helper.Locales, the loader shared by the whole suite. This module
used to re-implement them, which is how two packages came to hold two answers
to the same question. What stays is the part os-helper must not know: that a
prompts section exists at all, and what a prompt’s fields mean. That
separation is the point — the generic mechanism lives in the foundation, the
domain vocabulary lives where the domain is.
- best_engine_ai_helper.i18n.PROMPTS_SECTION = 'prompts'
The namespace holding model-facing templates. Named here rather than in os-helper, which has no business knowing that prompts are a thing. Since the GUI moved to gettext, this is the only section this module reads: the prompts are single-language templates keyed on meaning, which is exactly what Locales is for and exactly what gettext is not.
- best_engine_ai_helper.i18n.locales()[source]
Return the parsed locale file, loaded once.
- Returns:
The shared loader bound to this package’s
locales/i18n.yaml.- Return type:
os_helper.Locales
- Raises:
RuntimeError – If the file is malformed or lacks its
metasection — a broken locale file fails loudly at first use rather than surfacing as a confusingKeyErrordeep inside a caller.
Examples
>>> sorted(locales().supported_locales) ['en', 'fr']
- best_engine_ai_helper.i18n.meta()[source]
Return the
metablock: locale defaults and the model-prompt language.- Returns:
Keys
default_locale,supported_locales,model_prompt_localeandunlocalized_sections.- Return type:
Examples
>>> meta()["model_prompt_locale"] 'en'
- best_engine_ai_helper.i18n.prompt(key, field='user')[source]
Return one field of a model-facing prompt template.
- Parameters:
- Returns:
The raw template text, with any
{placeholder}markers intact for the caller to fill viastr.format.- Return type:
- Raises:
KeyError – If
keyorfieldis not present — a missing prompt must fail loudly rather than silently send an empty string to a model.
Examples
>>> prompt("writing_charter_excerpt", "text").startswith("Rule 5") True
- best_engine_ai_helper.i18n.prompts()[source]
The shared prompt loader, bound to this package’s locale file.
os_helper.Prompts serves the single-language shape this package uses (
key -> role -> text) as readily as the multi-language one, so the deliberate choice to author one model-facing language — declared asmeta.model_prompt_localeand documented in CODING.md 21.3.3 — needs no reshaping of the file to delegate. What goes away is this module’s own three-line accessor overLocales.raw, and with it one more place where the suite solved prompts privately.- Returns:
The loader, parsed once.
- Return type:
os_helper.Prompts