Skip to content

end to end app store screenshot creation using AI

localisation fixes

Parth Jadhav3d46149ab366
diff --git a/skills/app-store-screenshots/SKILL.md b/skills/app-store-screenshots/SKILL.md
index 982c940..4a31928 100644
--- a/skills/app-store-screenshots/SKILL.md
+++ b/skills/app-store-screenshots/SKILL.md
@@ -254,7 +254,16 @@ Shrink the slide to ~160px wide (App Store search-result size). Squint. Can you
## Step 4: Localization
-The editor exposes a locale dropdown; switching it changes the `locale` field on the project state. Screenshots are looked up under `public/screenshots/.../{locale}/...`, so put localized PNGs in matching folders.
+**Always confirm the language list with the user before scaffolding** — even if they didn't volunteer it. Ask: _"Should screenshots be localized? If yes, which locales? (e.g. en, de, es, pt, ja)."_ Default to English-only if they say no or skip.
+
+The project state file (`app-store-screenshots.json`) carries a `locales: string[]` field — the list of locale codes the project targets. The editor reads this to decide:
+- The locale dropdown in the toolbar is **hidden** when `locales.length <= 1`.
+- The dropdown's options come from this list (not a hardcoded set).
+- The **Export bundle** loops every locale in the list × every required size.
+
+**After scaffolding, edit `app-store-screenshots.json` to set `locales` to the user's chosen list, e.g.** `"locales": ["en", "de", "ja"]`. Also set `"locale": "en"` (or whichever is the source-of-truth language) so the editor opens on it.
+
+The editor stores headlines and labels per-locale on each slide — switch to a locale and type to fill it in; unfilled locales fall back to `en` at preview time. Screenshots are a single string per slide; put `{locale}` anywhere in the path and the editor substitutes the active locale at render and export (e.g. `/screenshots/iphone/{locale}/01.png`).
- Don't literally translate — rewrite for the target market.
- Re-check line breaks per locale; German/French/Portuguese often need shorter claims.
@@ -262,7 +271,9 @@ The editor exposes a locale dropdown; switching it changes the `locale` field on
## Step 5: Export Time
-Inside the editor, the user picks a device, picks a target size from the dropdown, and hits **Export all**. PNGs download with zero-padded numbered filenames. Repeat per device.
+Inside the editor, the user picks a device, then hits **Export bundle**. A single zip downloads with every required size × every project locale for that device, organized as `<platform>/<device>/<WxH>/<locale>/NN-<layout>.png`. Repeat per device.
+
+Project locales come from `app-store-screenshots.json` `locales` field — set during scaffolding (Step 4). Single-locale projects produce a flat per-size structure with just the one locale folder.
If exports come out blank or with black screen rectangles:
- Verify source screenshots are RGB (not RGBA). The template flattens via `objectFit: cover`, but truly transparent sources can still produce black regions.
diff --git a/skills/app-store-screenshots/template/src/components/editor/inspector.tsx b/skills/app-store-screenshots/template/src/components/editor/inspector.tsx
index e3d1a0b..0be1cc7 100644
--- a/skills/app-store-screenshots/template/src/components/editor/inspector.tsx
+++ b/skills/app-store-screenshots/template/src/components/editor/inspector.tsx
@@ -4,13 +4,22 @@ import { ArrowDownToLine, ArrowUpToLine, ChevronDown, ChevronUp, RotateCw } from
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "@/components/ui/select";
import { Textarea } from "@/components/ui/textarea";
-import { LAYOUT_HINT } from "@/lib/constants";
-import type { ElementId, ElementTransform, Slide } from "@/lib/types";
+import { LAYOUT_HINT, LAYOUT_LABEL } from "@/lib/constants";
+import { pickText, writeLocalized } from "@/lib/locale";
+import type { ElementId, ElementTransform, Slide, SlideLayout } from "@/lib/types";
import { ScreenshotPicker } from "./screenshot-picker";
type Props = {
slide: Slide;
+ locale: string;
selectedElementId: ElementId | null;
onChange: (patch: Partial<Slide>) => void;
};
@@ -21,25 +30,70 @@ const ELEMENT_LABEL: Record<ElementId, string> = {
deviceSecondary: "Back device",
};
-export function Inspector({ slide, selectedElementId, onChange }: Props) {
+export function Inspector({ slide, locale, selectedElementId, onChange }: Props) {
const isFeatureGraphic = slide.layout === "feature-graphic";
const isNoDevice = slide.layout === "no-device";
+ const localeLabel = slide.label?.[locale] ?? "";
+ const localeHeadline = slide.headline?.[locale] ?? "";
+ // When the active locale is empty, surface the fallback (typically en) as
+ // the placeholder so the user sees what they're translating from.
+ const headlineDefault = isFeatureGraphic ? "Your tagline." : "One idea\nper slide.";
+ const labelPlaceholder = localeLabel ? "FEATURE 01" : pickText(slide.label, locale) || "FEATURE 01";
+ const headlinePlaceholder = localeHeadline
+ ? headlineDefault
+ : pickText(slide.headline, locale) || headlineDefault;
+
+ function setLocaleField(key: "label" | "headline", value: string) {
+ onChange({ [key]: writeLocalized(slide[key], locale, value) } as Partial<Slide>);
+ }
return (
<div className="flex h-full flex-col">
<div className="border-b p-3">
- <h2 className="text-sm font-semibold">Slide settings</h2>
+ <div className="flex items-baseline justify-between gap-2">
+ <h2 className="text-sm font-semibold">Slide settings</h2>
+ <span className="text-[10px] uppercase tracking-wide text-muted-foreground">
+ editing · {locale.toUpperCase()}
+ </span>
+ </div>
<p className="text-xs text-muted-foreground">{LAYOUT_HINT[slide.layout]}</p>
</div>
<div className="flex-1 space-y-4 overflow-y-auto p-3">
+ <div className="space-y-1.5">
+ <Label className="text-xs">Layout</Label>
+ <Select
+ value={slide.layout}
+ onValueChange={(layout) => {
+ const next = layout as SlideLayout;
+ onChange({
+ layout: next,
+ transforms: undefined,
+ screenshotSecondary:
+ next === "two-devices" ? slide.screenshotSecondary || slide.screenshot : undefined,
+ });
+ }}
+ >
+ <SelectTrigger>
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ {Object.entries(LAYOUT_LABEL).map(([layout, label]) => (
+ <SelectItem key={layout} value={layout}>
+ {label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ </div>
+
{!isFeatureGraphic && (
<div className="space-y-1.5">
<Label className="text-xs">Label</Label>
<Input
- value={slide.label}
- onChange={(e) => onChange({ label: e.target.value })}
- placeholder="FEATURE 01"
+ value={localeLabel}
+ onChange={(e) => setLocaleField("label", e.target.value)}
+ placeholder={labelPlaceholder}
/>
</div>
)}
@@ -50,10 +104,10 @@ export function Inspector({ slide, selectedElementId, onChange }: Props) {
<span className="text-[10px] text-muted-foreground">newline = break</span>
</div>
<Textarea
- value={slide.headline}
- onChange={(e) => onChange({ headline: e.target.value })}
+ value={localeHeadline}
+ onChange={(e) => setLocaleField("headline", e.target.value)}
rows={3}
- placeholder={isFeatureGraphic ? "Your tagline." : "One idea\nper slide."}
+ placeholder={headlinePlaceholder}
/>
</div>
diff --git a/skills/app-store-screenshots/template/src/components/editor/preview-stage.tsx b/skills/app-store-screenshots/template/src/components/editor/preview-stage.tsx
index bd50bcb..88729f9 100644
--- a/skills/app-store-screenshots/template/src/components/editor/preview-stage.tsx
+++ b/skills/app-store-screenshots/template/src/components/editor/preview-stage.tsx
@@ -16,6 +16,7 @@ type Props = {
device: Device;
orientation: Orientation;
theme: Theme;
+ locale: string;
appName?: string;
appIcon?: string;
selectedElementId: ElementId | null;
@@ -32,6 +33,7 @@ export function PreviewStage({
device,
orientation,
theme,
+ locale,
appName,
appIcon,
selectedElementId,
@@ -82,6 +84,7 @@ export function PreviewStage({
device={device}
orientation={orientation}
theme={theme}
+ locale={locale}
appName={appName}
appIcon={appIcon}
editable
diff --git a/skills/app-store-screenshots/template/src/components/editor/screenshot-editor.tsx b/skills/app-store-screenshots/template/src/components/editor/screenshot-editor.tsx
index 8a75adc..72aae54 100644
--- a/skills/app-store-screenshots/template/src/components/editor/screenshot-editor.tsx
+++ b/skills/app-store-screenshots/template/src/components/editor/screenshot-editor.tsx
@@ -8,8 +8,9 @@ import {
supportsLandscape,
THEMES,
} from "@/lib/constants";
-import { nid } from "@/lib/defaults";
+import { detectPlatform, nid } from "@/lib/defaults";
import { preloadImages } from "@/lib/image-cache";
+import { resolveScreenshot, writeLocalized } from "@/lib/locale";
import { useProject } from "@/lib/storage";
import type { Device, ElementId, Slide } from "@/lib/types";
import { Inspector } from "./inspector";
@@ -22,9 +23,9 @@ export function ScreenshotEditor() {
const { state, setState, hydrated, savedAt, saveError, reset, resetDevice, undo, redo } = useProject();
const [activeSlideId, setActiveSlideId] = React.useState<string | null>(null);
const [selectedElementId, setSelectedElementId] = React.useState<ElementId | null>(null);
- const [sizeIdx, setSizeIdx] = React.useState(0);
const [exporting, setExporting] = React.useState<string | null>(null);
const [ready, setReady] = React.useState(false);
+ const [exportLocaleOverride, setExportLocaleOverride] = React.useState<string | null>(null);
const exportRefs = React.useRef<Record<string, HTMLDivElement | null>>({});
const currentSlides = state.slidesByDevice[state.device] || [];
@@ -43,10 +44,6 @@ export function ScreenshotEditor() {
}
}, [hydrated, currentSlides, activeSlide]);
- React.useEffect(() => {
- setSizeIdx(0);
- }, [state.device, state.orientation]);
-
React.useEffect(() => {
if (!supportsLandscape(state.device) && state.orientation !== "portrait") {
setState((p) => ({ ...p, orientation: "portrait" }));
@@ -57,15 +54,20 @@ export function ScreenshotEditor() {
const paths = new Set<string>();
paths.add("/mockup.png");
if (state.appIcon) paths.add(state.appIcon);
- for (const dev of Object.values(state.slidesByDevice)) {
- for (const s of dev) {
- if (s.screenshot && !s.screenshot.startsWith("data:")) paths.add(s.screenshot);
- if (s.screenshotSecondary && !s.screenshotSecondary.startsWith("data:"))
- paths.add(s.screenshotSecondary);
+ // Preload every locale variant so bulk export doesn't race image loads.
+ const allSlides: Slide[] = Object.values(state.slidesByDevice).flat();
+ for (const s of allSlides) {
+ for (const raw of [s.screenshot, s.screenshotSecondary]) {
+ if (!raw || raw.startsWith("data:")) continue;
+ if (raw.includes("{locale}")) {
+ for (const loc of state.locales) paths.add(resolveScreenshot(raw, loc));
+ } else {
+ paths.add(raw);
+ }
}
}
return Array.from(paths).sort();
- }, [state.slidesByDevice, state.appIcon]);
+ }, [state.slidesByDevice, state.appIcon, state.locales]);
const assetSig = assetPaths.join("|");
React.useEffect(() => {
@@ -168,6 +170,15 @@ export function ScreenshotEditor() {
[setState],
);
+ const patchLocalized = React.useCallback(
+ (slide: Slide, key: "label" | "headline", value: string) => {
+ patchSlide(slide.id, {
+ [key]: writeLocalized(slide[key], state.locale, value),
+ } as Partial<Slide>);
+ },
+ [patchSlide, state.locale],
+ );
+
const duplicateSlide = React.useCallback(
(id: string) => {
let newId: string | null = null;
@@ -249,16 +260,27 @@ export function ScreenshotEditor() {
// ---------- Export ----------
- const currentSizes = getExportSizes(state.device, state.orientation);
+ // Wait two animation frames so React's render → browser layout/paint of the
+ // off-screen container settles before html-to-image snapshots it. One frame
+ // is occasionally not enough on slower machines.
+ const waitForPaint = () =>
+ new Promise<void>((resolve) => {
+ requestAnimationFrame(() => requestAnimationFrame(() => resolve()));
+ });
async function exportAll() {
- const size = currentSizes[sizeIdx];
- if (!size) return;
if (!currentSlides.length) {
toast.error("No slides to export");
return;
}
+ const sizes = getExportSizes(state.device, state.orientation);
+ if (!sizes.length) {
+ toast.error("Nothing to export");
+ return;
+ }
+ const locales = state.locales;
+
// Make sure custom fonts are loaded before snapshot so typography in PNG
// matches what's on screen.
if (typeof document !== "undefined" && document.fonts && document.fonts.ready) {
@@ -270,38 +292,51 @@ export function ScreenshotEditor() {
}
const { cW, cH } = getCanvas(state.device, state.orientation);
- // Render the export wrapper as a uniform scale of the design canvas so
- // smaller export sizes downscale instead of being cropped by html-to-image.
- const scale = Math.min(size.w / cW, size.h / cH);
-
+ const platform = detectPlatform(state.device);
const zip = new JSZip();
+ const totalUnits = sizes.length * locales.length * currentSlides.length;
+ let unit = 0;
let okCount = 0;
let failed = 0;
const errors: string[] = [];
- for (let i = 0; i < currentSlides.length; i++) {
- const slide = currentSlides[i];
- setExporting(`${i + 1}/${currentSlides.length}`);
- const el = exportRefs.current[slide.id];
- if (!el) {
- failed += 1;
- errors.push(`Slide ${i + 1}: render target missing`);
- continue;
- }
- try {
- const dataUrl = await captureSlide(el, size.w, size.h, scale);
- const base64 = dataUrl.split(",")[1] || "";
- const name = `${String(i + 1).padStart(2, "0")}-${slide.layout}-${state.device}-${state.locale}-${size.w}x${size.h}.png`;
- zip.file(name, base64, { base64: true });
- okCount += 1;
- } catch (e) {
- failed += 1;
- const msg = e instanceof Error ? e.message : String(e);
- errors.push(`Slide ${i + 1}: ${msg}`);
- console.error("Export failed for slide", slide.id, e);
+ for (const locale of locales) {
+ setExportLocaleOverride(locale);
+ await waitForPaint();
+
+ for (const size of sizes) {
+ // Uniform downscale so smaller sizes shrink instead of getting cropped
+ // by html-to-image.
+ const scale = Math.min(size.w / cW, size.h / cH);
+
+ for (let i = 0; i < currentSlides.length; i++) {
+ const slide = currentSlides[i];
+ unit += 1;
+ setExporting(`${unit}/${totalUnits}`);
+ const el = exportRefs.current[slide.id];
+ if (!el) {
+ failed += 1;
+ errors.push(`${locale} ${size.w}×${size.h} slide ${i + 1}: render target missing`);
+ continue;
+ }
+ try {
+ const dataUrl = await captureSlide(el, size.w, size.h, scale);
+ const base64 = dataUrl.split(",")[1] || "";
+ const filename = `${String(i + 1).padStart(2, "0")}-${slide.layout}.png`;
+ const path = `${platform}/${state.device}/${size.w}x${size.h}/${locale}/${filename}`;
+ zip.file(path, base64, { base64: true });
+ okCount += 1;
+ } catch (e) {
+ failed += 1;
+ const msg = e instanceof Error ? e.message : String(e);
+ errors.push(`${locale} ${size.w}×${size.h} slide ${i + 1}: ${msg}`);
+ console.error("Export failed", { slideId: slide.id, locale, size }, e);
+ }
+ }
}
}
+ setExportLocaleOverride(null);
setExporting(null);
if (okCount > 0) {
@@ -310,7 +345,7 @@ export function ScreenshotEditor() {
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
- a.download = `${slugify(state.appName)}-${state.device}-${state.locale}-${size.w}x${size.h}-${stamp()}.zip`;
+ a.download = `${slugify(state.appName)}-${platform}-${state.device}-${stamp()}.zip`;
a.click();
setTimeout(() => URL.revokeObjectURL(url), 5000);
} catch (e) {
@@ -320,14 +355,15 @@ export function ScreenshotEditor() {
}
}
+ const summary = `${locales.length} locale${locales.length === 1 ? "" : "s"} × ${sizes.length} size${sizes.length === 1 ? "" : "s"}`;
if (failed === 0) {
- toast.success(`Exported ${okCount} slide${okCount === 1 ? "" : "s"} at ${size.w}×${size.h}`);
+ toast.success(`Exported ${okCount} PNGs (${summary})`);
} else if (okCount === 0) {
- toast.error(`All ${failed} slide(s) failed to export`, {
+ toast.error(`All ${failed} renders failed`, {
description: errors.slice(0, 3).join("\n"),
});
} else {
- toast.error(`${failed} of ${currentSlides.length} slide(s) failed`, {
+ toast.error(`${failed} of ${totalUnits} renders failed`, {
description: errors.slice(0, 3).join("\n"),
});
}
@@ -391,21 +427,17 @@ export function ScreenshotEditor() {
<Toolbar
appName={state.appName}
setAppName={(v) => setState((p) => ({ ...p, appName: v }))}
- themeId={state.themeId}
- setThemeId={(v) => setState((p) => ({ ...p, themeId: v }))}
locale={state.locale}
setLocale={(v) => setState((p) => ({ ...p, locale: v }))}
+ locales={state.locales}
device={state.device}
setDevice={(v) => setState((p) => ({ ...p, device: v }))}
orientation={state.orientation}
setOrientation={(v) => setState((p) => ({ ...p, orientation: v }))}
- sizeIdx={sizeIdx}
- setSizeIdx={setSizeIdx}
onExport={exportAll}
onResetAll={() => {
reset();
setActiveSlideId(null);
- setSizeIdx(0);
toast.success("Reset all devices to defaults");
}}
onResetDevice={() => {
@@ -427,6 +459,7 @@ export function ScreenshotEditor() {
device={state.device}
orientation={state.orientation}
theme={theme}
+ locale={state.locale}
appName={state.appName}
appIcon={state.appIcon}
disabled={busy}
@@ -445,11 +478,12 @@ export function ScreenshotEditor() {
device={state.device}
orientation={state.orientation}
theme={theme}
+ locale={state.locale}
appName={state.appName}
appIcon={state.appIcon}
selectedElementId={selectedElementId}
- onLabelChange={(v) => patchSlide(activeSlide.id, { label: v })}
- onHeadlineChange={(v) => patchSlide(activeSlide.id, { headline: v })}
+ onLabelChange={(v) => patchLocalized(activeSlide, "label", v)}
+ onHeadlineChange={(v) => patchLocalized(activeSlide, "headline", v)}
onElementChange={(id, t) =>
patchSlide(activeSlide.id, {
transforms: { ...(activeSlide.transforms || {}), [id]: t },
@@ -469,6 +503,7 @@ export function ScreenshotEditor() {
{activeSlide ? (
<Inspector
slide={activeSlide}
+ locale={state.locale}
selectedElementId={selectedElementId}
onChange={(patch) => patchSlide(activeSlide.id, patch)}
/>
@@ -505,6 +540,7 @@ export function ScreenshotEditor() {
device={state.device}
orientation={state.orientation}
theme={theme}
+ locale={exportLocaleOverride ?? state.locale}
appName={state.appName}
appIcon={state.appIcon}
hideEmpty
diff --git a/skills/app-store-screenshots/template/src/components/editor/screenshot-picker.tsx b/skills/app-store-screenshots/template/src/components/editor/screenshot-picker.tsx
index e33bf5a..f1b48d0 100644
--- a/skills/app-store-screenshots/template/src/components/editor/screenshot-picker.tsx
+++ b/skills/app-store-screenshots/template/src/components/editor/screenshot-picker.tsx
@@ -133,9 +133,10 @@ export function ScreenshotPicker({ label, value, onChange }: Props) {
accept="image/png,image/jpeg"
className="hidden"
onChange={async (e) => {
- const file = e.target.files?.[0];
+ const input = e.currentTarget;
+ const file = input.files?.[0];
if (file) await handleFile(file);
- e.currentTarget.value = "";
+ input.value = "";
}}
/>
<Button
diff --git a/skills/app-store-screenshots/template/src/components/editor/sidebar.tsx b/skills/app-store-screenshots/template/src/components/editor/sidebar.tsx
index 708efa6..43d7d13 100644
--- a/skills/app-store-screenshots/template/src/components/editor/sidebar.tsx
+++ b/skills/app-store-screenshots/template/src/components/editor/sidebar.tsx
@@ -27,6 +27,7 @@ type Props = {
device: Device;
orientation: Orientation;
theme: Theme;
+ locale: string;
appName?: string;
appIcon?: string;
disabled?: boolean;
@@ -43,6 +44,7 @@ export function Sidebar({
device,
orientation,
theme,
+ locale,
appName,
appIcon,
disabled,
@@ -88,6 +90,7 @@ export function Sidebar({
device={device}
orientation={orientation}
theme={theme}
+ locale={locale}
appName={appName}
appIcon={appIcon}
onSelect={() => onSelect(slide.id)}
diff --git a/skills/app-store-screenshots/template/src/components/editor/slide-canvas.tsx b/skills/app-store-screenshots/template/src/components/editor/slide-canvas.tsx
index 70a155a..937c4b7 100644
--- a/skills/app-store-screenshots/template/src/components/editor/slide-canvas.tsx
+++ b/skills/app-store-screenshots/template/src/components/editor/slide-canvas.tsx
@@ -20,6 +20,7 @@ import {
tabletPW,
} from "@/lib/constants";
import { img } from "@/lib/image-cache";
+import { pickText, resolveScreenshot } from "@/lib/locale";
import {
AndroidPhone,
AndroidTabletL,
@@ -90,6 +91,7 @@ type Props = {
device: Device;
orientation: Orientation;
theme: Theme;
+ locale: string;
appName?: string;
appIcon?: string;
editable?: boolean;
@@ -180,6 +182,7 @@ function Caption({
cH,
slide,
theme,
+ locale,
editable,
edit,
align = "center",
@@ -190,6 +193,7 @@ function Caption({
cH: number;
slide: Slide;
theme: Theme;
+ locale: string;
editable?: boolean;
edit?: EditHandlers;
align?: "center" | "left";
@@ -204,7 +208,7 @@ function Caption({
return (
<div style={{ textAlign: align, position: "relative", width: "100%" }}>
<EditableText
- value={slide.label}
+ value={pickText(slide.label, locale)}
editable={editable}
onChange={edit?.onLabelChange}
onFocus={onFocus}
@@ -220,7 +224,7 @@ function Caption({
}}
/>
<EditableText
- value={slide.headline}
+ value={pickText(slide.headline, locale)}
editable={editable}
multiline
onChange={edit?.onHeadlineChange}
@@ -422,6 +426,7 @@ export function SlideCanvas({
device,
orientation,
theme,
+ locale,
appName,
appIcon,
editable,
@@ -431,6 +436,8 @@ export function SlideCanvas({
hideEmpty,
}: Props) {
const { cW, cH } = getCanvas(device, orientation);
+ const screenshot = resolveScreenshot(slide.screenshot, locale);
+ const screenshotSecondary = resolveScreenshot(slide.screenshotSecondary, locale);
const { Comp: Frame, widthFn, smallWidthFn } = getFrameForDevice(device, orientation);
const inverted = !!slide.inverted;
const bg = backgroundFor(theme, inverted);
@@ -492,7 +499,7 @@ export function SlideCanvas({
<div>
<div style={{ fontSize: cW * 0.06, fontWeight: 800, lineHeight: 1.05 }}>{appName || "App"}</div>
<EditableText
- value={slide.headline}
+ value={pickText(slide.headline, locale)}
editable={editable}
multiline
onChange={edit?.onHeadlineChange}
@@ -524,6 +531,7 @@ export function SlideCanvas({
cH={cH}
slide={slide}
theme={theme}
+ locale={locale}
editable={editable}
edit={edit}
align={captionRect.align || "center"}
@@ -620,11 +628,11 @@ export function SlideCanvas({
renderDevice(
"deviceSecondary",
secondaryRect,
- slide.screenshotSecondary || slide.screenshot,
+ screenshotSecondary || screenshot,
{ opacity: 0.85 },
)}
{deviceRect &&
- renderDevice("device", deviceRect, slide.screenshot)}
+ renderDevice("device", deviceRect, screenshot)}
{renderCaption()}
</div>
);
diff --git a/skills/app-store-screenshots/template/src/components/editor/slide-thumb.tsx b/skills/app-store-screenshots/template/src/components/editor/slide-thumb.tsx
index 60d1f4c..9ca6343 100644
--- a/skills/app-store-screenshots/template/src/components/editor/slide-thumb.tsx
+++ b/skills/app-store-screenshots/template/src/components/editor/slide-thumb.tsx
@@ -5,6 +5,7 @@ import { CSS } from "@dnd-kit/utilities";
import { Copy, GripVertical, Trash2 } from "lucide-react";
import { Button } from "@/components/ui/button";
import { LAYOUT_LABEL } from "@/lib/constants";
+import { pickText } from "@/lib/locale";
import type { Device, Orientation, Slide, Theme } from "@/lib/types";
import { cn } from "@/lib/utils";
import { SlideCanvas, getCanvas } from "./slide-canvas";
@@ -16,6 +17,7 @@ type Props = {
device: Device;
orientation: Orientation;
theme: Theme;
+ locale: string;
appName?: string;
appIcon?: string;
onSelect: () => void;
@@ -33,12 +35,15 @@ export function SlideThumb({
device,
orientation,
theme,
+ locale,
appName,
appIcon,
onSelect,
onDelete,
onDuplicate,
}: Props) {
+ const headline = pickText(slide.headline, locale);
+ const label = pickText(slide.label, locale);
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({
id: slide.id,
});
@@ -99,6 +104,7 @@ export function SlideThumb({
device={device}
orientation={orientation}
theme={theme}
+ locale={locale}
appName={appName}
appIcon={appIcon}
editable={false}
@@ -110,13 +116,13 @@ export function SlideThumb({
{`Slide ${index + 1} · ${LAYOUT_LABEL[slide.layout]}`}
</span>
<span className="truncate text-sm font-medium leading-tight">
- {slide.headline.split("\n")[0] || (
+ {headline.split("\n")[0] || (
<em className="font-normal text-muted-foreground">Untitled</em>
)}
</span>
- {slide.label ? (
+ {label ? (
<span className="truncate text-[10px] uppercase tracking-wide text-muted-foreground">
- {slide.label}
+ {label}
</span>
) : null}
</div>
diff --git a/skills/app-store-screenshots/template/src/components/editor/toolbar.tsx b/skills/app-store-screenshots/template/src/components/editor/toolbar.tsx
index f639481..6f59a70 100644
--- a/skills/app-store-screenshots/template/src/components/editor/toolbar.tsx
+++ b/skills/app-store-screenshots/template/src/components/editor/toolbar.tsx
@@ -20,26 +20,21 @@ import {
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
import {
DEVICE_LABEL,
- getExportSizes,
- LOCALES,
supportsLandscape,
} from "@/lib/constants";
import { detectPlatform } from "@/lib/defaults";
-import type { Device, Orientation, ThemeId } from "@/lib/types";
+import type { Device, Orientation } from "@/lib/types";
type Props = {
appName: string;
setAppName: (v: string) => void;
- themeId: ThemeId;
- setThemeId: (v: ThemeId) => void;
locale: string;
setLocale: (v: string) => void;
+ locales: string[];
device: Device;
setDevice: (v: Device) => void;
orientation: Orientation;
setOrientation: (v: Orientation) => void;
- sizeIdx: number;
- setSizeIdx: (i: number) => void;
onExport: () => void;
onResetAll: () => void;
onResetDevice: () => void;
@@ -53,7 +48,6 @@ export function Toolbar(props: Props) {
const platform = detectPlatform(props.device);
const hasLandscape = supportsLandscape(props.device);
const [resetOpen, setResetOpen] = React.useState(false);
- const sizes = getExportSizes(props.device, props.orientation);
// Track last device per platform so iOS/Android tabs preserve user's choice.
const lastByPlatform = React.useRef<{ ios: Device; android: Device }>({
@@ -64,10 +58,7 @@ export function Toolbar(props: Props) {
lastByPlatform.current[platform] = props.device;
}, [platform, props.device]);
- // Clamp sizeIdx so the controlled Select never falls out of range when the
- // sizes array changes (e.g. switching device).
- const safeSizeIdx = Math.min(props.sizeIdx, Math.max(0, sizes.length - 1));
- const showLocale = LOCALES.length > 1;
+ const showLocale = props.locales.length > 1;
const deviceLabel = DEVICE_LABEL[props.device];
@@ -150,7 +141,7 @@ export function Toolbar(props: Props) {
<SelectValue />
</SelectTrigger>
<SelectContent>
- {LOCALES.map((l) => (
+ {props.locales.map((l) => (
<SelectItem key={l} value={l}>
{l.toUpperCase()}
</SelectItem>
@@ -159,23 +150,6 @@ export function Toolbar(props: Props) {
</Select>
)}
- <Select
- value={String(safeSizeIdx)}
- onValueChange={(v) => props.setSizeIdx(Number(v))}
- disabled={props.busy}
- >
- <SelectTrigger className="h-8 w-56 text-xs">
- <SelectValue />
- </SelectTrigger>
- <SelectContent>
- {sizes.map((s, i) => (
- <SelectItem key={i} value={String(i)}>
- {s.label} — {s.w}×{s.h}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
-
<div className="ml-auto flex shrink-0 items-center gap-2">
<SaveStatus savedAt={props.savedAt} saveError={props.saveError} />
<span aria-hidden className="h-5 w-px bg-border" />
@@ -190,9 +164,15 @@ export function Toolbar(props: Props) {
>
<RotateCcw className="h-4 w-4" />
</Button>
- <Button onClick={props.onExport} disabled={!!props.exporting} size="sm" className="h-8">
+ <Button
+ onClick={props.onExport}
+ disabled={!!props.exporting}
+ size="sm"
+ className="h-8"
+ title="Export every size × locale for this device as a zip"
+ >
<Download className="h-4 w-4" />
- {props.exporting ? `Exporting ${props.exporting}` : "Export all"}
+ {props.exporting ? `Exporting ${props.exporting}` : "Export bundle"}
</Button>
</div>
diff --git a/skills/app-store-screenshots/template/src/lib/constants.ts b/skills/app-store-screenshots/template/src/lib/constants.ts
index 3db5fd5..3ba6d73 100644
--- a/skills/app-store-screenshots/template/src/lib/constants.ts
+++ b/skills/app-store-screenshots/template/src/lib/constants.ts
@@ -124,9 +124,6 @@ export const THEMES: Record<ThemeId, Theme> = {
},
};
-export const LOCALES = ["en", "de", "es", "fr", "ja", "pt"] as const;
-export type Locale = typeof LOCALES[number];
-
export const STORAGE_KEY = "app-store-screenshots:project:v1";
export const DEVICE_LABEL: Record<Device, string> = {
diff --git a/skills/app-store-screenshots/template/src/lib/defaults.ts b/skills/app-store-screenshots/template/src/lib/defaults.ts
index 36c4b06..2719d5d 100644
--- a/skills/app-store-screenshots/template/src/lib/defaults.ts
+++ b/skills/app-store-screenshots/template/src/lib/defaults.ts
@@ -1,45 +1,48 @@
+import { DEFAULT_LOCALE } from "./locale";
import type { Device, ProjectState, Slide } from "./types";
let _id = 0;
export const nid = () => `s_${Date.now().toString(36)}_${(_id++).toString(36)}`;
+const en = (s: string) => ({ [DEFAULT_LOCALE]: s });
+
function makeStarterSlides(): Slide[] {
return [
{
id: nid(),
layout: "hero",
- label: "MEET YOUR APP",
- headline: "Sell one\nidea per slide.",
+ label: en("MEET YOUR APP"),
+ headline: en("Sell one\nidea per slide."),
screenshot: "",
},
{
id: nid(),
layout: "device-bottom",
- label: "FEATURE 01",
- headline: "Your headline\nlives here.",
+ label: en("FEATURE 01"),
+ headline: en("Your headline\nlives here."),
screenshot: "",
},
{
id: nid(),
layout: "two-devices",
- label: "FEATURE 02",
- headline: "Show two\nscreens at once.",
+ label: en("FEATURE 02"),
+ headline: en("Show two\nscreens at once."),
screenshot: "",
screenshotSecondary: "",
},
{
id: nid(),
layout: "device-top",
- label: "FEATURE 03",
- headline: "Flip the contrast\nfor visual rhythm.",
+ label: en("FEATURE 03"),
+ headline: en("Flip the contrast\nfor visual rhythm."),
screenshot: "",
inverted: true,
},
{
id: nid(),
layout: "no-device",
- label: "MORE",
- headline: "And so\nmuch more.",
+ label: en("MORE"),
+ headline: en("And so\nmuch more."),
screenshot: "",
},
];
@@ -50,22 +53,22 @@ function ipadStarter(): Slide[] {
{
id: nid(),
layout: "hero",
- label: "MEET YOUR APP",
- headline: "Made for\nthe big screen.",
+ label: en("MEET YOUR APP"),
+ headline: en("Made for\nthe big screen."),
screenshot: "",
},
{
id: nid(),
layout: "device-bottom",
- label: "FEATURE 01",
- headline: "Built for\nfocus.",
+ label: en("FEATURE 01"),
+ headline: en("Built for\nfocus."),
screenshot: "",
},
{
id: nid(),
layout: "device-top",
- label: "FEATURE 02",
- headline: "Always within reach.",
+ label: en("FEATURE 02"),
+ headline: en("Always within reach."),
screenshot: "",
inverted: true,
},
@@ -77,15 +80,15 @@ function tabletStarter(kind: "7" | "10"): Slide[] {
{
id: nid(),
layout: "hero",
- label: "MEET YOUR APP",
- headline: kind === "7" ? "Pocket-sized\npower." : "Made for\nthe big screen.",
+ label: en("MEET YOUR APP"),
+ headline: en(kind === "7" ? "Pocket-sized\npower." : "Made for\nthe big screen."),
screenshot: "",
},
{
id: nid(),
layout: "split-landscape",
- label: "FEATURE 01",
- headline: "Wide canvas,\nbigger ideas.",
+ label: en("FEATURE 01"),
+ headline: en("Wide canvas,\nbigger ideas."),
screenshot: "",
},
];
@@ -96,8 +99,8 @@ function fgStarter(): Slide[] {
{
id: nid(),
layout: "feature-graphic",
- label: "",
- headline: "Your tagline goes here.",
+ label: {},
+ headline: en("Your tagline goes here."),
screenshot: "",
},
];
@@ -106,7 +109,8 @@ function fgStarter(): Slide[] {
export const DEFAULT_PROJECT: ProjectState = {
appName: "My App",
themeId: "clean-light",
- locale: "en",
+ locales: [DEFAULT_LOCALE],
+ locale: DEFAULT_LOCALE,
device: "iphone",
orientation: "portrait",
appIcon: "",
@@ -124,8 +128,8 @@ export function newSlide(layout: Slide["layout"] = "device-bottom"): Slide {
return {
id: nid(),
layout,
- label: "NEW",
- headline: "Edit this\nheadline.",
+ label: en("NEW"),
+ headline: en("Edit this\nheadline."),
screenshot: "",
};
}
diff --git a/skills/app-store-screenshots/template/src/lib/locale.ts b/skills/app-store-screenshots/template/src/lib/locale.ts
new file mode 100644
index 0000000..51cb431
--- /dev/null
+++ b/skills/app-store-screenshots/template/src/lib/locale.ts
@@ -0,0 +1,50 @@
+import type { LocalizedText } from "./types";
+
+export const DEFAULT_LOCALE = "en";
+
+// Read the value for `locale` from a localized field. Falls back to en, then to
+// the first locale that has a non-empty value, then to empty string. Used by
+// the canvas/preview/thumb so switching to a locale the user hasn't filled in
+// shows the source copy instead of blanks.
+export function pickText(field: LocalizedText | undefined, locale: string): string {
+ if (!field) return "";
+ const direct = field[locale];
+ if (direct && direct.length) return direct;
+ const en = field[DEFAULT_LOCALE];
+ if (en && en.length) return en;
+ for (const k of Object.keys(field)) {
+ const v = field[k];
+ if (v && v.length) return v;
+ }
+ return "";
+}
+
+// Replace `{locale}` placeholders in a screenshot path. Data URLs and empty
+// strings pass through unchanged.
+export function resolveScreenshot(path: string | undefined, locale: string): string {
+ if (!path) return "";
+ if (path.startsWith("data:")) return path;
+ if (!path.includes("{locale}")) return path;
+ return path.replace(/\{locale\}/g, locale);
+}
+
+// Convert legacy `string` headline/label fields to the per-locale shape. Safe
+// to call on already-migrated data.
+export function coerceLocalized(value: unknown): LocalizedText {
+ if (typeof value === "string") return { [DEFAULT_LOCALE]: value };
+ if (value && typeof value === "object") return value as LocalizedText;
+ return {};
+}
+
+// Set or clear the value for `locale` on a localized field. Empty values delete
+// the key so the persisted JSON stays free of "" placeholders.
+export function writeLocalized(
+ field: LocalizedText | undefined,
+ locale: string,
+ value: string,
+): LocalizedText {
+ const next: LocalizedText = { ...(field || {}) };
+ if (value.length === 0) delete next[locale];
+ else next[locale] = value;
+ return next;
+}
diff --git a/skills/app-store-screenshots/template/src/lib/storage.ts b/skills/app-store-screenshots/template/src/lib/storage.ts
index eba095f..7633e00 100644
--- a/skills/app-store-screenshots/template/src/lib/storage.ts
+++ b/skills/app-store-screenshots/template/src/lib/storage.ts
@@ -2,7 +2,8 @@
import { useCallback, useEffect, useRef, useState } from "react";
import { STORAGE_KEY } from "./constants";
import { DEFAULT_PROJECT } from "./defaults";
-import type { Device, ProjectState } from "./types";
+import { coerceLocalized } from "./locale";
+import type { Device, ProjectState, Slide } from "./types";
const HISTORY_LIMIT = 50;
// Coalesce rapid edits (typing, slider drags) into a single undo step.
@@ -10,15 +11,41 @@ const COALESCE_MS = 500;
// Debounce file/localStorage writes — frequent enough to feel instant, infrequent enough not to thrash disk.
const SAVE_DEBOUNCE_MS = 600;
-function mergeWithDefaults(parsed: Partial<ProjectState>): ProjectState {
+// Migrate pre-locale string label/headline into { en: value }.
+function migrateSlide(slide: Slide): Slide {
return {
+ ...slide,
+ label: coerceLocalized(slide.label as unknown),
+ headline: coerceLocalized(slide.headline as unknown),
+ };
+}
+
+function mergeWithDefaults(parsed: Partial<ProjectState>): ProjectState {
+ const slidesByDevice = parsed.slidesByDevice
+ ? Object.fromEntries(
+ Object.entries(parsed.slidesByDevice).map(([device, slides]) => [
+ device,
+ (slides || []).map(migrateSlide),
+ ]),
+ )
+ : {};
+ const merged: ProjectState = {
...DEFAULT_PROJECT,
...parsed,
slidesByDevice: {
...DEFAULT_PROJECT.slidesByDevice,
- ...(parsed.slidesByDevice || {}),
- },
+ ...slidesByDevice,
+ } as ProjectState["slidesByDevice"],
};
+ // Clamp the active locale into the project's locale list so a stale
+ // `locale` (e.g. from a project that dropped languages) doesn't show blank.
+ if (!merged.locales || merged.locales.length === 0) {
+ merged.locales = [...DEFAULT_PROJECT.locales];
+ }
+ if (!merged.locales.includes(merged.locale)) {
+ merged.locale = merged.locales[0];
+ }
+ return merged;
}
function loadFromLocalStorage(): ProjectState | null {
diff --git a/skills/app-store-screenshots/template/src/lib/types.ts b/skills/app-store-screenshots/template/src/lib/types.ts
index bcff254..fcab254 100644
--- a/skills/app-store-screenshots/template/src/lib/types.ts
+++ b/skills/app-store-screenshots/template/src/lib/types.ts
@@ -32,14 +32,20 @@ export type ElementTransform = {
export type ElementId = "caption" | "device" | "deviceSecondary";
+// Per-locale text keyed by locale code (e.g. "en", "de"). A locale is absent
+// if the user hasn't typed anything for it; renderers fall back to en (see
+// lib/locale.ts). The set of locales a project targets lives on
+// ProjectState.locales.
+export type LocalizedText = Partial<Record<string, string>>;
+
export type Slide = {
id: string;
layout: SlideLayout;
- label: string; // tiny uppercase caption above headline
- headline: string; // multi-line; newlines are intentional
- screenshot: string; // path under /screenshots/ (or "" for none)
- screenshotSecondary?: string; // for two-devices layout
- inverted?: boolean; // dark background variant
+ label: LocalizedText; // tiny uppercase caption above headline, per locale
+ headline: LocalizedText; // multi-line; newlines are intentional, per locale
+ screenshot: string; // path under /screenshots/ — may contain {locale}
+ screenshotSecondary?: string; // for two-devices layout — may contain {locale}
+ inverted?: boolean; // dark background variant
// Per-element overrides; when present, replaces layout default placement.
transforms?: Partial<Record<ElementId, ElementTransform>>;
};
@@ -60,6 +66,9 @@ export type Theme = {
export type ProjectState = {
appName: string;
themeId: ThemeId;
+ // Locales this project targets. Drives the toolbar dropdown and bulk export.
+ // Single-locale projects ship as ["en"] and hide the locale UI.
+ locales: string[];
locale: string;
device: Device;
orientation: Orientation;