Localize skills, templates and notifications
Run the existing localization template, switch Chinese and English, and inspect display text, business values and listener cleanup. Internal source preview.
Outcome: Run the existing localization template, switch Chinese and English, and inspect display text, business values and listener cleanup. Internal source preview.
Before you begin: Prepare the files and tools specified on this page. The previous page in the learning path is not automatically a dependency.
On this page
01Prepare the host and local packages
Complete local package setup in the first-extension guide. Run in extension-work with AMBLELOFT_PACKS set. The host must provide skillLocalization, templateLocalization, notificationLocalization and liveLocalization. Notifications also require user opt-in. This example needs no external service.
Prepare local packages02Generate and install the existing template
Install dist/locale-demo.amble-extension in the host, confirm trust and grant declared permissions. This uses the existing tooling template.
npx --no-install amble-extension init locale-demo --name locale-demo --template localization
cd locale-demo
npm install --save-dev "$AMBLELOFT_PACKS/ambleloft-extension-sdk-0.1.0-alpha.9.tgz" "$AMBLELOFT_PACKS/ambleloft-extension-core-0.1.0-alpha.9.tgz" "$AMBLELOFT_PACKS/ambleloft-extension-cli-0.1.0-alpha.9.tgz"
npm run build
npm run validate
npm run pack03Switch language and inspect the result
Open the extension page, publish one notification and inspect its status. Switch the app between Chinese and English, then inspect again: activation should remain unchanged, changes should increase, and the next invocationLocale should use the new language. Request-form option labels follow the dictionaries while shanghai/beijing values stay unchanged. Only declared keys are translated; the collection still contains literal Chinese text, so the entire template is not fully translated.
04Listen and dispose
Preview capability · SDK 0.1.0-alpha.9
Place this code inside synchronous activate(context) in defineExtension. Probe first and register the Disposable in subscriptions. Dictionary parameters accept string, number and boolean. Translation changes declared display text, not user input, identities or idempotency keys.
import { getLocalization, requireLocalization } from '@ambleloft/extension-sdk/localization-preview';
// Inside activate(context):
requireLocalization(context, ['skillLocalization', 'templateLocalization',
'notificationLocalization', 'liveLocalization']);
const l10n = getLocalization(context);
context.subscriptions.push(l10n.onDidChangeLocale(locale => {
console.log(locale);
}));05Recovery and next steps
If capabilities are missing, stop using translated templates and check the host. For missing keys, inspect the owning Skill dictionary and fallback warnings. If notifications are rejected, check preferences instead of changing eventKey and resending. Check listener cleanup after disabling the extension. Next, use the same template to inspect collection interactions.
Explore collection interactionsCheck the result and troubleshoot
Check actual results using this page’s verification steps. For business integrations, inspect UI submission, tool receipts and server records separately.
Open the error reference →