Skip to main content

Types

AVAILABLE_LANGS

const: readonly ["fr", "en", "nl", "it", "de", "es", "pl", "pt", "ro", "hu", "sv", "tr", "ja", "cn", "cz", "ru", "ko", "ar"]

A runtime constant listing every language code i18n-keyless can translate to. Unlike the Lang type (which only exists at compile time), AVAILABLE_LANGS is a real array you can iterate over, spread into your supported config, or use for validation.

It is exported from both SDKs:

import { AVAILABLE_LANGS, type Lang } from 'i18n-keyless-react';
// or
import { AVAILABLE_LANGS, type Lang } from 'i18n-keyless-node';

The Lang type is derived from this constant: type Lang = (typeof AVAILABLE_LANGS)[number].

// Support every language i18n-keyless offers, no hardcoding
I18nKeyless.init({
API_KEY: 'YOUR_API_KEY',
storage: window.localStorage,
languages: {
primary: 'fr',
supported: [...AVAILABLE_LANGS],
},
});

// Type-safe runtime check
const isSupportedLang = (lang: string): lang is Lang =>
(AVAILABLE_LANGS as readonly string[]).includes(lang);

PrimaryLang

type: "fr" | "en"

The primary language used by the developer. This is limited to French ("fr") or English ("en") and represents the base language in which the application is developed.

Lang

type: "fr" | "en" | "nl" | "it" | "de" | "es" | "pl" | "pt" | "ro" | "hu" | "sv" | "tr" | "ja" | "cn" | "cz" | "ru" | "ko" | "ar"

All supported languages for translation. This extends PrimaryLang to include additional languages: Dutch, Italian, German, Spanish, Polish, Portuguese, Romanian, Hungarian, Swedish, Turkish, Japanese, Chinese, Czech, Russian, Korean, and Arabic.

Derived from AVAILABLE_LANGStype Lang = (typeof AVAILABLE_LANGS)[number]. If you need the list at runtime (e.g. to populate a <select> or validate input), import AVAILABLE_LANGS instead of writing the array by hand.

Translations

type: Record<string, string>

The translations for a key, represented as a key-value mapping where each key is the original text and each value is its translation. Example: { "un text": "a text" }.

LastRefresh

type: string | null

Timestamp indicating when the translations were last refreshed. Can be null if no refresh has occurred yet.

UniqueId

type: string | null

A unique identifier for tracking purposes. Can be null if no identifier has been assigned.

LanguagesConfig

type: object

Configuration object for language settings with the following properties:

  • primary: The language used by the developer (PrimaryLang)
  • supported: Array of languages supported for users (Lang[])
  • fallback: Optional fallback language when user's language is not supported (Lang)
  • initWithDefault: Optional language to use when the app is initialized (Lang)

TranslationOptions

type: object

Options for customizing translation behavior with the following properties:

  • context: Optional context for disambiguation of ambiguous translations (e.g., "8 heures" could mean "8 AM" or "8 hours")
  • debug: Optional boolean for debugging specific translation keys
  • forceTemporary: Optional partial record to override AI translations with custom ones
  • replace: Optional record for replacing placeholders in text with values (e.g., { "{{name}}": "John" })