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.
suspenseTimeoutMsnumberفال بیک رینڈرنگ جاری رکھنے سے پہلے render blocking کے لیے زیادہ سے زیادہ وقت۔
fetchertypeof fetchCustom fetch implementation.
acceptedLocalesstring[]Optional explicit locale list.

Scoped props

Nested scopes accept:

PropTypeNotes
contextstring | objectRequired.
localestringدستیاب ہے، مگر الگ تھلگ لوکیل سیشن کے لیے nested root استعمال کریں۔
baseLocalestringsubtree کے لیے اختیاری source-locale override۔
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()

موجودہ روٹ رن ٹائم کے لیے منتخب لوکیل پڑھتا ہے۔

useTargetLocale()

موجودہ scope کے لیے فعال target locale پڑھتا ہے۔

useBaseLocale()

موجودہ روٹ رن ٹائم کے لیے source locale پڑھتا ہے۔

useSetCurrentLocale()

Returns the setter for the root runtime locale.

useAcceptedLocales()

روٹ رن ٹائم سے حل شدہ accepted locale list پڑھتا ہے۔

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
Changing language
React حوالہ