Skip to main content

JavaScript SDK

The Kalima JavaScript SDK is the fastest route for websites and browser-rendered product surfaces.

Current hosted script

<script
src="https://uni-sdk.kalima.digital/kalima.js"
data-project-key="your-project-key"
data-show-language-switcher="true"
></script>
<script>
window.KalimaConfig = {
projectKey: 'your-project-key',
apiBaseUrl: 'https://sdk-api.kalima.digital/api/v1',
defaultLanguage: 'en',
supportedLocales: ['en', 'fr', 'es'],
urlMode: 'query',
languageParam: 'lang',
showLanguageSwitcher: true,
enableCssMasking: true,
maskOnlyWhenNotReady: true,
maskSafetyTimeoutMs: 400,
prefetchTranslations: false,
customCss: '.promo-banner { border-radius: 16px; }',
instantTranslation: false,
instantTranslationCacheTtlMs: 600000,
instantTranslationBatchSize: 25,
debug: false,
};
</script>

Important settings

SettingPurposeDefault behavior
projectKeyConnects the SDK to the right Kalima projectRequired
apiBaseUrlSelects the environment the SDK should callProduction defaults to https://sdk-api.kalima.digital/api/v1
defaultLanguageDefines the source localeen
supportedLocalesLimits which locales the SDK should exposeEmpty until provided by runtime or project info
urlModeControls locale parsing from query or pathquery
languageParamQuery parameter used in query modelang
showLanguageSwitcherDisplays Kalima language switcher UItrue
enableCssMaskingMasks content until translation state is readytrue
customCssInjects custom CSS on page startupEmpty string
prefetchTranslationsPrefetches translations earlyfalse
instantTranslationAllows SDK/API instant translation for approved missesProject setting or false
instantTranslationCacheTtlMsBrowser cache TTL for instant translation batches600000
instantTranslationBatchSizeMaximum instant translation batch size25
debugEnables SDK debug behaviorfalse

QA and language behavior

The SDK can:

  • Read locale from a query parameter such as ?lang=fr
  • Read locale from a path prefix when urlMode is path
  • Store the active locale in local storage
  • Use approved translations only
  • Use instant translation for eligible misses when explicitly enabled
  • Fall back to the source text when a translation is not available

Non-DOM translation

Use this when you need to translate strings outside the DOM, such as export labels.

const label = window.Kalima?.translateText('Export List') || 'Export List';

For instant translation, use the async API. Approved translations still win before instant translation is attempted.

const result = await window.Kalima?.translateInstant(
['Export List', 'Billing period'],
{ targetLanguage: 'fr', context: 'account settings' },
);

Common implementation notes

  • Load the SDK after window.KalimaConfig is defined if you need explicit overrides
  • Ensure the project key belongs to the same environment as the API base URL
  • Keep supportedLocales aligned with the project configuration in Kalima
  • Use debug mode only for troubleshooting, not production defaults

Support

Need help shipping this integration?

If you hit a blocker, contact Kalima with your project key, target environment, and a short description of what failed.