React reference

Ways

Root props

Common root props:

PropTypeNotes
apiKeystringRequired.
localestringCurrent target locale.
baseLocalestringSource locale.
persistLocaleCookiebooleanDefault locale-cookie policy for the root runtime.
contextstring | objectOptional root context.
cacheTtlnumberCache TTL for translation requests.
messageFormatter'waysParser' | 'none' | fnParser or formatter override.
suspenseTimeoutMsnumberMaximale Zeit, für die das Rendern blockiert werden darf, bevor mit dem Fallback-Rendering fortgefahren wird.
fetchertypeof fetchCustom fetch implementation.
acceptedLocalesstring[]Optional explicit locale list.

Scoped props

Nested scopes accept:

PropTypeNotes
contextstring | objectRequired.
localestringVerfügbar, aber verwende einen verschachtelten Root für eine isolierte Locale-Sitzung.
baseLocalestringOptionale Quellgebietsschema-Überschreibung für den Unterbaum.
componentsRecord<string, component>Components used inside translatable content.

T

T is the JSX-first translation primitive.

PropTypeNotes
childrenReactNodeRequired.
varsRecord<string, unknown>Interpolation input.
contextstring | objectOptional leaf context override.
componentsRecord<string, component>Component mapping for rich content.
fixedbooleanSkip translation for fixed branding-like content.

useT()

useT() returns a translation function for strings, attributes, and logic.

tsx
const t = useT();
const label = t('Save changes');

Runtime hooks

useTranslatedMemo()

A memoized value that recomputes when translations change.

useTranslationLoading()

Returns true while the current context is still loading.

useCurrentLocale()

Liest die ausgewählte Gebietsschema für die aktuelle Root-Laufzeit.

useTargetLocale()

Liest die aktive Zielgebietssprache für den aktuellen Geltungsbereich.

useBaseLocale()

Liest die Quell-Locale für die aktuelle Root-Laufzeitumgebung.

useSetCurrentLocale()

Returns the setter for the root runtime locale.

useAcceptedLocales()

Liest die aufgelöste Liste der akzeptierten Gebietsschemas aus der Root-Runtime.

LanguageSwitcher

Common props:

PropTypeNotes
currentLocalestringControlled locale.
onLocaleChange(locale) => voidChange handler.
direction'up' | 'down'Menu direction.
styles / classNamesobjectStyling overrides.
unstyledbooleanDisable built-in styles.

Utility exports

@18ways/react also re-exports:

  • fetchAcceptedLocales
  • fetchConfig
  • resolveOrigin