Vanilla JS reference
create18waysEngine(options)
Import from @18ways/core/engine.
import { create18waysEngine } from '@18ways/core/engine';Common options:
| Option | Type | Notes |
|---|---|---|
apiKey | string | Required. |
baseLocale | string | Source locale. |
locale | string | Current target locale. |
context | string | object | Default context key. |
initialTranslations | Translations | Optional starting cache. |
apiUrl | string | Optional API base override. |
fetcher | typeof fetch | Custom fetch implementation. |
cacheTtlSeconds | number | Request cache TTL. |
origin | string | Origin forwarded on server-side requests. |
Engine methods
t(text, options?)
Translate a string and return the resolved value.
setLocale(locale)
Change the target locale.
getLocale()
Read the current target locale.
getStore()
Access the underlying translation store.
t() options
| Option | Type | Notes |
|---|---|---|
locale | string | Override the target locale for this call. |
baseLocale | string | Override the base locale for this call. |
context | string | object | Override the context for this call. |
vars | Record<string, unknown> | Variable input for waysParser. |
Utility exports
The core package also exports lower-level helpers such as:
fetchAcceptedLocalesfetchEnabledLanguages- locale utilities
- translation store utilities
Use those when you need them, but the engine should be the default starting point.