שאלו את שאלתכם וקבלו סיכום של המסמך על ידי הפניה לדף הזה ולספק ה-AI שתבחרו
היסטוריית גרסאות
- "Deprecate getConfiguration in favor of direct imports from intlayer"v9.5.925.9.2026
- "Init history"v5.5.1029.6.2025
התוכן של הדף הזה תורגם באמצעות AI.
צפייה בגרסה האחרונה של התוכן המקורי באנגליתאם יש לכם רעיון לשיפור התיעוד הזה, אל תהססו לתרום על ידי הגשת Pull Request ב-GitHub.
קישור GitHub לתיעודהעתקת ה-Markdown של המסמך ללוח
Documentation: getConfiguration Function in intlayer (Deprecated)
WARNING Deprecated: The
getConfigurationfunction is deprecated. The new recommended way is to import{ availableLocale, defaultLocales, internationalization, routing, ... }(such asdefaultLocale,locales,requiredLocales, oreditor) directly from'intlayer':typescriptהעתקת קודהעתקת הקוד ללוח
Description
The getConfiguration function retrieves the entire configuration for the intlayer application by extracting environment variables. This function provides the flexibility to use the same configuration on both the client and server sides, ensuring consistency across the application.
Parameters
The function does not take any parameters. Instead, it uses environment variables for configuration.
Returns
- Type:
IntlayerConfig - Description: An object containing the complete configuration for
intlayer. The configuration includes the following sections:internationalization: Settings related to locales and strict mode.middleware: Settings related to URL and cookie management.content: Settings related to content files, directories, and patterns.editor: Editor-specific configurations.
See Intlayer configuration documentation for more details.
Example Usage
Retrieving the Full Configuration
העתקת הקוד ללוח
import { getConfiguration } from "intlayer";
const config = getConfiguration();
console.log(config);
// Output:
// {
// internationalization: { ... },
// middleware: { ... },
// content: { ... },
// editor: { ... }
// }
Extracting availableLocales and defaultLocale
TIP Recommended Way: Instead of extracting locales from
getConfiguration(), import them directly from'intlayer':typescriptהעתקת קודהעתקת הקוד ללוח
The internationalization section of the configuration provides locale-related settings such as locales (available locales) and defaultLocale (fallback language).
העתקת הקוד ללוח
import { getConfiguration } from "intlayer";
const { internationalization, middleware } = getConfiguration();
const { locales: availableLocales, defaultLocale } = internationalization;
const { cookieName } = middleware;
console.log(availableLocales); // Output example: ["en", "fr", "es"]
console.log(defaultLocale); // Output example: "en"
console.log(cookieName); // Output: "INTLAYER_LOCALE"
Notes
- Ensure that all required environment variables are correctly set before calling this function. Missing variables will cause errors during initialization.
- This function can be used on both client and server sides, making it a versatile tool for managing configurations in a unified manner.
Usage in Applications
The getConfiguration function is a cornerstone utility for initializing and managing the configuration of an intlayer application. By providing access to settings like locales, middleware, and content directories, it ensures consistency and scalability across multilingual and content-driven applications.
