React reference

Ways

Root props

Common root props:

PropUriMga Tala
apiKeystringKinakailangan.
lokalidadstringKasalukuyang target na locale.
baseLocalestringPinagmulan ng lokalidad.
persistLocaleCookiebooleanDefault locale-cookie policy for the root runtime.
kontekstostring | objectOptional root context.
cacheTtlnumeroCache TTL for translation requests.
messageFormatter'waysParser' | 'none' | fnParser or formatter override.
suspenseTimeoutMsnumeroPinakamahabang oras na pinapayagang mag-block ang render bago magpatuloy ang fallback rendering.
fetchertypeof fetchPasadyang implementasyon ng pagkuha.
acceptedLocalesstring[]Optional explicit locale list.

Scoped props

Nested scopes accept:

PropUriMga Tala
kontekstostring | objectKinakailangan.
lokalidadstringAvailable, pero gumamit ng nested root para sa isang hiwalay na locale session.
baseLocalestringOpsyonal na override ng source locale para sa subtree.
componentsRecord<string, component>Components used inside translatable content.

T

T is the JSX-first translation primitive.

PropUriMga Tala
childrenReactNodeKinakailangan.
varsRecord<string, unknown>Interpolation input.
kontekstostring | 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()

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:

PropUriMga Tala
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
Pinapalitan ang wika
Sanggunian sa React