Home/
Part XIII — Expert Mode: Systems, Agents, and Automation/40. Advanced Structured Output/40.4 Internationalization schemas (multi-locale outputs)
40.4 Internationalization schemas (multi-locale outputs)
Overview and links for this section of the guide.
On this page
Multi-Locale Schema
const LocalizedContent = z.object({
localized: z.record(
z.enum(['en', 'es', 'fr', 'de', 'ja']),
z.object({
title: z.string(),
description: z.string(),
keywords: z.array(z.string())
})
),
defaultLocale: z.enum(['en', 'es', 'fr', 'de', 'ja'])
});
// Example output
{
"localized": {
"en": { "title": "Welcome", "description": "...", "keywords": ["..."] },
"es": { "title": "Bienvenido", "description": "...", "keywords": ["..."] }
},
"defaultLocale": "en"
}
Prompting
const I18N_PROMPT = `
Generate content for these locales: ${locales.join(', ')}
Rules:
- Translate, don't transliterate
- Adapt cultural references appropriately
- Keep technical terms consistent across locales
- Maintain same meaning and tone
Output localized content for each requested locale.
`;