# react-native: useLocaleSelector URL: https://generaltranslation.com/ja/docs/react-native/api/helpers/use-locale-selector.mdx --- title: useLocaleSelector description: useLocaleSelector Hook のAPIリファレンス --- {/* 自動生成: 直接編集せず、代わりに content/docs-templates/ 内の template を編集してください。 */} ## 概要 このHookは、現在のロケール、ロケールの一覧、[`useSetLocale`](/docs/react-native/api/helpers/use-set-locale) Hook、およびロケールのプロパティを取得する関数を返します。 独自のロケールセレクターコンポーネントを簡単に作成できるようにするためのものです。 独自に実装したくない場合は、代わりに [``](/docs/react-native/api/components/locale-selector) コンポーネントを使用できます。 ## リファレンス ### 戻り値 現在のロケール、ロケールの一覧、[`useSetLocale`](/docs/react-native/api/helpers/use-set-locale) Hook、ロケールのプロパティを取得する関数を含むオブジェクト。 *** ## 例 ### `` これは [``](/docs/react-native/api/components/locale-selector) コンポーネントの実装例です。 ```jsx export default function LocaleSelector({ locales: _locales, ...props }: { locales?: string[]; [key: string]: any; }): React.JSX.Element | null { // ロケールセレクターのプロパティを取得 const { locale, locales, setLocale, getLocaleProperties } = useLocaleSelector( _locales ? _locales : undefined ); // 表示名を取得 const getDisplayName = (locale: string) => { return capitalizeLanguageName( getLocaleProperties(locale).nativeNameWithRegionCode ); }; // localesが返されない場合は何もレンダリングしないか、適切に処理する if (!locales || locales.length === 0 || !setLocale) { return null; } return ( ); } ``` *** ## 注記 * この Hook はクライアント側でのみ使用できます。 * ロケールコードについて詳しくは、[こちら](/docs/core/locales)を参照してください。 ## 次のステップ * [``](/docs/react-native/api/components/locale-selector) コンポーネントの詳細を確認してください。 * [`useLocale`](/docs/react-native/api/helpers/use-locale) Hook の詳細を確認してください。