Key Resolution
Key Resolution Flow
Section titled “Key Resolution Flow”When a user clicks on a translatable element in the editor overlay:
- The
KeyResolverreceives the clicked DOM element. - It first checks for
data-i18n-keyattribute on the element or its ancestors. - If the adapter provides
getKeyFromElement(), it calls that method. - The resolved key is used to look up translations in the
I18nLiveStore.
Key Format
Section titled “Key Format”Translation keys use dot-notation for nested objects:
{ "nav": { "home": "Home", "about": "About" }, "card.welcome": "Welcome!"}nav.homeresolves to"Home"card.welcomeresolves to"Welcome!"
Both nested JSON and flat dot-notation keys are supported.
CLI Key Extraction
Section titled “CLI Key Extraction”The localive extract command finds keys in your source code using these patterns:
| Pattern | Matches |
|---|---|
t('key') | Generic t() calls (React, Vue, Svelte, i18next) |
data-i18n-key="key" | HTML attribute |
[attr.data-i18n-key]="'key'" | Angular attribute binding |
v-localive-tag="'key'" | Vue directive |