# generaltranslation: General Translation Core SDK: isValidLocale URL: https://generaltranslation.com/en-US/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 properly formatted and recognized 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 ### Parameters description | 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 mapping locales always validate as true (bypass standard validation) - Supports private-use language codes (qaa-qtz) - Returns `false` for malformed or unrecognized locale codes ## Next steps - **[Get locale properties with getLocaleProperties](/docs/core/class/methods/locales/get-locale-properties)** - **[Determine 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 CustomMapping type](/docs/core/types/custom-mapping)**