Auth0 Universal Components
    Preparing search index...

    Function createI18nService

    • Creates an internationalization (i18n) service with translation loading and management capabilities.

      This factory function initializes the i18n service with language support, translation loading, and runtime language switching. It supports namespace-based translations, variable substitution, and safe HTML rendering through Trans component pattern.

      Parameters

      • options: I18nInitOptions = {}

        Optional configuration for i18n initialization

        Configuration options for initializing the i18n service.

        • OptionalcurrentLanguage?: string

          The current/preferred language code (e.g., 'en-US', 'es-ES')

        • OptionalfallbackLanguage?: string

          The fallback language code if current language fails to load

      Returns Promise<I18nServiceInterface>

      Promise resolving to a fully configured i18n service interface

      // Basic initialization
      const i18nService = await createI18nService();

      // With custom language
      const i18nService = await createI18nService({
      currentLanguage: 'es-ES',
      fallbackLanguage: 'en-US'
      });

      // Use translations with safe HTML rendering
      const t = i18nService.translator('mfa');
      const message = t('enrollment.success'); // Plain text
      const elements = t.trans('help.link', {
      components: {
      link: (children) => <a href="/help">{children}</a>
      }
      }); // Safe HTML components