The I18NProvider is used to match locale aware routes, detect the locale from the pathname and hostname and normalize the pathname by removing the locale prefix.

Constructors

Properties

Methods

  • Analyzes the pathname for a locale and returns the pathname without it.

    Parameters

    • pathname: string

      The pathname that could contain a locale prefix.

    • Optional options: LocaleAnalysisOptions

      The options to use when matching the locale.

    Returns LocaleAnalysisResult

    The matched locale and the pathname without the locale prefix (if any).

  • Detects the domain locale from the hostname and the detected locale if provided.

    Parameters

    • Optional hostname: string

      The hostname to detect the domain locale from, this must be lowercased.

    • Optional detectedLocale: string

      The detected locale to use if the hostname does not match.

    Returns undefined | DomainLocale

    The domain locale if found, undefined otherwise.

  • Pulls the pre-computed locale and inference results from the query object.

    Parameters

    • pathname: string

      the pathname that could contain a locale prefix

    • query: NextParsedUrlQuery

      the query object

    Returns LocaleAnalysisResult

    the locale analysis result

  • Validates that the locales in the query object are valid.

    Parameters

    Returns boolean

    true if the locale is valid, false otherwise.