# General Translation React SDKs (gt-react, gt-next): getLocaleDirection URL: https://generaltranslation.com/zh/docs/react/nextjs/reference/functions/get-locale-direction.mdx --- title: getLocaleDirection 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'>` 传入区域设置会同步返回;省略时则会异步解析当前请求的区域设置。 ## 示例 [#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 {children}; } ```