# General Translation React SDKs (gt-react, gt-next, gt-react-native): getLocaleDirection
URL: https://generaltranslation.com/ja/docs/react/nextjs/reference/functions/get-locale-direction.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: General Translation を使用して、Next.js App Router のロケールのテキスト方向を取得します。getLocaleDirection の API リファレンス。

`getLocaleDirection` 関数は、現在のリクエストのロケール、または指定したロケールに対して `'ltr'` または `'rtl'` を返します。App Router のサーバーコードでは、`gt-next/server` からインポートしてください。

`getLocaleDirection` はサーバー専用で、Pages Router では動作しません。

## 概要 [#overview]

```tsx
import { getLocaleDirection } from 'gt-next/server';

const currentDirection = await getLocaleDirection();
const arabicDirection = getLocaleDirection('ar'); // 'rtl'（右から左）
```

## パラメータ [#parameters]

| パラメータ    | 説明                | 型        | 任意 | デフォルト         |
| -------- | ----------------- | -------- | -- | ------------- |
| `locale` | テキスト方向を返すロケール。 | `string` | はい | 現在のリクエストのロケール |

## 戻り値 [#returns]

**型** `locale` が指定されている場合は `'ltr' | 'rtl'`、省略した場合は `Promise<'ltr' | 'rtl'>`

`locale` を渡すと、値は同期的に返されます。省略すると、現在のリクエストのロケールが非同期に返されます。

## 例 [#example]

```tsx title="app/[locale]/layout.tsx"
import { getLocale, getLocaleDirection } from 'gt-next/server';

export default async function LocaleLayout({ children }) {
  const [locale, direction] = await Promise.all([
    getLocale(),
    getLocaleDirection(),
  ]);
  return <html lang={locale} dir={direction}>{children}</html>;
}
```

## Sitemap

See the full [sitemap](https://generaltranslation.com/sitemap.md) for all pages.
