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 | فال بیک رینڈرنگ جاری رکھنے سے پہلے render blocking کے لیے زیادہ سے زیادہ وقت۔ |
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 | دستیاب ہے، مگر الگ تھلگ لوکیل سیشن کے لیے nested root استعمال کریں۔ |
baseLocale | string | subtree کے لیے اختیاری source-locale override۔ |
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()
موجودہ روٹ رن ٹائم کے لیے منتخب لوکیل پڑھتا ہے۔
useTargetLocale()
موجودہ scope کے لیے فعال target locale پڑھتا ہے۔
useBaseLocale()
موجودہ روٹ رن ٹائم کے لیے source locale پڑھتا ہے۔
useSetCurrentLocale()
Returns the setter for the root runtime locale.
useAcceptedLocales()
روٹ رن ٹائم سے حل شدہ accepted locale list پڑھتا ہے۔
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