React reference
Ways
Root props
Common root props:
| Prop | Uri | Mga Tala |
|---|---|---|
apiKey | string | Kinakailangan. |
lokalidad | string | Kasalukuyang target na locale. |
baseLocale | string | Pinagmulan ng lokalidad. |
persistLocaleCookie | boolean | Default locale-cookie policy for the root runtime. |
konteksto | string | object | Optional root context. |
cacheTtl | numero | Cache TTL for translation requests. |
messageFormatter | 'waysParser' | 'none' | fn | Parser or formatter override. |
suspenseTimeoutMs | numero | Pinakamahabang oras na pinapayagang mag-block ang render bago magpatuloy ang fallback rendering. |
fetcher | typeof fetch | Pasadyang implementasyon ng pagkuha. |
acceptedLocales | string[] | Optional explicit locale list. |
Scoped props
Nested scopes accept:
| Prop | Uri | Mga Tala |
|---|---|---|
konteksto | string | object | Kinakailangan. |
lokalidad | string | Available, pero gumamit ng nested root para sa isang hiwalay na locale session. |
baseLocale | string | Opsyonal na override ng source locale para sa subtree. |
components | Record<string, component> | Components used inside translatable content. |
T
T is the JSX-first translation primitive.
| Prop | Uri | Mga Tala |
|---|---|---|
children | ReactNode | Kinakailangan. |
vars | Record<string, unknown> | Interpolation input. |
konteksto | 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()
Binabasa ang napiling locale para sa kasalukuyang root runtime.
useTargetLocale()
Binabasa ang aktibong target locale para sa kasalukuyang scope.
useBaseLocale()
Binabasa ang source locale para sa kasalukuyang root runtime.
useSetCurrentLocale()
Returns the setter for the root runtime locale.
useAcceptedLocales()
Binabasa ang na-resolve na tinatanggap na listahan ng locale mula sa root runtime.
LanguageSwitcher
Common props:
| Prop | Uri | Mga Tala |
|---|---|---|
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