# gt-next: General Translation Next.js SDK: getLocales URL: https://generaltranslation.com/zh/docs/next/api/helpers/get-locales.mdx --- title: getLocales description: getLocales 服务端方法的 API 参考 --- ## 概述 在服务端渲染期间,`getLocales` 函数会获取为你的应用配置的受支持区域设置列表。 `getLocales` 是服务端方法,只能在服务端组件中使用。 如需在客户端使用,请参阅 [`useLocales`](/docs/next/api/helpers/use-locales)。 ## 参考 ### 返回值 `string[]` — 一个 BCP 47 [区域设置代码](/docs/core/locales)数组,表示支持的区域设置,例如 `['en-US', 'fr', 'ja']`。 *** ## 示例 ### 基本用法 ```jsx title="LocaleList.jsx" copy import { getLocales } from 'gt-next/server'; export default function LocaleList() { const locales = getLocales(); // [!code highlight] return ( ); } ``` *** ## 说明 * 支持的区域设置在你的 [`gt.config.json`](/docs/next/api/config/gt-config-json) 文件中配置。 * `getLocales` 仅可在服务端使用。对于客户端组件,请使用 [`useLocales`](/docs/next/api/helpers/use-locales)。 ## 后续步骤 * 了解如何在 [`gt.config.json`](/docs/next/api/config/gt-config-json) 中配置支持的区域设置。 * 客户端对应的版本请参见 [`useLocales`](/docs/next/api/helpers/use-locales)。