React reference
Ways
Root props
Common root props:
| Prop | टाइप | नोट्स |
|---|---|---|
apiKey | स्ट्रिंग | आवश्यक। |
locale | स्ट्रिंग | Current target locale. |
baseLocale | स्ट्रिंग | Source locale. |
persistLocaleCookie | boolean | Default locale-cookie policy for the root runtime. |
context | string | object | Optional root context. |
cacheTtl | संख्या | Cache TTL for translation requests. |
messageFormatter | 'waysParser' | 'none' | fn | Parser or formatter override. |
suspenseTimeoutMs | संख्या | फ़ॉलबैक रेंडरिंग जारी रहने से पहले render blocking के लिए अधिकतम अनुमत समय। |
fetcher | fetch का प्रकार | कस्टम फ़ेच कार्यान्वयन. |
स्वीकृतLocales | string[] | Optional explicit locale list. |
Scoped props
Nested scopes accept:
| Prop | टाइप | नोट्स |
|---|---|---|
context | string | object | आवश्यक। |
locale | स्ट्रिंग | उपलब्ध है, लेकिन isolated locale session के लिए nested root का उपयोग करें। |
baseLocale | स्ट्रिंग | subtree के लिए वैकल्पिक source-locale ओवरराइड। |
components | Record<string, component> | Components used inside translatable content. |
T
T is the JSX-first translation primitive.
| Prop | टाइप | नोट्स |
|---|---|---|
children | ReactNode | आवश्यक। |
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()
मौजूदा root runtime के लिए selected locale पढ़ता है।
useTargetLocale()
मौजूदा scope के लिए सक्रिय target locale पढ़ता है।
useBaseLocale()
मौजूदा root runtime के लिए source locale पढ़ता है।
useSetCurrentLocale()
Returns the setter for the root runtime locale.
useAcceptedLocales()
root runtime से resolved accepted locale list पढ़ता है।
LanguageSwitcher
Common props:
| Prop | टाइप | नोट्स |
|---|---|---|
currentLocale | स्ट्रिंग | 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