React reference
Ways
Root props
Common root props:
| Prop | Type | Notes |
|---|---|---|
apiKey | string | Required. |
locale | string | Current target locale. |
baseLocale | string | Source locale. |
persistLocaleCookie | boolean | Default locale-cookie policy for the root runtime. |
context | string | object | Optional root context. |
cacheTtl | number | Cache TTL for translation requests. |
messageFormatter | 'waysParser' | 'none' | fn | Parser or formatter override. |
suspenseTimeoutMs | number | Maximale Zeit, für die das Rendern blockiert werden darf, bevor mit dem Fallback-Rendering fortgefahren wird. |
fetcher | typeof fetch | Custom fetch implementation. |
acceptedLocales | string[] | Optional explicit locale list. |
Scoped props
Nested scopes accept:
| Prop | Type | Notes |
|---|---|---|
context | string | object | Required. |
locale | string | Verfügbar, aber verwende einen verschachtelten Root für eine isolierte Locale-Sitzung. |
baseLocale | string | Optionale Quellgebietsschema-Überschreibung für den Unterbaum. |
components | Record<string, component> | Components used inside translatable content. |
T
T is the JSX-first translation primitive.
| Prop | Type | Notes |
|---|---|---|
children | ReactNode | Required. |
vars | Record<string, unknown> | Interpolation input. |
context | string | object | Optional leaf context override. |
components | Record<string, component> | Component mapping for rich content. |
fixed | boolean | Skip translation for fixed branding-like content. |
useT()
useT() returns a translation function for strings, attributes, and logic.
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:
| Prop | Type | Notes |
|---|---|---|
currentLocale | string | Controlled locale. |
onLocaleChange | (locale) => void | Change handler. |
direction | 'up' | 'down' | Menu direction. |
styles / classNames | object | Styling overrides. |
unstyled | boolean | Disable built-in styles. |
Utility exports
@18ways/react also re-exports:
fetchAcceptedLocalesfetchConfigresolveOrigin