Translation bundles¶
_interpretation_bundle ¶
Locale translation bundles: schema, loader, and en-US derivation.
Interpretation text is data, not code. Each dataset family ships one JSON
bundle per locale under <family package>/locales/<dataset>/<locale>.json with
this shape::
{
"schema_version": 1,
"locale": "fr-FR",
"templates": { "<name>": "<format string>", ... },
"vocab": { "<group>": { "<key>": "<translated string>", ... }, ... }
}
The dataset builders stay in code and keep deriving structure (lookup keys,
keyword tokens, the set and order of signs/stems/cards) from fortune-telling-core.
A bundle only supplies the translatable templates and vocab strings; the
builder joins them with the structural data. templates and vocab are both
optional and may be empty (prose datasets keep all their text in vocab).
en-GB, fr-FR, and ja-JP are authored bundles. en-US is derived in code from the
en-GB bundle by :func:americanize (a British -> American spelling normalization),
so it never drifts from en-GB.
LocaleBundle
dataclass
¶
Parsed, validated translation bundle for one dataset and locale.
load_bundle ¶
Load and validate a locale bundle shipped as package data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
anchor
|
str
|
Import path of the package that owns the |
required |
dataset
|
str
|
Dataset family folder under |
required |
locale
|
str
|
Locale tag and file stem (e.g. |
required |
Returns:
| Type | Description |
|---|---|
LocaleBundle
|
The parsed bundle. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the bundle is missing or malformed. |
Source code in src/fortune_telling_core/_interpretation_bundle.py
americanize ¶
Return an en-US bundle from an en-GB one via spelling normalization.
Source code in src/fortune_telling_core/_interpretation_bundle.py
available_locales ¶
Return the sorted locale tags that have a bundle file for dataset.
Source code in src/fortune_telling_core/_interpretation_bundle.py
build_all ¶
Build a dataset for every authored bundle locale, plus a derived en-US.
Discovers all locales/<dataset>/*.json bundles, builds each with
builder(locale, bundle), and adds a derived en-US from the en-GB
bundle when no en-US bundle is authored. Adding a locale is therefore a
matter of adding a bundle file.