# gt-react: General Translation React SDK: useSetLocale URL: https://generaltranslation.com/zh/docs/react/api/helpers/use-set-locale.mdx --- title: useSetLocale description: useSetLocale Hook 的 API 参考文档 --- {/* 自动生成:请勿直接编辑。请改为编辑 content/docs-templates/ 中的 template。 */} ## 概述 `useSetLocale` Hook 用于设置用户的区域设置。 该 Hook 仅适用于客户端,且必须包裹在 [``](/docs/react/api/components/gtprovider) 组件中。 ## 参考文档 ### 返回值 一个用于设置用户区域设置的函数。 *** ## 示例 ### 基本用法 ```jsx import { useSetLocale } from 'gt-react'; export default function MyComponent() { const setLocale = useSetLocale(); return ; } ``` *** ## 说明 * `useSetLocale` 用于设置用户的区域设置。 * 在[此处](/docs/core/locales)详细了解区域设置代码。 ## 后续步骤 * 详细了解 [``](/docs/react/api/components/gtprovider) 组件。 * 详细了解 [`useLocale`](/docs/react/api/helpers/use-locale) Hook。