Skip to content

AI turns documents or topics into real, native PowerPoint decks—with native shapes, transitions and animations, data-backed charts and tables on demand, audio narration from speaker notes, and support for your own .pptx templates. · by Hugo He

feat(multilingual): propagate project language through PPTX export

hugohe37abf8af4cea1
diff --git a/skills/ppt-master/references/strategist.md b/skills/ppt-master/references/strategist.md
index f895744e..34fff016 100644
--- a/skills/ppt-master/references/strategist.md
+++ b/skills/ppt-master/references/strategist.md
@@ -28,7 +28,7 @@ As a top-tier AI presentation strategist, receive source documents, perform cont
| Stage | Items | Role |
|---|---|---|
-| **1 — communication contract** | `c` audience · open-ended communication intent · audience outcome · core message / delivery context (primary + optional secondary) / artifact afterlife · `content_divergence` (all prose fields may be blank) · `a` canvas | confirmed first |
+| **1 — communication contract** | `primary_language` · `c` audience · open-ended communication intent · audience outcome · core message / delivery context (primary + optional secondary) / artifact afterlife · `content_divergence` (all prose fields may be blank) · `a` canvas | confirmed first |
| **2 — complete deck solution** (authored once from the user's *actual* Stage 1) | reading mode (`delivery_purpose`, PPT only) · `d` mode + visual style · `b` page count · `e` color · `f` icon · `g` typography · `h` image source + generated-image rendering · conditional natural-language template application | derived from the confirmed contract; internal template exporter modes remain hidden |
| **3 — resources / production** (authored once from the user's *actual* Stage 1 + Stage 2) | formula policy · conditional AI-image acquisition path · generation mode · refine-spec toggle · proactive speaker notes / custom animations / narration audio | derived from the confirmed solution |
@@ -38,7 +38,7 @@ Do not force communication intent into one catalog label; Stage 1 records compos
>
> **One opt-in exception**: present the refinement line with the split-mode note ([`generate-pptx.md`](../workflows/generate-pptx.md) Step 4). Only explicit opt-in runs [`refine-spec`](../workflows/stages/refine-spec.md): write the Design Spec once, pass Gate 1, then stop before the lock for unrestricted chat revision. Never enter it unprompted.
-> **Default presentation surface — Confirm UI.** Use `<project>/confirm_ui/recommendations.stage1.json`, `.stage2.json`, and `.stage3.json` at their documented handoffs and launch per Generate Step 4. Stage 1 writes the deck content's `primary_language` separately from UI `lang`; the server carries it forward. The active, unconfirmed stage may be overwritten when the user asks for a new recommendation; normal progression writes the next stage file and leaves confirmed earlier stages intact. Stage 2 carries ≥3 safe / shifted / bold `design_directions`; each bundles visual style, a six-role HEX palette, primary-language heading/body typography plus an English companion only for non-English decks, icons, and conditional image rendering. Immediately print the actual URL, current Stage-1 compact summary, and direct-chat fallback line required by `confirm_ui.md`; this context is not confirmation. Skip launch only for an explicit chat-only request; a chat-question tool is not a substitute. Generate Step 4 reads the final confirmed `result.json` once and retains that object for Design Spec authoring. [`confirm_ui.md`](../scripts/docs/confirm_ui.md) owns schema and lifecycle.
+> **Default presentation surface — Confirm UI.** Use `<project>/confirm_ui/recommendations.stage1.json`, `.stage2.json`, and `.stage3.json`; launch per Generate Step 4. Stage 1 writes canonical BCP-47 `primary_language` apart from UI `lang`; the server normalizes legacy English/Chinese/Japanese/Korean names, rejecting `und` and Chinese without script/region; Strategist projects it through Design Spec §I to lock communication. Replace only the active unconfirmed stage; preserve confirmed files. Stage 2 carries ≥3 safe / shifted / bold `design_directions`; each bundles visual style, a six-role HEX palette, primary-language heading/body typography plus an English companion only for non-English decks, icons, and conditional image rendering. Print the URL, Stage-1 summary, and `confirm_ui.md` chat fallback; this is not confirmation. Skip launch only for explicit chat-only use; chat-question tools are no substitute. Step 4 reads final confirmed `result.json` once for Design Spec authoring. [`confirm_ui.md`](../scripts/docs/confirm_ui.md) owns schema and lifecycle.
**Confirmed-value semantics**: confirmation preserves both the value and the owning field's semantic type. Apply the type to the affected property, not automatically to the whole object:
diff --git a/skills/ppt-master/scripts/README.md b/skills/ppt-master/scripts/README.md
index f93e468d..212b80c4 100644
--- a/skills/ppt-master/scripts/README.md
+++ b/skills/ppt-master/scripts/README.md
@@ -51,7 +51,7 @@ python3 scripts/update_repo.py
| PPTX animations | `pptx_animations.py`, `animation_config.py` | [docs/pptx-animations.md](./docs/pptx-animations.md) |
| Spec maintenance | `update_spec.py`, `chart_recall.py` | [docs/update_spec.md](./docs/update_spec.md); [docs/chart-recall.md](./docs/chart-recall.md) |
| Image tools | `image_gen.py`, `latex_render.py`, `analyze_images.py`, `gemini_watermark_remover.py` | [docs/image.md](./docs/image.md) |
-| Maintenance smokes | Inline temporary-project commands | [advanced image and motion](./docs/advanced-image-motion-smoke.md); [mask and gradient](./docs/mask-gradient-smoke.md) |
+| Maintenance smokes | Inline temporary-project commands | [advanced image and motion](./docs/advanced-image-motion-smoke.md); [mask and gradient](./docs/mask-gradient-smoke.md); [multilingual text](./docs/multilingual-text-smoke.md) |
| Repo maintenance | `update_repo.py` | README install/update section |
| Troubleshooting | validation, preview, export, dependency issues | [docs/troubleshooting.md](./docs/troubleshooting.md) |
diff --git a/skills/ppt-master/scripts/confirm_ui/server.py b/skills/ppt-master/scripts/confirm_ui/server.py
index 9f89d8de..20a8d73d 100644
--- a/skills/ppt-master/scripts/confirm_ui/server.py
+++ b/skills/ppt-master/scripts/confirm_ui/server.py
@@ -55,6 +55,11 @@ if str(_SCRIPTS_DIR) not in sys.path:
sys.path.insert(0, str(_SCRIPTS_DIR))
from console_encoding import configure_utf8_stdio # noqa: E402
+from language_tags import ( # noqa: E402
+ LanguageTagError,
+ language_base,
+ normalize_language_tag,
+)
from server_common import ( # noqa: E402
claim_lock as _claim_lock,
clear_lock as _clear_lock,
@@ -556,12 +561,10 @@ def _is_english_language(language: object) -> bool:
"""Return whether a recommendation language is an English locale."""
if not isinstance(language, str):
return False
- normalized = language.strip().casefold().replace('_', '-')
- return (
- normalized == 'english'
- or normalized == 'en'
- or normalized.startswith('en-')
- )
+ try:
+ return language_base(language) == 'en'
+ except LanguageTagError:
+ return False
def _recommendation_language(recommendations: dict) -> object:
@@ -577,13 +580,28 @@ def _recommendation_language(recommendations: dict) -> object:
def _primary_language_error(recommendations: dict) -> Optional[str]:
- """Require a content-language source of truth for the new staged flow."""
+ """Require and canonicalize the staged content-language source of truth."""
+ return _canonicalize_primary_language(recommendations, required=True)
+
+
+def _canonicalize_primary_language(
+ recommendations: dict,
+ *,
+ required: bool,
+) -> Optional[str]:
+ """Write a canonical primary language into one recommendation/result object."""
value = _recommendation_language(recommendations)
if not isinstance(value, str) or not value.strip():
- return (
- 'Stage 1 recommendations must declare a non-empty primary language; '
- 'lang controls only the Confirm UI language'
- )
+ if required:
+ return (
+ 'Stage 1 recommendations must declare a valid primary_language '
+ 'BCP-47 tag; lang controls only the Confirm UI language'
+ )
+ return None
+ try:
+ recommendations['primary_language'] = normalize_language_tag(value)
+ except LanguageTagError as exc:
+ return f'invalid primary_language: {exc}'
return None
@@ -875,10 +893,18 @@ def _submission_stage_error(
previous_result = _read_json_object(confirm_dir / RESULT_NAME)
except (OSError, json.JSONDecodeError, ValueError):
previous_result = {}
- main_language = (
- _recommendation_language(previous_result)
- or _recommendation_language(recommendations)
+ language_source = (
+ previous_result
+ if _recommendation_language(previous_result)
+ else recommendations
+ )
+ language_error = _canonicalize_primary_language(
+ language_source,
+ required=True,
)
+ if language_error:
+ return language_error
+ main_language = _recommendation_language(language_source)
recommendation_error = _template_stage2_error(
recommendations,
template_required=template_required,
@@ -1199,7 +1225,12 @@ def _merge_confirmed_choices(data: dict, result_file: Path) -> None:
recommend = data['recommend'] = {}
main_language = _recommendation_language(res)
if main_language:
- data['primary_language'] = main_language
+ try:
+ data['primary_language'] = normalize_language_tag(main_language)
+ except LanguageTagError:
+ # Keep the invalid legacy value visible to the API boundary below,
+ # which returns a user-facing contract error instead of hiding it.
+ data['primary_language'] = main_language
for key in _CONTRACT_RECOMMEND_KEYS:
if res.get(key) not in (None, ''):
recommend[key] = res[key]
@@ -1667,10 +1698,18 @@ def create_app(
rec_stage_number = _recommendation_stage(data)
if rec_stage_number >= 2 and result_file.exists():
_merge_confirmed_choices(data, result_file)
- if rec_stage_number == 1:
- language_error = _primary_language_error(data)
+ if rec_stage_number > 0:
+ language_error = _canonicalize_primary_language(
+ data,
+ required=True,
+ )
if language_error:
return jsonify({'error': language_error}), 409
+ else:
+ # Legacy single-pass files remain permissive. Canonicalize only
+ # aliases/tags the shared helper already understands; an old prose
+ # value must never prevent the compatibility UI from opening.
+ _canonicalize_primary_language(data, required=False)
if rec_stage_number == 2:
recommendation_error = _template_stage2_error(
data,
@@ -1747,11 +1786,22 @@ def create_app(
previous_result = _read_json_object(result_file)
except (OSError, json.JSONDecodeError, ValueError):
pass
- main_language = (
- _recommendation_language(previous_result)
- or _recommendation_language(current_recommendations)
- )
+ main_language = None
if rec_stage_number > 0:
+ language_source = (
+ previous_result
+ if _recommendation_language(previous_result)
+ else current_recommendations
+ )
+ if not _recommendation_language(language_source):
+ language_source = result
+ language_error = _canonicalize_primary_language(
+ language_source,
+ required=True,
+ )
+ if language_error:
+ return jsonify({'error': language_error}), 409
+ main_language = _recommendation_language(language_source)
if main_language:
result['primary_language'] = main_language
else:
diff --git a/skills/ppt-master/scripts/confirm_ui/static/app.js b/skills/ppt-master/scripts/confirm_ui/static/app.js
index eb05b7ea..2309ed05 100644
--- a/skills/ppt-master/scripts/confirm_ui/static/app.js
+++ b/skills/ppt-master/scripts/confirm_ui/static/app.js
@@ -843,6 +843,7 @@
var allChips = [];
var customInput = el(aiCustom ? "textarea" : "input", "text-input custom-input");
+ setNaturalInputDirection(customInput);
if (opts2.inputClass) customInput.classList.add(opts2.inputClass);
if (aiCustom) customInput.rows = aiCustom.rows || 4;
else customInput.type = "text";
@@ -997,6 +998,7 @@
function textField(parent, getVal, setVal, placeholderKey, numeric) {
var input = el("input", numeric ? "num-input" : "text-input");
input.type = "text";
+ if (!numeric) setNaturalInputDirection(input);
input.value = getVal() || "";
input.placeholder = t(placeholderKey);
input.addEventListener("input", function () { setVal(input.value); });
@@ -1005,6 +1007,7 @@
function textareaField(parent, getVal, setVal, placeholderKey, rows) {
var input = el("textarea", "text-input");
+ setNaturalInputDirection(input);
input.rows = rows || 2;
input.value = getVal() || "";
input.placeholder = t(placeholderKey);
@@ -1054,16 +1057,32 @@
if (raw && typeof raw === "object") {
raw = raw.value || raw.id || raw.code || "";
}
- raw = String(raw || "und").trim().toLowerCase().replace(/_/g, "-");
- if (raw === "english") return "en";
- if (raw === "chinese") return "zh";
- if (raw === "japanese") return "ja";
- if (raw === "korean") return "ko";
- return raw;
+ // The API is the single normalizer; the browser consumes its canonical
+ // value instead of maintaining a second alias table.
+ return String(raw || "und").trim().replace(/_/g, "-");
}
function isEnglishProject() {
- return /^en(?:-|$)/.test(recommendationLanguage());
+ return /^en(?:-|$)/i.test(recommendationLanguage());
+ }
+
+ function setProjectLanguageAttributes(node) {
+ node.lang = recommendationLanguage();
+ node.dir = "auto";
+ }
+
+ function setEnglishLanguageAttributes(node) {
+ node.lang = "en";
+ node.dir = "ltr";
+ }
+
+ function setUiLanguageAttributes(node) {
+ node.lang = LANG === "zh" ? "zh-CN" : (LANG === "ja" ? "ja-JP" : "en-US");
+ node.dir = "ltr";
+ }
+
+ function setNaturalInputDirection(node) {
+ node.dir = "auto";
}
function stringList(value) {
@@ -1859,6 +1878,7 @@
});
}
var customInput = el("textarea", "text-input custom-color-input");
+ setNaturalInputDirection(customInput);
customInput.rows = 2;
customInput.placeholder = t("custom_color_placeholder");
customInput.style.display = "none";
@@ -1998,6 +2018,38 @@
!typographyFamiliesComplete(STATE.typography));
}
+ function previewText(value, maxCharacters) {
+ var text = String(value || "").replace(/\s+/g, " ").trim();
+ var characters = Array.from(text);
+ if (characters.length <= maxCharacters) return text;
+ return characters.slice(0, Math.max(1, maxCharacters - 1)).join("") + "…";
+ }
+
+ function projectLanguageProse() {
+ var fields = [
+ "core_message",
+ "communication_intent",
+ "audience_outcome",
+ "delivery_context",
+ "artifact_afterlife",
+ "content_divergence",
+ "audience"
+ ];
+ var values = [];
+ fields.forEach(function (field) {
+ var value = String((STATE && STATE[field]) || "").replace(/\s+/g, " ").trim();
+ if (value && values.indexOf(value) < 0) values.push(value);
+ });
+ return values;
+ }
+
+ function projectLanguageSample(role) {
+ var prose = projectLanguageProse();
+ if (!prose.length) return "";
+ if (role === "heading") return previewText(prose[0], 56);
+ return previewText(prose[1] || prose[0], 96);
+ }
+
function sampleText(role, field) {
var useEnglish = field === "english" || isEnglishProject();
if (role === "heading") {
@@ -2008,8 +2060,12 @@
function fontSample(box, slot, css, role) {
var line = el("div", "font-sample-line");
+ var projectSample = projectLanguageSample(role);
+ var slotSample = String(slot.sample_primary || "").trim();
var primary = el("span", "fs-primary",
- slot.sample_primary || sampleText(role, "primary"));
+ projectSample || slotSample || sampleText(role, "primary"));
+ if (projectSample || slotSample) setProjectLanguageAttributes(primary);
+ else setUiLanguageAttributes(primary);
var primaryStack = previewFontStack(slot.primary, css);
if (primaryStack) primary.style.fontFamily = primaryStack;
if (primaryStack) primary.title = primaryStack;
@@ -2017,6 +2073,7 @@
if (!isEnglishProject()) {
var english = el("span", "fs-english",
slot.sample_english || sampleText(role, "english"));
+ setEnglishLanguageAttributes(english);
var englishStack = previewFontStack(slot.english, css);
if (englishStack) english.style.fontFamily = englishStack;
if (englishStack) english.title = englishStack;
@@ -2408,6 +2465,8 @@
var bodyWrap = el("div", "sp-body-wrap");
var bodyPrimary = el("span", "sp-body-primary");
var bodyEnglish = el("span", "sp-body-english");
+ setEnglishLanguageAttributes(titleEnglish);
+ setEnglishLanguageAttributes(bodyEnglish);
bodyWrap.appendChild(bodyPrimary); bodyWrap.appendChild(bodyEnglish);
bodyRow.appendChild(accentBar); bodyRow.appendChild(bodyWrap);
textcol.appendChild(title); textcol.appendChild(bodyRow);
@@ -2440,18 +2499,28 @@
var headEnglishStack = previewFontStack(head.english, head.css);
var bodyPrimaryStack = previewFontStack(body.primary, body.css);
var bodyEnglishStack = previewFontStack(body.english, body.css);
+ var projectTitle = projectLanguageSample("heading");
+ var projectBody = projectLanguageSample("body");
+ var headingSample = String(head.sample_primary || "").trim();
+ var bodySample = String(body.sample_primary || "").trim();
card.style.background = bg;
- titlePrimary.textContent = head.sample_primary ||
+ titlePrimary.textContent = projectTitle ||
+ headingSample ||
sampleText("heading", "primary");
+ if (projectTitle || headingSample) setProjectLanguageAttributes(titlePrimary);
+ else setUiLanguageAttributes(titlePrimary);
titleEnglish.textContent = head.sample_english ||
sampleText("heading", "english");
title.style.color = pri;
title.style.fontSize = Math.round(bodyPx * 1.7) + "px";
titlePrimary.style.fontFamily = headPrimaryStack || "";
titleEnglish.style.fontFamily = headEnglishStack || "";
- bodyPrimary.textContent = body.sample_primary ||
+ bodyPrimary.textContent = projectBody ||
+ bodySample ||
sampleText("body", "primary");
+ if (projectBody || bodySample) setProjectLanguageAttributes(bodyPrimary);
+ else setUiLanguageAttributes(bodyPrimary);
bodyEnglish.textContent = body.sample_english ||
sampleText("body", "english");
bodyWrap.style.color = txt;
@@ -2464,6 +2533,8 @@
content.style.color = txt;
content.style.fontFamily = bodyPrimaryStack || "";
content.innerHTML = stylePreviewContentMarkup(STATE.icons);
+ if (projectLanguageProse().length) setProjectLanguageAttributes(content);
+ else setUiLanguageAttributes(content);
chip.style.background = sbg;
chipDot.style.background = sacc;
chipLabel.textContent = t("role_secondary_bg");
@@ -2528,6 +2599,17 @@
}
function stylePreviewRows() {
+ var prose = projectLanguageProse();
+ if (prose.length) {
+ var projectRows = [];
+ for (var i = 0; i < Math.min(3, Math.ceil(prose.length / 2)); i += 1) {
+ projectRows.push([
+ previewText(prose[i * 2], 36),
+ previewText(prose[i * 2 + 1] || "", 72)
+ ]);
+ }
+ return projectRows;
+ }
return [
[t("preview_point_1_title"), t("preview_point_1_text")],
[t("preview_point_2_title"), t("preview_point_2_text")],
@@ -2566,6 +2648,7 @@
var usageNote = el("div", "subfield");
usageNote.appendChild(el("div", "subfield-label", t("image_usage_notes")));
var usageNoteInput = el("textarea", "text-input image-usage-notes-input");
+ setNaturalInputDirection(usageNoteInput);
usageNoteInput.placeholder = t("image_usage_notes_placeholder");
usageNoteInput.value = STATE.image_notes || "";
usageNoteInput.addEventListener("input", function () { STATE.image_notes = usageNoteInput.value; });
@@ -2643,6 +2726,7 @@
var customCopy = el("div", "ai-custom-candidate-copy", customStrategy.behavior);
customCard.appendChild(customCopy);
var customInput = el("textarea", "text-input image-strategy-custom-input");
+ setNaturalInputDirection(customInput);
customInput.rows = 4;
customInput.placeholder = t("image_strategy_custom_placeholder");
customInput.value = customStrategy.behavior;
@@ -2981,6 +3065,20 @@
// with the newly authored candidates. Stage-1 STATE is preserved
// across the single-session transition — this never resets the contract.
function initStage2State() {
+ [
+ "audience",
+ "communication_intent",
+ "audience_outcome",
+ "core_message",
+ "delivery_context",
+ "artifact_afterlife",
+ "content_divergence"
+ ].forEach(function (field) {
+ var value = recValue(field);
+ if (value && typeof value === "object") value = value.value;
+ if (value != null) STATE[field] = String(value);
+ });
+ STATE.primary_language = recommendationLanguage();
resetTypographySizeOverrides();
var templateApplication = templateApplicationRecommendation();
if (templateApplication != null) {
diff --git a/skills/ppt-master/scripts/docs/confirm_ui.md b/skills/ppt-master/scripts/docs/confirm_ui.md
index 00281ca6..42f6654d 100644
--- a/skills/ppt-master/scripts/docs/confirm_ui.md
+++ b/skills/ppt-master/scripts/docs/confirm_ui.md
@@ -92,7 +92,7 @@ The page runs as a **three-stage wizard in one browser session**. Each stage has
| Recommendation file | Declared stage | Page renders | Button | On submit |
|---|---|---|---|---|
-| `recommendations.stage1.json` | `"stage1"` | communication contract — audience; open `communication_intent`; audience outcome; core message / primary delivery context + optional secondary use / artifact afterlife / `content_divergence` (all prose fields may be blank); canvas | **Confirm contract & continue** | writes `result.json` `{ stage: "stage1", status: "stage1-confirmed", <communication contract> }`; the page stays open and polls |
+| `recommendations.stage1.json` | `"stage1"` | communication contract — content language; audience; open `communication_intent`; audience outcome; core message / primary delivery context + optional secondary use / artifact afterlife / `content_divergence` (all prose fields may be blank); canvas | **Confirm contract & continue** | writes `result.json` `{ stage: "stage1", status: "stage1-confirmed", <communication contract> }`; the page stays open and polls |
| `recommendations.stage2.json` | `"stage2"` | complete deck solution — conditional natural-language template application, reading mode, mode, page count, visual direction, color, icons, typography, image usage, generated-image rendering | **Confirm solution & continue** | writes `result.json` `{ stage: "stage2", status: "stage2-confirmed", <contract + solution> }`; the page stays open and polls |
| `recommendations.stage3.json` | `"stage3"` | production only — confirmed image-source summary, conditional AI acquisition path, formula policy, proactive notes / custom-animation / narration-audio toggles, generation mode, Design Spec review toggle | **Confirm** | writes `result.json` `{ stage: "final", status: "confirmed", <all fields> }`, then shuts the page down |
| `recommendations.json` | stage or legacy no-stage payload | read-only compatibility when no stage-specific file exists | matching legacy behavior | preserves the former staged or single-pass behavior; new projects never create this file |
@@ -131,7 +131,7 @@ The AI launches Stage 1, authors the complete Stage-2 solution once from the use
}
```
-All seven Stage-1 prose values may be blank. `primary_language` is the deck's BCP-47 content language; `lang` is UI-only, and the server carries the former across stages. Displayed prose is editable and submitted verbatim, including `""`. A profile may lock an open field with `{ "value": "...", "locked": true }`; the browser renders it read-only, the server carries the lock, and removes its internal marker from final `result.json`.
+All seven Stage-1 prose values may be blank. `primary_language` is required canonical BCP-47. The server normalizes legacy English / Chinese / Japanese / Korean aliases, rejects `und` and Chinese without script/region, and carries it forward; `lang` is UI-only. Prose submits verbatim, including `""`. A profile's `{ "locked": true }` value is read-only, persisted, and stripped of that marker in final `result.json`.
The common paths — inform / explain / persuade / decide / align / teach / report and account / mobilize / record and hand off — appear only as help text for `communication_intent`. They are not catalog ids and must not be emitted as a `primary_job` field.
@@ -223,7 +223,7 @@ After Stage 2 is confirmed, create `recommendations.stage3.json` with production
- `recommend.*` names each recommended id. New mode / style values use a catalog id or literal `custom`; arbitrary prose values are legacy-only. Use `recommend.image_strategy: "custom"` only when an explicit user-supplied image direction should start selected. Missing recommendations fall back to the normal preset. Legacy aliases remain accepted; new files write canonical ids.
- The three proactive-execution fields are top-level boolean `{ "value": ... }` objects, not catalog ids. Omitted fields use `true / false / false` for notes / custom animation / narration audio. These are absence-of-instruction defaults, not permission to override the user's latest explicit request. Preserve all three raw values independently through `result.json`; do not couple or rewrite them. Strategist derives effective Speaker Notes as enabled when audio is `true` and records `Narration Audio dependency` as provenance in the Design Spec. `proactive_custom_animations: false` leaves Strategist animation suggestions unchanged; it only prevents unrequested custom-animation execution.
- `custom_candidates` is recommendation-only. Mode / style carry localized `name` + `behavior`; conditional image strategy also carries `rendering: "custom"`, `visual`, and `mood`. When a proposal combines or borrows existing catalog entries, the visible behavior names every exact id and Strategist reads every corresponding file before authoring it; a genuinely novel proposal names none. The server rejects missing required candidates; the UI shows full copy, edits it only after selection, rejects a selected blank, and omits unselected candidates from `result.json`. Template-backed proposals obey inherited identity, prototype capacity, and `template_application`.
-- `audience`, `communication_intent`, `audience_outcome`, and `delivery_context` are load-bearing Stage-1 reasoning inputs, so seed concrete recommendations when the evidence supports them; they are not required user inputs. Every Stage-1 prose field may be blank after confirmation. The complete six-field contract stays in `result.json` and `design_spec.md`; `spec_lock.md communication` receives only the compact `audience` / `objective` / `core_message` execution projection plus the applicable reading mode. `communication_intent` may preserve several purposes plus priority / sequence; never add a `primary_job` enum.
+- Seed `audience`, `communication_intent`, `audience_outcome`, and `delivery_context` when evidence supports them; users need not supply them, and every Stage-1 prose field may end blank. The contract and `primary_language` stay in `result.json` and `design_spec.md`; `spec_lock.md communication` receives `primary_language`, compact `audience` / `objective` / `core_message`, and reading mode. `communication_intent` may preserve multiple purposes and priority/sequence; never add a `primary_job` enum.
- Do not write `recommend.template_reuse_scope` or `recommend.template_adherence`. Strategist records those internal exporter values later in `spec_lock.md` after inspecting the actual template and current content.
- For an active template workspace, write one editable prose field as top-level `template_application.value`. It summarizes actual page/prototype use and preservation/reorganization decisions. Omit it for free design. The UI returns the current string through Stage 2, Stage 3, and final confirmation; Strategist then persists the final effective plan as `- **Template Application**: ...` in `design_spec.md §I`, which Executor reads from the retained Design Spec. Never replace it with internal reuse/adherence ids or a fixed option menu.
- `recommend.image_usage` should be an array of source ids when more than one source applies, e.g. `["ai", "provided"]`. A single string is still accepted for backward compatibility. Do not write bare `"custom"` and do not encode a mixed-source plan as prose here; write the prose to top-level `image_notes.value`.
diff --git a/skills/ppt-master/scripts/docs/multilingual-text-smoke.md b/skills/ppt-master/scripts/docs/multilingual-text-smoke.md
new file mode 100644
index 00000000..6896253a
--- /dev/null
+++ b/skills/ppt-master/scripts/docs/multilingual-text-smoke.md
@@ -0,0 +1,302 @@
+# Multilingual Text Maintenance Smoke
+
+Run this manual smoke from the repository root after changing Confirm UI
+language handling, DrawingML text export, native tables/charts, notes, or
+document metadata. It uses only temporary files and does not add an automated
+test suite.
+
+```bash
+PYTHONPATH="skills/ppt-master/scripts:skills/ppt-master/scripts/confirm_ui" python3 - <<'PY'
+import json
+import zipfile
+from pathlib import Path
+from tempfile import TemporaryDirectory
+from xml.etree import ElementTree as ET
+
+from pptx import Presentation
+
+from confirm_ui.server import create_app
+from language_tags import (
+ LanguageTagError,
+ language_uses_rtl,
+ normalize_language_tag,
+)
+from svg_to_pptx.drawingml.context import ConvertContext
+from svg_to_pptx.drawingml.converter import convert_svg_to_slide_shapes
+from svg_to_pptx.native_objects import _build_native_chart
+from svg_to_pptx.native_objects.table import _build_native_table
+from svg_to_pptx.pptx_package.builder import create_pptx_with_native_svg
+from svg_to_pptx.pptx_package.cli import _declared_primary_language
+from svg_to_pptx.pptx_package.notes import create_notes_slide_xml
+
+
+def reject_language(value):
+ try:
+ normalize_language_tag(value)
+ except LanguageTagError:
+ return
+ raise AssertionError(f"invalid language accepted: {value}")
+
+
+canonical = {
+ "ES_mx": "es-MX",
+ "RU_ru": "ru-RU",
+ "AR_sa": "ar-SA",
+ "HE_il": "he-IL",
+ "HI_in": "hi-IN",
+ "TH_th": "th-TH",
+ "KO_kr": "ko-KR",
+ "fil_ph": "fil-PH",
+ "zh_hans": "zh-Hans",
+ "de-CH-1901": "de-CH-1901",
+ "en-u-nu-latn": "en-u-nu-latn",
+}
+for raw, expected in canonical.items():
+ assert normalize_language_tag(raw) == expected
+for raw in ("und", "zh", "en--US", "Arabic", "x-private"):
+ reject_language(raw)
+assert language_uses_rtl("ar-Arab-SA")
+assert not language_uses_rtl("ar-Latn-SA")
+assert language_uses_rtl("en-Arab-US")
+
+samples = {
+ "en-US": "Summary 2026",
+ "zh-Hans": "年度总结 2026",
+ "ja-JP": "年間まとめ 2026",
+ "ko-KR": "연간 요약 2026",
+ "es-ES": "Resumen 2026",
+ "ru-RU": "Итоги 2026",
+ "ar-SA": "ملخص 2026",
+ "he-IL": "סיכום 2026",
+ "hi-IN": "सारांश 2026",
+ "th-TH": "สรุป 2026",
+}
+rtl_languages = {"ar-SA", "he-IL"}
+
+with TemporaryDirectory(prefix="ppt-master-multilingual-smoke-") as tmp:
+ root = Path(tmp)
+
+ # Confirm UI canonicalizes Stage 1 and persists the same project language.
+ project = root / "confirm-project"
+ confirm = project / "confirm_ui"
+ confirm.mkdir(parents=True)
+ recommendation = {
+ "stage": "stage1",
+ "lang": "en",
+ "primary_language": "AR_sa",
+ "audience": {"value": "Team"},
+ "communication_intent": {"value": "Explain"},
+ "audience_outcome": {"value": "Understand"},
+ "core_message": {"value": "Result"},
+ "delivery_context": {"value": "Meeting"},
+ "artifact_afterlife": {"value": ""},
+ "content_divergence": {"value": ""},
+ "recommend": {"canvas": "ppt169"},
+ }
+ (confirm / "recommendations.stage1.json").write_text(
+ json.dumps(recommendation),
+ encoding="utf-8",
+ )
+ app = create_app(str(project), idle_timeout=0)
+ app.testing = True
+ client = app.test_client()
+ response = client.get("/api/recommendations")
+ assert response.status_code == 200
+ assert response.get_json()["primary_language"] == "ar-SA"
+ response = client.post(
+ "/api/confirm",
+ json={
+ "stage": "stage1",
+ "primary_language": "ar-SA",
+ "canvas": "ppt169",
+ "audience": "Team",
+ "communication_intent": "Explain",
+ "audience_outcome": "Understand",
+ "core_message": "Result",
+ "delivery_context": "Meeting",
+ "artifact_afterlife": "",
+ "content_divergence": "",
+ },
+ )
+ assert response.status_code == 200
+ result = json.loads((confirm / "result.json").read_text(encoding="utf-8"))
+ assert result["primary_language"] == "ar-SA"
+
+ # The execution lock is the only export-time project-language source.
+ lock_project = root / "lock-project"
+ lock_project.mkdir()
+ lock_template = """# Execution Lock
+
+## communication
+{language}- audience: team
+- objective: explain
+- core_message: result
+"""
+ lock = lock_project / "spec_lock.md"
+ lock.write_text(
+ lock_template.format(language="- primary_language: ES_mx\n"),
+ encoding="utf-8",
+ )
+ assert _declared_primary_language(lock_project) == "es-MX"
+ lock.write_text(lock_template.format(language=""), encoding="utf-8")
+ assert _declared_primary_language(lock_project) is None
+
+ for index, (language, sample) in enumerate(samples.items(), 1):
+ stem = f"slide-{index}"
+ svg = root / f"{stem}.svg"
+ svg.write_text(
+ '<svg xmlns="http://www.w3.org/2000/svg" '
+ 'viewBox="0 0 1280 720">'
+ '<rect x="0" y="0" width="1280" height="720" fill="#FFFFFF"/>'
+ f'<text x="100" y="140" font-size="42" '
+ f'font-family="Arial" fill="#111111">{sample}</text>'
+ "</svg>",
+ encoding="utf-8",
+ )
+
+ slide_xml, *_ = convert_svg_to_slide_shapes(
+ svg,
+ index,
+ verbose=False,
+ primary_language=language,
+ )
+ assert f'lang="{language}"' in slide_xml
+ assert ("rtl=\"1\"" in slide_xml) == (language in rtl_languages)
+ assert ("<a:rtl val=\"1\"/>" in slide_xml) == (
+ language in rtl_languages
+ )
+
+ ascii_svg = root / f"{stem}-ascii.svg"
+ ascii_svg.write_text(
+ '<svg xmlns="http://www.w3.org/2000/svg" '
+ 'viewBox="0 0 1280 720">'
+ '<text x="100" y="140" font-size="42">2026 AI</text>'
+ "</svg>",
+ encoding="utf-8",
+ )
+ ascii_xml, *_ = convert_svg_to_slide_shapes(
+ ascii_svg,
+ index + 20,
+ verbose=False,
+ primary_language=language,
+ )
+ assert f'lang="{language}"' in ascii_xml
+ assert 'rtl="1"' not in ascii_xml
+ assert "<a:rtl val=\"1\"/>" not in ascii_xml
+
+ context = ConvertContext(primary_language=language)
+ marker = ET.Element("g")
+ table = _build_native_table(
+ marker,
+ context,
+ {
+ "x": 10,
+ "y": 10,
+ "width": 600,
+ "height": 180,
+ "columns": [sample, "2026 AI"],
+ "rows": [["A", "B"]],
+ "style": {"font_family": "Arial"},
+ },
+ )
+ assert f'lang="{language}"' in table.xml
+ assert all(slot in table.xml for slot in ("<a:latin ", "<a:ea ", "<a:cs "))
+
+ chart_context = ConvertContext(primary_language=language)
+ _build_native_chart(
+ marker,
+ chart_context,
+ {
+ "x": 10,
+ "y": 220,
+ "width": 600,
+ "height": 300,
+ "type": "column",
+ "title": sample,
+ "categories": ["A", "B"],
+ "series": [{"name": sample, "values": [1, 2]}],
+ "style": {"font_family": "Arial"},
+ "show_legend": True,
+ },
+ )
+ chart_xml = next(
+ value.decode("utf-8")
+ for part, value in chart_context.package_files.items()
+ if part.startswith("ppt/charts/chart") and not part.endswith(".rels")
+ )
+ assert f'<c:lang val="{language}"/>' in chart_xml
+ assert f'lang="{language}"' in chart_xml
+
+ notes_xml = create_notes_slide_xml(
+ 1,
+ sample + "\n2026 AI",
+ language,
+ )
+ assert f'lang="{language}"' in notes_xml
+ assert ("rtl=\"1\"" in notes_xml) == (language in rtl_languages)
+
+ output = root / f"{index}.pptx"
+ assert create_pptx_with_native_svg(
+ [svg],
+ output,
+ canvas_format="ppt169",
+ verbose=False,
+ transition=None,
+ notes={stem: sample + "\n2026 AI"},
+ pptx_structure="flat",
+ structure_name="multilingual-smoke",
+ primary_language=language,
+ )
+ with zipfile.ZipFile(output) as archive:
+ assert archive.testzip() is None
+ packaged_slide = archive.read(
+ "ppt/slides/slide1.xml"
+ ).decode("utf-8")
+ packaged_notes = archive.read(
+ "ppt/notesSlides/notesSlide1.xml"
+ ).decode("utf-8")
+ core = archive.read("docProps/core.xml").decode("utf-8")
+ assert f'lang="{language}"' in packaged_slide
+ assert f'lang="{language}"' in packaged_notes
+ assert f"<dc:language>{language}</dc:language>" in core
+ assert len(Presentation(str(output)).slides) == 1
+
+ # A legacy lock with no language field keeps the previous per-run path.
+ legacy_svg = root / "legacy.svg"
+ legacy_svg.write_text(
+ '<svg xmlns="http://www.w3.org/2000/svg" '
+ 'viewBox="0 0 1280 720">'
+ '<text x="100" y="140" font-size="42">한국어 2026</text>'
+ "</svg>",
+ encoding="utf-8",
+ )
+ legacy_output = root / "legacy.pptx"
+ assert create_pptx_with_native_svg(
+ [legacy_svg],
+ legacy_output,
+ canvas_format="ppt169",
+ verbose=False,
+ transition=None,
+ pptx_structure="flat",
+ structure_name="legacy-smoke",
+ )
+ with zipfile.ZipFile(legacy_output) as archive:
+ assert archive.testzip() is None
+ legacy_slide = archive.read(
+ "ppt/slides/slide1.xml"
+ ).decode("utf-8")
+ assert 'lang="ko-KR"' in legacy_slide
+
+print("Multilingual text smoke: passed")
+PY
+```
+
+Expected output:
+
+```text
+Multilingual text smoke: passed
+```
+
+The RTL contract is paragraph `a:pPr rtl="1"` plus run-level `a:rtl` only
+when the run contains strong RTL characters. Do not use `rtlCol`; it controls
+column order, not paragraph direction.
diff --git a/skills/ppt-master/scripts/language_tags.py b/skills/ppt-master/scripts/language_tags.py
new file mode 100644
index 00000000..4ac53266
--- /dev/null
+++ b/skills/ppt-master/scripts/language_tags.py
@@ -0,0 +1,283 @@
+#!/usr/bin/env python3
+"""
+PPT Master - Language Tag Helpers
+
+Normalize and inspect the project primary-language tag shared by confirmation
+and export tooling.
+
+Usage:
+ Import ``normalize_language_tag`` from another script.
+
+Examples:
+ from language_tags import normalize_language_tag
+ normalize_language_tag("Chinese")
+
+Dependencies:
+ None (only uses standard library)
+"""
+
+import re
+
+
+class LanguageTagError(ValueError):
+ """Report an invalid or ambiguous project language tag."""
+
+
+_LANGUAGE_RE = re.compile(r"^[A-Za-z]{2,8}$")
+_EXTLANG_RE = re.compile(r"^[A-Za-z]{3}$")
+_SCRIPT_RE = re.compile(r"^[A-Za-z]{4}$")
+_REGION_RE = re.compile(r"^(?:[A-Za-z]{2}|[0-9]{3})$")
+_VARIANT_RE = re.compile(r"^(?:[A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3})$")
+_SINGLETON_RE = re.compile(r"^[0-9A-WY-Za-wy-z]$")
+_EXTENSION_RE = re.compile(r"^[A-Za-z0-9]{2,8}$")
+_PRIVATE_RE = re.compile(r"^[A-Za-z0-9]{1,8}$")
+
+
+def _alias_key(value: str) -> str:
+ """Return a whitespace-stable key for legacy natural-language aliases."""
+ return " ".join(value.strip().casefold().split())
+
+
+_LANGUAGE_ALIASES = {
+ _alias_key(alias): tag
+ for tag, aliases in {
+ "en-US": (
+ "English",
+ "英文",
+ "英语",
+ "英語",
+ ),
+ "zh-Hans": (
+ "Chinese",
+ "Chinese Simplified",
+ "Chinese (Simplified)",
+ "Simplified Chinese",
+ "Mandarin",
+ "中文",
+ "汉语",
+ "漢語",
+ "普通话",
+ "普通話",
+ "简体",
+ "簡體",
+ "简体中文",
+ "簡體中文",
+ "简中",
+ ),
+ "zh-Hant": (
+ "Chinese Traditional",
+ "Chinese (Traditional)",
+ "Traditional Chinese",
+ "繁体",
+ "繁體",
+ "繁体中文",
+ "繁體中文",
+ "繁中",
+ ),
+ "ja-JP": (
+ "Japanese",
+ "日本語",
+ "日文",
+ "日语",
+ "日語",
+ ),
+ "ko-KR": (
+ "Korean",
+ "한국어",
+ "조선말",
+ "韩语",
+ "韓語",
+ "朝鲜语",
+ "朝鮮語",
+ ),
+ }.items()
+ for alias in aliases
+}
+
+_NATURAL_LANGUAGE_NAMES = {
+ "arabic",
+ "bengali",
+ "czech",
+ "danish",
+ "dutch",
+ "farsi",
+ "finnish",
+ "french",
+ "georgian",
+ "german",
+ "greek",
+ "hebrew",
+ "hindi",
+ "hungarian",
+ "indonesian",
+ "italian",
+ "malay",
+ "marathi",
+ "nepali",
+ "norwegian",
+ "persian",
+ "polish",
+ "portuguese",
+ "romanian",
+ "russian",
+ "slovak",
+ "spanish",
+ "swedish",
+ "tamil",
+ "telugu",
+ "thai",
+ "turkish",
+ "ukrainian",
+ "urdu",
+ "vietnamese",
+}
+_RTL_BASE_LANGUAGES = {
+ "ar",
+ "dv",
+ "fa",
+ "he",
+ "iw",
+ "ps",
+ "sd",
+ "ug",
+ "ur",
+ "yi",
+}
+_RTL_SCRIPTS = {
+ "Adlm",
+ "Arab",
+ "Hebr",
+ "Mand",
+ "Nkoo",
+ "Rohg",
+ "Samr",
+ "Syrc",
+ "Thaa",
+}
+
+
+def normalize_language_tag(value: str) -> str:
+ """Return one canonical, unambiguous BCP-47 language tag.
+
+ The helper accepts the four historical natural-language aliases used by
+ Confirm UI. Other language names stay invalid: callers must provide a real
+ tag such as ``es-ES``, ``ru-RU``, or ``ar-SA``.
+ """
+ if not isinstance(value, str) or not value.strip():
+ raise LanguageTagError("primary language must be a non-empty BCP-47 tag")
+
+ raw = value.strip()
+ alias = _LANGUAGE_ALIASES.get(_alias_key(raw))
+ if alias:
+ raw = alias
+ else:
+ raw = raw.replace("_", "-")
+
+ parts = raw.split("-")
+ if any(not part for part in parts):
+ raise LanguageTagError(f"invalid BCP-47 language tag: {value!r}")
+
+ language = parts[0]
+ if not _LANGUAGE_RE.fullmatch(language):
+ raise LanguageTagError(
+ "use a BCP-47 language tag such as es-ES, ru-RU, ar-SA, or zh-Hans"
+ )
+ language = language.lower()
+ if language in _NATURAL_LANGUAGE_NAMES:
+ raise LanguageTagError(
+ "use a BCP-47 language tag such as es-ES, ru-RU, ar-SA, or zh-Hans"
+ )
+ if language == "und":
+ raise LanguageTagError(
+ "und is not a usable primary language; choose the presentation language"
+ )
+
+ normalized = [language]
+ index = 1
+
+ extlang_count = 0
+ while (
+ len(language) <= 3
+ and index < len(parts)
+ and extlang_count < 3
+ and _EXTLANG_RE.fullmatch(parts[index])
+ ):
+ normalized.append(parts[index].lower())
+ index += 1
+ extlang_count += 1
+
+ has_script = False
+ if index < len(parts) and _SCRIPT_RE.fullmatch(parts[index]):
+ normalized.append(parts[index].title())
+ index += 1
+ has_script = True
+
+ has_region = False
+ if index < len(parts) and _REGION_RE.fullmatch(parts[index]):
+ region = parts[index]
+ normalized.append(region.upper() if region.isalpha() else region)
+ index += 1
+ has_region = True
+
+ variants = set()
+ while index < len(parts) and _VARIANT_RE.fullmatch(parts[index]):
+ variant = parts[index].lower()
+ if variant in variants:
+ raise LanguageTagError(f"duplicate BCP-47 variant: {parts[index]!r}")
+ variants.add(variant)
+ normalized.append(variant)
+ index += 1
+
+ singletons = set()
+ while index < len(parts) and _SINGLETON_RE.fullmatch(parts[index]):
+ singleton = parts[index].lower()
+ if singleton in singletons:
+ raise LanguageTagError(f"duplicate BCP-47 extension: {parts[index]!r}")
+ singletons.add(singleton)
+ normalized.append(singleton)
+ index += 1
+ start = index
+ while index < len(parts) and _EXTENSION_RE.fullmatch(parts[index]):
+ normalized.append(parts[index].lower())
+ index += 1
+ if index == start:
+ raise LanguageTagError(
+ f"BCP-47 extension {singleton!r} requires a following subtag"
+ )
+
+ if index < len(parts) and parts[index].casefold() == "x":
+ normalized.append("x")
+ index += 1
+ start = index
+ while index < len(parts) and _PRIVATE_RE.fullmatch(parts[index]):
+ normalized.append(parts[index].lower())
+ index += 1
+ if index == start:
+ raise LanguageTagError("BCP-47 private use requires a following subtag")
+
+ if index != len(parts):
+ raise LanguageTagError(f"invalid BCP-47 subtag: {parts[index]!r}")
+ if language == "zh" and not (has_script or has_region):
+ raise LanguageTagError(
+ "Chinese must declare a script or region, for example zh-Hans, "
+ "zh-Hant, zh-CN, or zh-TW"
+ )
+ return "-".join(normalized)
+
+
+def language_base(value: str) -> str:
+ """Return the lower-case primary language subtag."""
+ return normalize_language_tag(value).split("-", 1)[0]
+
+
+def language_uses_rtl(value: str) -> bool:
+ """Return whether the canonical language or explicit script is RTL."""
+ tag = normalize_language_tag(value)
+ parts = tag.split("-")
+ index = 1
+ if len(parts[0]) <= 3:
+ while index < len(parts) and _EXTLANG_RE.fullmatch(parts[index]):
+ index += 1
+ if index < len(parts) and _SCRIPT_RE.fullmatch(parts[index]):
+ return parts[index] in _RTL_SCRIPTS
+ return parts[0] in _RTL_BASE_LANGUAGES
diff --git a/skills/ppt-master/scripts/prompt_audit_manifest.json b/skills/ppt-master/scripts/prompt_audit_manifest.json
index d12e1b35..548ede99 100644
--- a/skills/ppt-master/scripts/prompt_audit_manifest.json
+++ b/skills/ppt-master/scripts/prompt_audit_manifest.json
@@ -12,7 +12,7 @@
"skills/ppt-master/templates/schemas/*.json"
],
"exclude": [],
- "max_tokens": 394750
+ "max_tokens": 397600
},
"file_budgets": {
"AGENTS.md": 2400,
@@ -1140,6 +1140,10 @@
"glob": "skills/ppt-master/scripts/docs/advanced-image-motion-smoke.md",
"reason": "Maintainer-only executable image-and-motion smoke; never loaded by generation roles."
},
+ {
+ "glob": "skills/ppt-master/scripts/docs/multilingual-text-smoke.md",
+ "reason": "Maintainer-only executable multilingual export smoke; never loaded by generation roles."
+ },
{
"glob": "skills/ppt-master/scripts/docs/update_spec.md",
"reason": "Maintainer command reference for an optional helper script."
diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/context.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml/context.py
index 063f8b38..09b15546 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml/context.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/context.py
@@ -124,6 +124,9 @@ class ConvertContext:
# Optional project theme-color contract. Exact locked colors are promoted
# to context-safe DrawingML scheme slots while local colors stay concrete.
theme_color_spec: ThemeColorSpec | None = None
+ # Canonical BCP-47 content language from spec_lock.md. ``None`` preserves
+ # the legacy per-run script heuristic for older projects and quick tests.
+ primary_language: str | None = None
def next_id(self) -> int:
"""Allocate the next shape ID."""
@@ -273,6 +276,7 @@ class ConvertContext:
trace_events=self.trace_events,
theme_font_spec=self.theme_font_spec,
theme_color_spec=self.theme_color_spec,
+ primary_language=self.primary_language,
)
def sync_from_child(self, child_ctx: ConvertContext) -> None:
diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.py
index 1a8a5b1d..ef7565c5 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.py
@@ -1374,6 +1374,7 @@ def convert_svg_to_slide_shapes(
animation_group_overrides: frozenset[str] | None = None,
theme_font_spec: ThemeFontSpec | None = None,
theme_color_spec: ThemeColorSpec | None = None,
+ primary_language: str | None = None,
trace_out: list[dict[str, Any]] | None = None,
promote_background: bool = True,
text_flow: str | None = None,
@@ -1412,6 +1413,8 @@ def convert_svg_to_slide_shapes(
theme_color_spec: Optional context-aware theme-color contract. Exact
locked colors emit DrawingML scheme tokens while local colors stay
fixed.
+ primary_language: Canonical BCP-47 project content language. ``None``
+ keeps the legacy per-run script heuristic.
trace_out: Optional list populated with one per-slide trace dictionary.
promote_background: Promote the first eligible full-canvas rectangle
into native ``p:bg``. Structured export disables this generic pass
@@ -1675,6 +1678,7 @@ def convert_svg_to_slide_shapes(
trace_events=trace_events,
theme_font_spec=theme_font_spec,
theme_color_spec=theme_color_spec,
+ primary_language=primary_language,
inherited_styles=_extract_inheritable_styles(root),
text_font_sizes=text_font_sizes,
text_letter_spacings=text_letter_spacings,
diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.py
index a3649fb4..f4ea9f1b 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.py
@@ -60,6 +60,7 @@ from .utils import (
parse_inline_style, parse_font_family, is_cjk_char,
detect_text_lang, estimate_text_cluster_widths, font_px_to_hpt,
resolve_text_run_fonts, split_project_text_clusters,
+ text_has_rtl_characters, text_uses_rtl,
is_thick_circle_shorthand, parse_project_geometry_length,
is_canonical_project_geometry_length,
parse_project_image_aspect_ratio,
@@ -2242,8 +2243,11 @@ def _paragraph_pr_xml(
body_xml: str = '',
bullet: dict[str, Any] | None = None,
ctx: ConvertContext | None = None,
+ rtl: bool = False,
) -> str:
attrs = f'algn="{algn}"'
+ if rtl:
+ attrs += ' rtl="1"'
if bullet:
margin = px_to_emu(_bullet_margin_px(bullet, font_size))
indent = px_to_emu(_bullet_indent_px(bullet, font_size))
@@ -2546,7 +2550,15 @@ def _build_run_properties_xml(
fonts,
ctx.theme_font_spec if ctx is not None else None,
) or resolve_text_run_fonts(text, fonts)
- lang = detect_text_lang(text)
+ lang = detect_text_lang(
+ text,
+ ctx.primary_language if ctx is not None else None,
+ )
+ rtl_xml = (
+ '\n<a:rtl val="1"/>'
+ if text_has_rtl_characters(text)
+ else ''
+ )
fill_xml = _build_text_fill_xml(fill, fill_raw, opacity, ctx)
outline_xml = _build_text_outline_xml(run, ctx)
@@ -2557,7 +2569,7 @@ def _build_run_properties_xml(
{effect_xml}
<a:latin typeface="{_xml_escape(run_fonts['latin'])}"/>
<a:ea typeface="{_xml_escape(run_fonts['ea'])}"/>
-<a:cs typeface="{_xml_escape(run_fonts['cs'])}"/>
+<a:cs typeface="{_xml_escape(run_fonts['cs'])}"/>{rtl_xml}
</a:rPr>'''
@@ -3011,6 +3023,10 @@ def convert_text(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:
body_xml=f'{ln_spc_xml}{spc_bef_xml}',
bullet=bullet,
ctx=ctx,
+ rtl=text_uses_rtl(
+ ''.join(str(run.get('text', '')) for run in line),
+ ctx.primary_language,
+ ),
)
paragraph_xml_chunks.append(
f'<a:p>\n{p_pr_xml}\n{runs_inner}\n</a:p>'
@@ -3023,6 +3039,7 @@ def convert_text(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:
font_size=float(runs[0].get('font_size', font_size)) if runs else font_size,
bullet=single_bullet,
ctx=ctx,
+ rtl=text_uses_rtl(full_text, ctx.primary_language),
)
paragraphs_xml = f'<a:p>\n{p_pr_xml}\n{runs_xml}\n</a:p>'
diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/utils.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml/utils.py
index 8744c458..12aa217c 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml/utils.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/utils.py
@@ -22,6 +22,7 @@ from pptx_shapes import (
svg_preset_preview_fingerprint,
validate_ooxml_xfrm,
)
+from language_tags import language_base, language_uses_rtl
from .context import AffineMatrix, ConvertContext, IDENTITY_MATRIX
@@ -3017,8 +3018,50 @@ def is_cjk_char(ch: str) -> bool:
)
-def detect_text_lang(text: str) -> str:
- """Return a DrawingML language tag for a text run."""
+def _contains_codepoint_range(
+ text: str,
+ ranges: tuple[tuple[int, int], ...],
+) -> bool:
+ """Return whether text contains a code point in one of the ranges."""
+ return any(
+ start <= ord(ch) <= end
+ for ch in text
+ for start, end in ranges
+ )
+
+
+def _default_language_for_script(
+ default_language: str | None,
+ bases: frozenset[str],
+ fallback: str,
+) -> str:
+ """Prefer the project language when it belongs to the detected script."""
+ if default_language and language_base(default_language) in bases:
+ return default_language
+ return fallback
+
+
+def text_has_rtl_characters(text: str) -> bool:
+ """Return whether text contains a strong right-to-left character."""
+ return any(unicodedata.bidirectional(ch) in {'R', 'AL'} for ch in text)
+
+
+def text_uses_rtl(text: str, default_language: str | None = None) -> bool:
+ """Resolve paragraph direction from its first strong character or project."""
+ for char in text:
+ direction = unicodedata.bidirectional(char)
+ if direction in {'R', 'AL'}:
+ return True
+ if direction == 'L':
+ return False
+ return bool(default_language and language_uses_rtl(default_language))
+
+
+def detect_text_lang(
+ text: str,
+ default_language: str | None = None,
+) -> str:
+ """Return a DrawingML language tag, preferring the project contract."""
has_hangul = False
has_kana = False
has_east_asian_text = False
@@ -3031,10 +3074,81 @@ def detect_text_lang(text: str) -> str:
)
has_east_asian_text = has_east_asian_text or is_cjk_char(ch)
if has_hangul:
- return 'ko-KR'
+ return _default_language_for_script(
+ default_language,
+ frozenset({'ko'}),
+ 'ko-KR',
+ )
if has_kana:
- return 'ja-JP'
- return 'zh-CN' if has_east_asian_text else 'en-US'
+ return _default_language_for_script(
+ default_language,
+ frozenset({'ja'}),
+ 'ja-JP',
+ )
+ if has_east_asian_text:
+ return _default_language_for_script(
+ default_language,
+ frozenset({'zh', 'ja', 'ko'}),
+ 'zh-CN',
+ )
+ if _contains_codepoint_range(text, (
+ (0x0600, 0x06FF),
+ (0x0750, 0x077F),
+ (0x08A0, 0x08FF),
+ (0xFB50, 0xFDFF),
+ (0xFE70, 0xFEFF),
+ (0x1EE00, 0x1EEFF),
+ )):
+ return _default_language_for_script(
+ default_language,
+ frozenset({'ar', 'fa', 'ps', 'sd', 'ug', 'ur'}),
+ 'ar-SA',
+ )
+ if _contains_codepoint_range(text, (
+ (0x0590, 0x05FF),
+ (0xFB1D, 0xFB4F),
+ )):
+ return _default_language_for_script(
+ default_language,
+ frozenset({'he', 'yi'}),
+ 'he-IL',
+ )
+ if _contains_codepoint_range(text, (
+ (0x0900, 0x097F),
+ (0xA8E0, 0xA8FF),
+ )):
+ return _default_language_for_script(
+ default_language,
+ frozenset({'hi', 'mr', 'ne', 'sa'}),
+ 'hi-IN',
+ )
+ if _contains_codepoint_range(text, ((0x0E00, 0x0E7F),)):
+ return _default_language_for_script(
+ default_language,
+ frozenset({'th'}),
+ 'th-TH',
+ )
+ if _contains_codepoint_range(text, (
+ (0x0400, 0x052F),
+ (0x1C80, 0x1C8F),
+ (0x2DE0, 0x2DFF),
+ (0xA640, 0xA69F),
+ )):
+ return _default_language_for_script(
+ default_language,
+ frozenset({'be', 'bg', 'kk', 'ky', 'mk', 'mn', 'ru', 'sr', 'uk'}),
+ 'ru-RU',
+ )
+ if _contains_codepoint_range(text, (
+ (0x0370, 0x03FF),
+ (0x1F00, 0x1FFF),
+ )):
+ return _default_language_for_script(
+ default_language,
+ frozenset({'el'}),
+ 'el-GR',
+ )
+ return default_language or 'en-US'
def _is_grapheme_extend(ch: str) -> bool:
@@ -3157,7 +3271,7 @@ def split_project_text_clusters(text: str) -> list[str]:
def resolve_text_run_fonts(text: str, fonts: dict[str, str]) -> dict[str, str]:
"""Return DrawingML latin/ea/cs typefaces for one text run."""
latin = fonts['latin']
- if detect_text_lang(text) != 'en-US':
+ if any(is_cjk_char(ch) for ch in text):
ea = fonts['ea']
else:
ea = latin
diff --git a/skills/ppt-master/scripts/svg_to_pptx/native_objects/__init__.py b/skills/ppt-master/scripts/svg_to_pptx/native_objects/__init__.py
index 5332bb4a..b5852381 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/native_objects/__init__.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/native_objects/__init__.py
@@ -151,6 +151,7 @@ def _build_native_chart(elem: ET.Element, ctx: ConvertContext, payload: dict[str
chart_rels_id="rId1",
chart_data=chart_data,
inherited_styles=ctx.inherited_styles,
+ primary_language=ctx.primary_language,
)
ctx.package_files[chart_rels_part] = _chart_rels_xml(f"../embeddings/{workbook_name}")
if chart_data["kind"] == "xy":
diff --git a/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_style.py b/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_style.py
index 764b43a6..9b311b72 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_style.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_style.py
@@ -15,6 +15,8 @@ from ..drawingml.utils import (
parse_font_family,
px_to_emu,
quantize_ooxml_alpha,
+ text_has_rtl_characters,
+ text_uses_rtl,
)
from .chart_data import _DEFAULT_CHART_COLORS
from .marker_common import (
@@ -297,7 +299,11 @@ def _font_face_xml(font_face: str | None) -> str:
fonts = parse_font_family(font_face)
latin_font = _xml_escape(fonts["latin"])
ea_font = _xml_escape(fonts["ea"])
- return f'<a:latin typeface="{latin_font}"/><a:ea typeface="{ea_font}"/>'
+ return (
+ f'<a:latin typeface="{latin_font}"/>'
+ f'<a:ea typeface="{ea_font}"/>'
+ f'<a:cs typeface="{latin_font}"/>'
+ )
def _chart_tx_pr_xml(
@@ -306,16 +312,20 @@ def _chart_tx_pr_xml(
*,
bold: bool = False,
font_face: str | None = None,
+ language: str | None = None,
) -> str:
fill_xml = (
f'<a:solidFill><a:srgbClr val="{color}"/></a:solidFill>'
if color else ""
)
bold_attr = ' b="1"' if bold else ""
+ resolved_language = language or 'en-US'
+ rtl_attr = ' rtl="1"' if text_uses_rtl('', language) else ''
return (
- "<c:txPr><a:bodyPr/><a:lstStyle/><a:p><a:pPr>"
- f'<a:defRPr sz="{font_size}"{bold_attr}>{fill_xml}{_font_face_xml(font_face)}</a:defRPr>'
- '</a:pPr><a:endParaRPr lang="en-US"/></a:p></c:txPr>'
+ f"<c:txPr><a:bodyPr/><a:lstStyle/><a:p><a:pPr{rtl_attr}>"
+ f'<a:defRPr lang="{resolved_language}" sz="{font_size}"{bold_attr}>'
+ f'{fill_xml}{_font_face_xml(font_face)}</a:defRPr>'
+ f'</a:pPr><a:endParaRPr lang="{resolved_language}"/></a:p></c:txPr>'
)
@@ -380,6 +390,7 @@ def _axis_title_xml(
font_size: int,
color: str | None = None,
font_face: str | None = None,
+ primary_language: str | None = None,
) -> str:
entry = _chart_text_entry(title)
if entry is None:
@@ -390,11 +401,19 @@ def _axis_title_xml(
f'<a:solidFill><a:srgbClr val="{text_color}"/></a:solidFill>'
if text_color else ""
)
- lang = detect_text_lang(text)
+ lang = detect_text_lang(text, primary_language)
+ rtl_attr = (
+ ' rtl="1"'
+ if text_uses_rtl(text, primary_language)
+ else ''
+ )
+ run_rtl = '<a:rtl val="1"/>' if text_has_rtl_characters(text) else ''
return (
"<c:title><c:tx><c:rich><a:bodyPr/><a:lstStyle/>"
- f'<a:p><a:r><a:rPr lang="{lang}" sz="{_chart_text_entry_font_size(item, font_size)}">'
- f"{fill_xml}{_font_face_xml(_chart_text_entry_font_face(item, font_face))}</a:rPr>"
+ f'<a:p><a:pPr{rtl_attr}/><a:r><a:rPr lang="{lang}" '
+ f'sz="{_chart_text_entry_font_size(item, font_size)}">'
+ f"{fill_xml}{_font_face_xml(_chart_text_entry_font_face(item, font_face))}"
+ f"{run_rtl}</a:rPr>"
f"<a:t>{_xml_escape(text)}</a:t></a:r></a:p>"
"</c:rich></c:tx><c:layout/><c:overlay val=\"0\"/></c:title>"
)
@@ -667,7 +686,17 @@ def _text_box_xml(
if color else ""
)
bold_attr = ' b="1"' if bold else ""
- lang = detect_text_lang(text)
+ lang = detect_text_lang(text, ctx.primary_language)
+ run_rtl = '<a:rtl val="1"/>' if text_has_rtl_characters(text) else ''
+ run_properties_xml = (
+ f'{fill_xml}{_font_face_xml(font_face)}'
+ f'{run_rtl}'
+ )
+ rtl_attr = (
+ ' rtl="1"'
+ if text_uses_rtl(text, ctx.primary_language)
+ else ''
+ )
name = _xml_escape(f"Chart {role.title()} {shape_id}")
return f'''<p:sp>
<p:nvSpPr>
@@ -683,8 +712,8 @@ def _text_box_xml(
<p:txBody>
<a:bodyPr wrap="square" lIns="0" tIns="0" rIns="0" bIns="0" anchor="t" anchorCtr="0"/>
<a:lstStyle/>
-<a:p><a:pPr algn="{algn}"/>
-<a:r><a:rPr lang="{lang}" sz="{font_size}"{bold_attr}>{fill_xml}{_font_face_xml(font_face)}</a:rPr><a:t>{_xml_escape(text)}</a:t></a:r>
+<a:p><a:pPr algn="{algn}"{rtl_attr}/>
+<a:r><a:rPr lang="{lang}" sz="{font_size}"{bold_attr}>{run_properties_xml}</a:rPr><a:t>{_xml_escape(text)}</a:t></a:r>
</a:p>
</p:txBody>
</p:sp>'''
diff --git a/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_xml.py b/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_xml.py
index 12cadb4c..8ca2a59a 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_xml.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_xml.py
@@ -5,7 +5,12 @@ from __future__ import annotations
from typing import Any
from xml.etree import ElementTree as ET
-from ..drawingml.utils import detect_text_lang, _xml_escape
+from ..drawingml.utils import (
+ _xml_escape,
+ detect_text_lang,
+ text_has_rtl_characters,
+ text_uses_rtl,
+)
from .chart_data import (
_DEFAULT_CHART_COLORS,
_category_axis_is_date,
@@ -152,6 +157,7 @@ def _data_labels_xml(
font_size: int,
default_color: str | None,
default_font_face: str | None,
+ language: str | None = None,
) -> str:
if config is None:
return ""
@@ -169,7 +175,13 @@ def _data_labels_xml(
color = _hex_or_none(config.get("color")) or default_color
bold = _chart_bool(config.get("bold"), False)
font_face = _chart_text_entry_font_face(config, default_font_face)
- tx_pr_xml = _chart_tx_pr_xml(label_font_size, color, bold=bold, font_face=font_face)
+ tx_pr_xml = _chart_tx_pr_xml(
+ label_font_size,
+ color,
+ bold=bold,
+ font_face=font_face,
+ language=language,
+ )
num_fmt = _first_present(
config.get("number_format"),
config.get("numberFormat"),
@@ -218,10 +230,17 @@ def _data_labels_xml(
)
item_bold = _chart_bool(item.get("bold"), bold)
item_position_xml = f'<c:dLblPos val="{item_position}"/>' if item_position else ""
+ item_text_properties_xml = _chart_tx_pr_xml(
+ item_font_size,
+ item_color,
+ bold=item_bold,
+ font_face=item_font_face,
+ language=language,
+ )
point_label_xml += (
f'<c:dLbl><c:idx val="{idx}"/>'
f"{item_num_fmt_xml}"
- f"{_chart_tx_pr_xml(item_font_size, item_color, bold=item_bold, font_face=item_font_face)}"
+ f"{item_text_properties_xml}"
f"{item_position_xml}"
f"{_data_label_flags_xml({**config, **item})}"
"</c:dLbl>"
@@ -243,7 +262,7 @@ def _data_labels_xml(
point_label_xml += (
f'<c:dLbl><c:idx val="{idx}"/>'
f"{num_fmt_xml}"
- f"{_chart_tx_pr_xml(label_font_size, label_color, bold=bold, font_face=font_face)}"
+ f"{_chart_tx_pr_xml(label_font_size, label_color, bold=bold, font_face=font_face, language=language)}"
f"{position_xml}"
f"{flags_xml}"
"</c:dLbl>"
@@ -314,6 +333,7 @@ def _series_xml(
data_label_font_size: int = 900,
data_label_color: str | None = None,
data_label_font_face: str | None = None,
+ language: str | None = None,
category_column: int = 1,
color_start_index: int | None = None,
series_indices: list[int] | None = None,
@@ -386,6 +406,7 @@ def _series_xml(
font_size=data_label_font_size,
default_color=data_label_color,
default_font_face=data_label_font_face,
+ language=language,
)
if _series_scoped_data_labels(data_labels)
and chart_type in {"area", "bar", "column", "line"}
@@ -417,14 +438,23 @@ def _chart_title_paragraph_xml(
font_size: int,
color: str | None = None,
font_face: str | None = None,
+ primary_language: str | None = None,
) -> str:
fill_xml = (
f'<a:solidFill><a:srgbClr val="{color}"/></a:solidFill>'
if color else ""
)
- lang = detect_text_lang(text)
+ lang = detect_text_lang(text, primary_language)
+ rtl_attr = (
+ ' rtl="1"'
+ if text_uses_rtl(text, primary_language)
+ else ''
+ )
+ run_rtl = '<a:rtl val="1"/>' if text_has_rtl_characters(text) else ''
return (
- f'<a:p><a:r><a:rPr lang="{lang}" sz="{font_size}">{fill_xml}{_font_face_xml(font_face)}</a:rPr>'
+ f'<a:p><a:pPr{rtl_attr}/><a:r><a:rPr lang="{lang}" '
+ f'sz="{font_size}">{fill_xml}{_font_face_xml(font_face)}'
+ f'{run_rtl}</a:rPr>'
f"<a:t>{_xml_escape(text)}</a:t></a:r></a:p>"
)
@@ -437,6 +467,7 @@ def _chart_title_xml(
subtitle: Any = None,
subtitle_font_size: int | None = None,
font_face: str | None = None,
+ primary_language: str | None = None,
) -> str:
title_entry = _chart_text_entry(title)
subtitle_entry = _chart_text_entry(subtitle)
@@ -450,6 +481,7 @@ def _chart_title_xml(
font_size=_chart_text_entry_font_size(item, font_size),
color=_chart_text_entry_color(item, color),
font_face=_chart_text_entry_font_face(item, font_face),
+ primary_language=primary_language,
))
if subtitle_entry is not None:
text, item = subtitle_entry
@@ -458,6 +490,7 @@ def _chart_title_xml(
font_size=_chart_text_entry_font_size(item, subtitle_font_size or font_size),
color=_chart_text_entry_color(item, color),
font_face=_chart_text_entry_font_face(item, font_face),
+ primary_language=primary_language,
))
return (
"<c:title><c:tx><c:rich><a:bodyPr/><a:lstStyle/>"
@@ -473,6 +506,7 @@ def _chart_legend_xml(
font_size: int,
color: str | None = None,
font_face: str | None = None,
+ primary_language: str | None = None,
) -> str:
style = payload.get("style") if isinstance(payload.get("style"), dict) else {}
show_legend = payload.get("show_legend", style.get("show_legend", False))
@@ -493,7 +527,7 @@ def _chart_legend_xml(
return (
f'<c:legend><c:legendPos val="{position}"/><c:layout/>'
'<c:overlay val="0"/>'
- f'{_chart_tx_pr_xml(font_size, color, font_face=font_face)}'
+ f'{_chart_tx_pr_xml(font_size, color, font_face=font_face, language=primary_language)}'
'</c:legend>'
)
@@ -684,6 +718,7 @@ def _axis_pair_xml(
axes: dict[str, dict[str, Any]],
secondary: bool,
) -> str:
+ primary_language = chart_style.get("primary_language")
category_role = "secondary_category" if secondary else "category"
value_role = "secondary_value" if secondary else "value"
category = axes.get(category_role, {})
@@ -710,12 +745,14 @@ def _axis_pair_xml(
axis_font_size,
chart_style.get("text_color"),
font_face=chart_style.get("font_face"),
+ language=primary_language,
)
cat_title_xml = "" if secondary else _axis_title_xml(
_first_present(axis_titles.get("category"), axis_titles.get("x")),
font_size=axis_title_font_size,
color=chart_style.get("text_color"),
font_face=chart_style.get("font_face"),
+ primary_language=primary_language,
)
value_title_key = "secondary_value" if secondary else "value"
value_title = axis_titles.get(value_title_key)
@@ -726,6 +763,7 @@ def _axis_pair_xml(
font_size=axis_title_font_size,
color=chart_style.get("text_color"),
font_face=chart_style.get("font_face"),
+ primary_language=primary_language,
)
cat_gridlines = _axis_major_gridlines_xml(
category,
@@ -858,6 +896,7 @@ def _combo_plot_xml(
data_label_font_size=axis_font_size,
data_label_color=chart_style.get("text_color"),
data_label_font_face=chart_style.get("font_face"),
+ language=chart_style.get("primary_language"),
line_style=plot.get("line_style", "line"),
category_column=int(plot.get("category_column", 1)),
color_start_index=start_index,
@@ -875,6 +914,7 @@ def _combo_plot_xml(
font_size=axis_font_size,
default_color=chart_style.get("text_color"),
default_font_face=chart_style.get("font_face"),
+ language=chart_style.get("primary_language"),
)
if not _series_scoped_data_labels(data_labels)
else ""
@@ -1057,6 +1097,7 @@ def _chart_plot_xml(
data_label_font_size=axis_font_size,
data_label_color=chart_style.get("text_color"),
data_label_font_face=chart_style.get("font_face"),
+ language=chart_style.get("primary_language"),
)
data_labels_xml = (
_data_labels_xml(
@@ -1067,6 +1108,7 @@ def _chart_plot_xml(
font_size=axis_font_size,
default_color=chart_style.get("text_color"),
default_font_face=chart_style.get("font_face"),
+ language=chart_style.get("primary_language"),
)
if chart_type in {"area", "bar", "column", "line"}
and not _series_scoped_data_labels(chart_data.get("data_labels"))
@@ -1213,6 +1255,7 @@ def _xy_axis_xml(
chart_style: dict[str, str | None],
axes: dict[str, dict[str, Any]] | None = None,
) -> str:
+ primary_language = chart_style.get("primary_language")
normalized_axes = axes or {}
x_axis = normalized_axes.get("x", {})
y_axis = normalized_axes.get("y", {})
@@ -1221,18 +1264,21 @@ def _xy_axis_xml(
axis_font_size,
chart_style.get("text_color"),
font_face=chart_style.get("font_face"),
+ language=primary_language,
)
x_title_xml = _axis_title_xml(
_first_present(axis_titles.get("x"), axis_titles.get("category")),
font_size=axis_title_font_size,
color=chart_style.get("text_color"),
font_face=chart_style.get("font_face"),
+ primary_language=primary_language,
)
y_title_xml = _axis_title_xml(
_first_present(axis_titles.get("y"), axis_titles.get("value")),
font_size=axis_title_font_size,
color=chart_style.get("text_color"),
font_face=chart_style.get("font_face"),
+ primary_language=primary_language,
)
def value_axis_xml(
@@ -1354,6 +1400,7 @@ def _chart_xml(
chart_rels_id: str,
chart_data: dict[str, Any],
inherited_styles: dict[str, str] | None = None,
+ primary_language: str | None = None,
) -> bytes:
style = payload.get("style") if isinstance(payload.get("style"), dict) else {}
colors = (
@@ -1364,6 +1411,7 @@ def _chart_xml(
text_sizes = _chart_text_sizes(payload, elem, inherited_styles)
axis_titles = _axis_titles(payload)
chart_style = _classic_chart_style(payload, elem, inherited_styles)
+ chart_style["primary_language"] = primary_language
plot_xml = _chart_plot_xml(
chart_data,
colors,
@@ -1379,19 +1427,28 @@ def _chart_xml(
subtitle=payload.get("subtitle"),
subtitle_font_size=text_sizes["subtitle"],
font_face=chart_style.get("font_face"),
+ primary_language=primary_language,
)
legend_xml = _chart_legend_xml(
payload,
font_size=text_sizes["legend"],
color=chart_style.get("text_color"),
font_face=chart_style.get("font_face"),
+ primary_language=primary_language,
+ )
+ chart_language = primary_language or "en-US"
+ base_text_properties_xml = _chart_tx_pr_xml(
+ text_sizes["base"],
+ chart_style.get("text_color"),
+ font_face=chart_style.get("font_face"),
+ language=primary_language,
)
xml = f'''<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<c:chartSpace xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart"
xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<c:date1904 val="0"/>
-<c:lang val="en-US"/>
+<c:lang val="{_xml_escape(chart_language)}"/>
<c:chart>
{title_xml}
<c:plotArea><c:layout/>{plot_xml}{_chart_area_sp_pr_xml(chart_style.get("plot_fill"))}</c:plotArea>
@@ -1400,7 +1457,7 @@ def _chart_xml(
<c:dispBlanksAs val="gap"/>
</c:chart>
{_chart_area_sp_pr_xml(chart_style.get("chart_fill"))}
-{_chart_tx_pr_xml(text_sizes["base"], chart_style.get("text_color"), font_face=chart_style.get("font_face"))}
+{base_text_properties_xml}
<c:externalData r:id="{chart_rels_id}"><c:autoUpdate val="0"/></c:externalData>
</c:chartSpace>'''
return xml.encode("utf-8")
diff --git a/skills/ppt-master/scripts/svg_to_pptx/native_objects/table.py b/skills/ppt-master/scripts/svg_to_pptx/native_objects/table.py
index 07bb0b57..28e1e332 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/native_objects/table.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/native_objects/table.py
@@ -10,7 +10,13 @@ from .marker_attributes import native_import_source
from ..drawingml.context import ConvertContext, ShapeResult
from ..drawingml.theme_colors import ThemeColorSpec, color_node_xml
-from ..drawingml.utils import _xml_escape, detect_text_lang, font_px_to_hpt
+from ..drawingml.utils import (
+ _xml_escape,
+ detect_text_lang,
+ font_px_to_hpt,
+ text_has_rtl_characters,
+ text_uses_rtl,
+)
from .chart_style import _font_face_xml
from .marker_common import (
TABLE_URI,
@@ -37,6 +43,7 @@ def _table_text_run(
font_size: int | None,
font_face: str | None,
language: str | None,
+ default_language: str | None,
theme_color_spec: ThemeColorSpec | None,
italic: bool | None = None,
underline: bool | None = None,
@@ -55,7 +62,7 @@ def _table_text_run(
f' strike="{"sngStrike" if strike else "noStrike"}"'
if strike is not None else ""
)
- resolved_language = language or detect_text_lang(text)
+ resolved_language = language or detect_text_lang(text, default_language)
language_attr = f' lang="{_xml_escape(resolved_language)}"'
alt_language_attr = (
f' altLang="{_xml_escape(alt_language)}"' if alt_language else ""
@@ -69,20 +76,40 @@ def _table_text_run(
font_xml = (
f'<a:latin typeface="{escaped_face}"/>'
f'<a:ea typeface="{escaped_face}"/>'
+ f'<a:cs typeface="{escaped_face}"/>'
)
else:
font_xml = _font_face_xml(font_face)
+ rtl_xml = '<a:rtl val="1"/>' if text_has_rtl_characters(text) else ''
space_attr = ' xml:space="preserve"' if text != text.strip() else ""
return (
f'<a:r><a:rPr{language_attr}{alt_language_attr}{size_attr}{bold_attr}'
f'{italic_attr}{underline_attr}{strike_attr}>'
f'{color_xml}'
f'{font_xml}'
+ f'{rtl_xml}'
"</a:rPr>"
f"<a:t{space_attr}>{_xml_escape(text)}</a:t></a:r>"
)
+def _table_paragraph_properties(
+ align: str,
+ *,
+ emit_align: bool,
+ text: str,
+ language: str | None,
+) -> str:
+ """Build table paragraph properties with project-aware direction."""
+ attrs = []
+ if emit_align:
+ attrs.append(f'algn="{align}"')
+ if text_uses_rtl(text, language):
+ attrs.append('rtl="1"')
+ suffix = f" {' '.join(attrs)}" if attrs else ''
+ return f'<a:pPr{suffix}/>'
+
+
def _cell_payload(value: Any) -> dict[str, Any]:
if isinstance(value, dict):
return value
@@ -951,8 +978,12 @@ def _build_native_table(elem: ET.Element, ctx: ConvertContext, payload: dict[str
"" if cell_data.get("text") is None
else str(cell_data.get("text"))
)
- paragraph_props = (
- f'<a:pPr algn="{align}"/>' if align != "l" else "<a:pPr/>"
+ default_language = language or ctx.primary_language
+ paragraph_props = _table_paragraph_properties(
+ align,
+ emit_align=align != "l",
+ text=text,
+ language=default_language,
)
text_run_xml = _table_text_run(
text,
@@ -961,6 +992,7 @@ def _build_native_table(elem: ET.Element, ctx: ConvertContext, payload: dict[str
font_size=cell_font_size,
font_face=font_face,
language=language,
+ default_language=ctx.primary_language,
theme_color_spec=ctx.theme_color_spec,
)
paragraphs_xml = (
@@ -970,10 +1002,19 @@ def _build_native_table(elem: ET.Element, ctx: ConvertContext, payload: dict[str
paragraph_parts: list[str] = []
for paragraph in paragraphs:
paragraph_align = paragraph.align or align
- paragraph_props = (
- f'<a:pPr algn="{paragraph_align}"/>'
- if paragraph.align is not None or paragraph_align != "l"
- else "<a:pPr/>"
+ paragraph_text = (
+ paragraph.text
+ if paragraph.runs is None
+ else ''.join(run.text for run in paragraph.runs)
+ )
+ paragraph_props = _table_paragraph_properties(
+ paragraph_align,
+ emit_align=(
+ paragraph.align is not None
+ or paragraph_align != "l"
+ ),
+ text=paragraph_text,
+ language=language or ctx.primary_language,
)
if paragraph.runs is None:
text_run_xml = _table_text_run(
@@ -983,6 +1024,7 @@ def _build_native_table(elem: ET.Element, ctx: ConvertContext, payload: dict[str
font_size=cell_font_size,
font_face=font_face,
language=language,
+ default_language=ctx.primary_language,
theme_color_spec=ctx.theme_color_spec,
)
else:
@@ -998,6 +1040,7 @@ def _build_native_table(elem: ET.Element, ctx: ConvertContext, payload: dict[str
),
font_face=run.font_family or font_face,
language=run.lang or language,
+ default_language=ctx.primary_language,
theme_color_spec=ctx.theme_color_spec,
italic=run.italic,
underline=run.underline,
diff --git a/skills/ppt-master/scripts/svg_to_pptx/pptx_package/builder.py b/skills/ppt-master/scripts/svg_to_pptx/pptx_package/builder.py
index b118e8d8..228726cf 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/pptx_package/builder.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/pptx_package/builder.py
@@ -54,6 +54,7 @@ from pptx_opc_validation import (
resolve_internal_opc_target as _resolve_internal_opc_target,
verify_internal_relationships,
)
+from language_tags import normalize_language_tag
from ..animation_config import (
MorphPair,
@@ -3917,7 +3918,10 @@ _NOTES_MASTER_REL_TYPE = (
)
-def _ensure_notes_master(extract_dir: Path) -> None:
+def _ensure_notes_master(
+ extract_dir: Path,
+ primary_language: str | None = None,
+) -> None:
"""Create notesMaster parts and wire them into the presentation package."""
ppt_dir = extract_dir / 'ppt'
notes_masters_dir = ppt_dir / 'notesMasters'
@@ -3925,7 +3929,10 @@ def _ensure_notes_master(extract_dir: Path) -> None:
notes_master_path = notes_masters_dir / 'notesMaster1.xml'
if not notes_master_path.exists():
- notes_master_path.write_text(create_notes_master_xml(), encoding='utf-8')
+ notes_master_path.write_text(
+ create_notes_master_xml(primary_language),
+ encoding='utf-8',
+ )
theme_dir = ppt_dir / 'theme'
theme_dir.mkdir(exist_ok=True)
@@ -4624,6 +4631,7 @@ def create_pptx_with_native_svg(
animation_resource_root: Path | None = None,
transition_effect_options: dict[str, object] | None = None,
text_flow: str | None = None,
+ primary_language: str | None = None,
) -> bool:
"""Create a PPTX file with native DrawingML shapes.
@@ -4700,6 +4708,8 @@ def create_pptx_with_native_svg(
callers may omit it; other routes ignore this value.
theme_color_spec: Locked project color scheme for context-aware
flat/structured theme inheritance. Preserve mode ignores this value.
+ primary_language: Canonical BCP-47 deck content language. ``None``
+ preserves legacy per-run language detection.
structured_baseline: Obsolete compatibility argument; must remain false.
baseline_layout_specs: Obsolete compatibility argument; must remain None.
@@ -4707,6 +4717,8 @@ def create_pptx_with_native_svg(
Whether all slides were successfully created.
"""
text_flow = resolve_text_flow(text_flow, merge_paragraphs)
+ if primary_language is not None:
+ primary_language = normalize_language_tag(primary_language)
public_svg_files = list(svg_files)
definition_svg_files = list(layout_definition_files or [])
public_slide_names = [path.stem for path in public_svg_files]
@@ -5175,6 +5187,7 @@ def create_pptx_with_native_svg(
animation_group_overrides=converter_group_overrides,
theme_font_spec=active_theme_font_spec,
theme_color_spec=active_theme_color_spec,
+ primary_language=primary_language,
promote_background=pptx_structure != "structured",
trace_out=conversion_trace
if conversion_trace is not None
@@ -5436,13 +5449,17 @@ def create_pptx_with_native_svg(
notes_content = notes.get(svg_stem, '') if notes else ''
notes_text = markdown_to_plain_text(notes_content) if notes_content else ''
if notes_text:
- _ensure_notes_master(extract_dir)
+ _ensure_notes_master(extract_dir, primary_language)
notes_slides_dir = extract_dir / 'ppt' / 'notesSlides'
notes_slides_dir.mkdir(exist_ok=True)
notes_xml_path = notes_slides_dir / f'notesSlide{slide_num}.xml'
- notes_xml = create_notes_slide_xml(slide_num, notes_text)
+ notes_xml = create_notes_slide_xml(
+ slide_num,
+ notes_text,
+ primary_language,
+ )
with open(notes_xml_path, 'w', encoding='utf-8') as f:
f.write(notes_xml)
@@ -5850,7 +5867,15 @@ def create_pptx_with_native_svg(
# author, 2013 dates, "generated using python-pptx", Slides=0) with
# accurate, tool-neutral document properties.
pres_format = _presentation_format(width_emu, height_emu)
- _stamp_docprops(extract_dir, public_slide_count, pres_format, doc_metadata)
+ effective_doc_metadata = dict(doc_metadata or {})
+ if primary_language is not None:
+ effective_doc_metadata['language'] = primary_language
+ _stamp_docprops(
+ extract_dir,
+ public_slide_count,
+ pres_format,
+ effective_doc_metadata,
+ )
# Repackage PPTX to a temporary file first. The public output path is
# replaced only after every slide and relationship has succeeded.
diff --git a/skills/ppt-master/scripts/svg_to_pptx/pptx_package/cli.py b/skills/ppt-master/scripts/svg_to_pptx/pptx_package/cli.py
index 3a71b8ca..144c317f 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/pptx_package/cli.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/pptx_package/cli.py
@@ -20,6 +20,10 @@ if str(_SCRIPTS_DIR) not in sys.path:
sys.path.insert(0, str(_SCRIPTS_DIR))
from console_encoding import configure_utf8_stdio # noqa: E402
+from language_tags import ( # noqa: E402
+ LanguageTagError,
+ normalize_language_tag,
+)
from native_payloads import PAYLOAD_STORE_RELATIVE_PATH # noqa: E402
from pptx_animations import ( # noqa: E402
ANIMATIONS,
@@ -599,6 +603,28 @@ def _declared_canvas_viewbox(project_path: Path) -> str | None:
return value.strip() if isinstance(value, str) and value.strip() else None
+def _declared_primary_language(project_path: Path) -> str | None:
+ """Return the canonical content language declared by the execution lock."""
+ lock_path = project_path / 'spec_lock.md'
+ try:
+ from update_spec import parse_lock
+
+ lock = parse_lock(lock_path)
+ except (OSError, ValueError):
+ return None
+ communication = lock.get('communication', {})
+ value = communication.get('primary_language')
+ if not isinstance(value, str) or not value.strip():
+ return None
+ try:
+ return normalize_language_tag(value)
+ except LanguageTagError as exc:
+ raise LanguageTagError(
+ 'spec_lock.md communication.primary_language '
+ f'is invalid: {exc}'
+ ) from exc
+
+
def _print_structure_contract_error(
mode: str | None,
*,
@@ -1159,6 +1185,20 @@ Recorded narration:
if args.quick_test
else _declared_pptx_structure_mode(project_path)
)
+ primary_language = None
+ if not args.quick_test:
+ try:
+ primary_language = _declared_primary_language(project_path)
+ except LanguageTagError as exc:
+ print(f"Error: {exc}", file=sys.stderr)
+ return 1
+ if primary_language is None:
+ print(
+ "Warning: spec_lock.md has no "
+ "communication.primary_language; using legacy per-run "
+ "language detection.",
+ file=sys.stderr,
+ )
if pptx_structure in _LEGACY_PPTX_STRUCTURE_MODES:
_print_structure_contract_error(pptx_structure)
return 1
@@ -1857,6 +1897,7 @@ Recorded narration:
theme_font_spec=theme_font_spec,
master_text_style_spec=master_text_style_spec,
theme_color_spec=theme_color_spec,
+ primary_language=primary_language,
)
if verbose:
diff --git a/skills/ppt-master/scripts/svg_to_pptx/pptx_package/notes.py b/skills/ppt-master/scripts/svg_to_pptx/pptx_package/notes.py
index b5c9cf6f..ef487089 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/pptx_package/notes.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/pptx_package/notes.py
@@ -4,7 +4,13 @@ from __future__ import annotations
import re
-from ..drawingml.utils import detect_text_lang
+from language_tags import normalize_language_tag
+
+from ..drawingml.utils import (
+ detect_text_lang,
+ text_has_rtl_characters,
+ text_uses_rtl,
+)
def markdown_to_plain_text(md_content: str) -> str:
@@ -54,16 +60,27 @@ def markdown_to_plain_text(md_content: str) -> str:
return '\n'.join(result).strip()
-def create_notes_slide_xml(slide_num: int, notes_text: str) -> str:
+def create_notes_slide_xml(
+ slide_num: int,
+ notes_text: str,
+ primary_language: str | None = None,
+) -> str:
"""Create notes slide XML.
Args:
slide_num: Slide number.
notes_text: Notes text in plain text format.
+ primary_language: Canonical BCP-47 deck language, when available.
Returns:
Notes slide XML string.
"""
+ primary_language = (
+ normalize_language_tag(primary_language)
+ if primary_language is not None
+ else None
+ )
+ default_language = primary_language or 'en-US'
notes_text = (notes_text
.replace('&', '&amp;')
.replace('<', '&lt;')
@@ -72,20 +89,40 @@ def create_notes_slide_xml(slide_num: int, notes_text: str) -> str:
paragraphs: list[str] = []
for para in notes_text.split('\n'):
if para.strip():
- lang = detect_text_lang(para)
+ lang = detect_text_lang(para, primary_language)
+ paragraph_rtl = ' rtl="1"' if text_uses_rtl(
+ para,
+ primary_language,
+ ) else ''
+ run_rtl = (
+ '<a:rtl val="1"/>'
+ if text_has_rtl_characters(para)
+ else ''
+ )
paragraphs.append(f'''<a:p>
+ <a:pPr{paragraph_rtl}/>
<a:r>
- <a:rPr lang="{lang}" dirty="0"/>
+ <a:rPr lang="{lang}" dirty="0">{run_rtl}</a:rPr>
<a:t>{para}</a:t>
</a:r>
</a:p>''')
else:
- paragraphs.append('<a:p><a:endParaRPr lang="en-US" dirty="0"/></a:p>')
+ paragraph_rtl = (
+ ' rtl="1"'
+ if primary_language and text_uses_rtl('', primary_language)
+ else ''
+ )
+ paragraphs.append(
+ f'<a:p><a:pPr{paragraph_rtl}/>'
+ f'<a:endParaRPr lang="{default_language}" dirty="0"/></a:p>'
+ )
paragraphs_xml = (
'\n '.join(paragraphs)
if paragraphs
- else '<a:p><a:endParaRPr lang="en-US" dirty="0"/></a:p>'
+ else (
+ f'<a:p><a:endParaRPr lang="{default_language}" dirty="0"/></a:p>'
+ )
)
return f'''<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
@@ -160,9 +197,15 @@ def create_notes_slide_rels_xml(slide_num: int) -> str:
</Relationships>'''
-def create_notes_master_xml() -> str:
+def create_notes_master_xml(primary_language: str | None = None) -> str:
"""Create a minimal PowerPoint-compatible notes master XML."""
- return '''<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+ language = (
+ normalize_language_tag(primary_language)
+ if primary_language is not None
+ else 'en-US'
+ )
+ paragraph_rtl = ' rtl="1"' if text_uses_rtl('', language) else ''
+ return f'''<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<p:notesMaster xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">
@@ -194,7 +237,7 @@ def create_notes_master_xml() -> str:
</a:xfrm>
<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>
</p:spPr>
- <p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang="en-US"/></a:p></p:txBody>
+ <p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:pPr{paragraph_rtl}/><a:endParaRPr lang="{language}"/></a:p></p:txBody>
</p:sp>
<p:sp>
<p:nvSpPr>
@@ -209,7 +252,7 @@ def create_notes_master_xml() -> str:
</a:xfrm>
<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>
</p:spPr>
- <p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang="en-US"/></a:p></p:txBody>
+ <p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:pPr{paragraph_rtl}/><a:endParaRPr lang="{language}"/></a:p></p:txBody>
</p:sp>
<p:sp>
<p:nvSpPr>
@@ -238,7 +281,7 @@ def create_notes_master_xml() -> str:
</a:xfrm>
<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>
</p:spPr>
- <p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang="en-US"/></a:p></p:txBody>
+ <p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:pPr{paragraph_rtl}/><a:endParaRPr lang="{language}"/></a:p></p:txBody>
</p:sp>
<p:sp>
<p:nvSpPr>
@@ -253,7 +296,7 @@ def create_notes_master_xml() -> str:
</a:xfrm>
<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>
</p:spPr>
- <p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang="en-US"/></a:p></p:txBody>
+ <p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:pPr{paragraph_rtl}/><a:endParaRPr lang="{language}"/></a:p></p:txBody>
</p:sp>
<p:sp>
<p:nvSpPr>
@@ -268,7 +311,7 @@ def create_notes_master_xml() -> str:
</a:xfrm>
<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>
</p:spPr>
- <p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang="en-US"/></a:p></p:txBody>
+ <p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:pPr{paragraph_rtl}/><a:endParaRPr lang="{language}"/></a:p></p:txBody>
</p:sp>
</p:spTree>
</p:cSld>
@@ -278,8 +321,8 @@ def create_notes_master_xml() -> str:
hlink="hlink" folHlink="folHlink"/>
<p:hf/>
<p:notesStyle>
- <a:lvl1pPr marL="0" algn="l">
- <a:defRPr sz="1200" lang="en-US"/>
+ <a:lvl1pPr marL="0" algn="l"{paragraph_rtl}>
+ <a:defRPr sz="1200" lang="{language}"/>
</a:lvl1pPr>
</p:notesStyle>
</p:notesMaster>'''
diff --git a/skills/ppt-master/templates/design_spec_reference.md b/skills/ppt-master/templates/design_spec_reference.md
index 615f1a67..6409dd89 100644
--- a/skills/ppt-master/templates/design_spec_reference.md
+++ b/skills/ppt-master/templates/design_spec_reference.md
@@ -33,6 +33,7 @@ Start with this exact heading order:
| Project Name | <resolved project name> |
| Canvas Format | <canonical format and dimensions> |
| Page Count | <exact final count matching §IX> |
+| Primary Language | <confirmed canonical BCP-47 content tag> |
| Target Audience | <confirmed audience> |
| Communication Intent | <confirmed intent, including priority or sequence> |
| Desired Audience Outcome | <confirmed observable outcome> |
diff --git a/skills/ppt-master/templates/scaffolds/spec_lock.md b/skills/ppt-master/templates/scaffolds/spec_lock.md
index f8706ee6..e66e3bad 100644
--- a/skills/ppt-master/templates/scaffolds/spec_lock.md
+++ b/skills/ppt-master/templates/scaffolds/spec_lock.md
@@ -6,6 +6,7 @@
- format: {{CANVAS_NAME}}
## communication
+- primary_language: [fill]
- audience:
- objective:
- core_message:
diff --git a/skills/ppt-master/templates/schemas/spec_lock.schema.json b/skills/ppt-master/templates/schemas/spec_lock.schema.json
index 9f6cb4aa..bba03902 100644
--- a/skills/ppt-master/templates/schemas/spec_lock.schema.json
+++ b/skills/ppt-master/templates/schemas/spec_lock.schema.json
@@ -94,11 +94,15 @@
"core_message"
],
"allowed_fields": [
+ "primary_language",
"audience",
"objective",
"core_message",
"consumption_mode"
],
+ "field_patterns": {
+ "primary_language": "^(?!und(?:-|$))(?:(?:zh(?:-[a-z]{3}){0,3}(?:-[A-Z][a-z]{3}(?:-(?:[A-Z]{2}|[0-9]{3}))?|-(?:[A-Z]{2}|[0-9]{3})))|(?:(?!zh(?:-|$))(?:[a-z]{2,3}(?:-[a-z]{3}){0,3}|[a-z]{4}|[a-z]{5,8})(?:-[A-Z][a-z]{3})?(?:-(?:[A-Z]{2}|[0-9]{3}))?))(?:-(?:[a-z0-9]{5,8}|[0-9][a-z0-9]{3}))*(?:-[0-9a-wy-z](?:-[a-z0-9]{2,8})+)*(?:-x(?:-[a-z0-9]{1,8})+)?$"
+ },
"field_enums": {
"consumption_mode": ["text", "balanced", "presentation"]
}
diff --git a/skills/ppt-master/templates/spec_lock_reference.md b/skills/ppt-master/templates/spec_lock_reference.md
index 7314e514..c72b7b4c 100644
--- a/skills/ppt-master/templates/spec_lock_reference.md
+++ b/skills/ppt-master/templates/spec_lock_reference.md
@@ -1,6 +1,6 @@
# Execution Lock Structure
-`spec_lock.md` is the compact execution contract from audited `design_spec.md` plus current context. It keeps stable cross-page anchors and routes, not every page-local paint or typeface. This file owns authoring structure; [`schemas/spec_lock.schema.json`](./schemas/spec_lock.schema.json) owns grammar.
+`spec_lock.md` projects cross-page anchors/routes from audited `design_spec.md` and context; it excludes local paint/type. This file owns structure; [`schemas/spec_lock.schema.json`](./schemas/spec_lock.schema.json) owns grammar.
## 1. Author the complete artifact
@@ -19,7 +19,7 @@ After Generate Step 4 Gate 1, read the completed Design Spec and current page/re
| Section | Required keys | Notes |
| --- | --- | --- |
| `canvas` | `viewBox`, `format` | `format` is the canonical display name (for example `PPT 16:9`); `viewBox` is the matching exact geometry |
-| `communication` | `audience`, `objective`, `core_message` | Compact execution projection; `objective` combines intent and audience outcome; `consumption_mode` is optional off PPT canvases |
+| `communication` | `primary_language`, `audience`, `objective`, `core_message` | New lock: canonical BCP-47; old lock may omit it. Reject `und` and Chinese without script/region. `objective` merges intent/outcome; `consumption_mode` is optional off PPT |
| `mode` | `mode` | Preset or `custom` |
| `visual_style` | `visual_style` | Preset or `custom` |
| `colors` | Stable semantic color roles | Core identity and recurring roles only; contextual SVG paints need no row; `image_rendering` appears only for AI images |