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 | フォールバックレンダリングが継続される前に許容される最大レンダーブロック時間。 |
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 | 利用可能ですが、分離されたロケールセッションにはネストされたルートを使用してください。 |
baseLocale | string | サブツリーに対するオプションのソースロケールの上書き。 |
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()
現在のスコープに対する、アクティブなターゲットロケールを読み取ります。
useBaseLocale()
現在のルートランタイムのソースロケールを読み取ります。
useSetCurrentLocale()
Returns the setter for the root runtime locale.
useAcceptedLocales()
ルートランタイムから解決済みの承認ロケール一覧を読み取ります。
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