Localization
Doodle Engine uses a simple @key system for localization. All player-visible text should use localization keys so your game can be translated.
Locale Files
Section titled “Locale Files”Create flat key-value YAML files in content/locales/:
location.tavern.name: 'The Rusty Tankard'location.tavern.description: 'A cozy tavern with worn wooden tables.'character.bartender.name: 'Greta'bartender.greeting: 'Welcome! What can I do for you?'location.tavern.name: 'La Jarra Oxidada'location.tavern.description: 'Una taberna acogedora con mesas de madera gastadas.'character.bartender.name: 'Greta'bartender.greeting: '¡Bienvenido! ¿Qué puedo hacer por ti?'Locale files are loaded by filename: en.yaml becomes locale "en", es.yaml becomes "es".
Using @keys
Section titled “Using @keys”Reference locale strings with the @ prefix in YAML content:
id: tavernname: '@location.tavern.name'description: '@location.tavern.description'And in .dlg dialogue files:
NODE start BARTENDER: @bartender.greeting
CHOICE @bartender.choice.hello GOTO hello ENDHow Resolution Works
Section titled “How Resolution Works”At snapshot build time, the engine resolves all @key references:
- Looks up the key in the current locale’s data
- If found, returns the translated string
- If not found, returns the
@keyas-is (useful for spotting missing translations)
The resolution function:
import { resolveText } from '@doodle-engine/core';
const text = resolveText('@bartender.greeting', localeData);// → "Welcome! What can I do for you?"Changing Language at Runtime
Section titled “Changing Language at Runtime”Use the setLocale action:
const { actions } = useGame();actions.setLocale('es');Or from a dialogue effect. This isn’t built into the DSL, but can be done programmatically via the engine.
Naming Convention
Section titled “Naming Convention”Use a consistent key naming scheme:
# Locationslocation.<id>.namelocation.<id>.description
# Characterscharacter.<id>.namecharacter.<id>.bio
# Dialogue text<character_id>.<context><character_id>.choice.<choice_name>
# Itemsitem.<id>.nameitem.<id>.description
# Questsquest.<id>.namequest.<id>.descriptionquest.<id>.stage.<stage_id>
# Notificationsnotification.<event_name>
# Narratornarrator.<context>Notification Strings
Section titled “Notification Strings”Notification effects use @key too:
NOTIFY @notification.quest_startednotification.quest_started: 'New Quest: Odd Jobs'