מחבר:
הפנו את עוזר ה-AI המועדף עליכם למסמך הזהChatGPTClaudeDeepSeekGoogle AI modeGeminiPerplexityMistralGrok
שאלו את שאלתכם וקבלו סיכום של המסמך על ידי הפניה לדף הזה ולספק ה-AI שתבחרו
היסטוריית גרסאות
- "Init doc"v9.5.519.9.2026
התוכן של הדף הזה תורגם באמצעות AI.
צפייה בגרסה האחרונה של התוכן המקורי באנגליתעריכת המסמך הזה
אם יש לכם רעיון לשיפור התיעוד הזה, אל תהססו לתרום על ידי הגשת Pull Request ב-GitHub.
קישור GitHub לתיעודנוצר:2026-09-19עדכון אחרון:2026-09-19
העתקה
העתקת ה-Markdown של המסמך ללוח
useLocale Hook Documentation
The useLocale hook from remix-intlayer provides access to the locale of the HTTP request currently being processed, along with the project's configured default and available locales.
Usage
In a Remix component (for example a language switcher):
src/components/LocaleSwitcher.tsx
העתקת קוד
העתקת הקוד ללוח
In a route handler:
src/server.ts
העתקת קוד
העתקת הקוד ללוח
Return Values
The hook returns an object of type UseLocaleResult:
הצגת כל תוכן הטבלה
פתיחת הטבלה בחלון כדי לראות את כל תוכן הנתונים בבירור
| Property | Type | Description |
|---|---|---|
locale | DeclaredLocales | The locale resolved for the current request. |
defaultLocale | DeclaredLocales | The default fallback locale configured in intlayer.config.ts. |
availableLocales | DeclaredLocales[] | Array of all available locales configured in intlayer.config.ts. |
Description
- Request-Scoped Resolution: In an active request handled by the
intlayer()middleware,useLocalereads the resolved locale from the request storage. - Graceful Fallback: If called outside of a request context (such as during initialization scripts or test suites), it defaults to the configured
defaultLocale.
