Function availableLocales

  • Gets locales that are in both the user's environment and the app translations

    Parameters

    • userLocales: string[]

      The locales from the user's environment

    • appLocales: string[]

      The locales translated by the app

    • Optional options: PreferredLocaleOptions = {}

      Options for the function

    Returns string[]

    An array of locales that are in both

    Example

    import { availableLocales } from 'preferred-locale'

    availableLocales(['en-US', 'fr-FR'], ['en-US', 'fr-FR', 'de-DE', 'az-Cyrl-AZ']) // ['en-US', 'fr-FR']

    availableLocales(['en-GB', 'fr-FR'], ['en-US', 'fr-FR']) // ['en-US', 'fr-FR']

    availableLocales(['es-MX'], ['es-ES'], {
    regionLowerCase: true
    }) // ['es-es']