# generaltranslation: General Translation Core SDK: isValidLocale URL: https://generaltranslation.com/en-GB/docs/core/class/methods/locales/is-valid-locale.mdx --- title: isValidLocale description: API reference for the GT isValidLocale method --- ## Overview The `isValidLocale` method validates whether a locale code is correctly formatted and recognised as a valid BCP-47 locale. It checks locale structure, language recognition, and regional/script validity using the `Intl` APIs, with support for custom locale mappings. *** ## Reference ### Parameters ### Parameter descriptions | Parameter | Description | | --------------- | ----------------------------------------------------------------------------------------------------------------------- | | `locale` | BCP-47 locale code to validate. If not provided, uses the instance's `targetLocale` | | `customMapping` | Optional custom mapping to check for additional valid locales. If not provided, uses the instance's `customMapping` | ### Returns `boolean` - `true` if the locale is valid, `false` otherwise ### Throws * `Error` - If no locale is provided and the instance has no `targetLocale` configured *** ## Examples ```typescript const gt = new GT({ sourceLocale: 'en', targetLocale: 'es' }); const isValid = gt.isValidLocale('en-US'); console.log(isValid); // true const isInvalid = gt.isValidLocale('invalid-locale'); console.log(isInvalid); // false ``` *** ## Notes * Performs comprehensive BCP-47 locale validation using browser Intl APIs * Custom-mapped locales always validate as true (bypassing standard validation) * Supports private-use language codes (qaa-qtz) * Returns `false` for malformed or unrecognised locale codes ## Next steps * **[Get locale properties with getLocaleProperties](/docs/core/class/methods/locales/get-locale-properties)** * **[Determine the best locale with determineLocale](/docs/core/class/methods/locales/determine-locale)** * **[Get locale names with getLocaleName](/docs/core/class/methods/locales/get-locale-name)** * **[Learn about the CustomMapping type](/docs/core/types/custom-mapping)**