Vanilla JS reference

create18waysEngine(options)

Import from @18ways/core/engine.

ts
import { create18waysEngine } from '@18ways/core/engine';

Common options:

OptionTypeNotes
apiKeystringRequired.
baseLocalestringSource locale.
localestringCurrent target locale.
contextstring | objectDefault context key.
initialTranslationsTranslationsOptional starting cache.
apiUrlstringOptional API base override.
fetchertypeof fetchCustom fetch implementation.
cacheTtlSecondsnumberRequest cache TTL.
originstringOrigin 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

OptionTypeNotes
localestringOverride the target locale for this call.
baseLocalestringOverride the base locale for this call.
contextstring | objectOverride the context for this call.
varsRecord<string, unknown>Variable input for waysParser.

Utility exports

The core package also exports lower-level helpers such as:

  • fetchAcceptedLocales
  • fetchEnabledLanguages
  • locale utilities
  • translation store utilities

Use those when you need them, but the engine should be the default starting point.