# generaltranslation: General Translation Core SDK: getLocaleName URL: https://generaltranslation.com/en-GB/docs/core/class/methods/locales/get-locale-name.mdx --- title: getLocaleName description: API reference for the GT getLocaleName method --- ## Overview The `getLocaleName` method retrieves the display name of a locale code using the `Intl.DisplayNames` API. It returns a human-readable name for any valid BCP-47 locale code, localised according to the instance's source locale. ```typescript const gt = new GT({ sourceLocale: 'en', targetLocale: 'es' }); const name = gt.getLocaleName('fr-CA'); console.log(name); // "French (Canada)" ``` *** ## Reference ### Parameters ### Parameter descriptions | Parameter | Description | | --------- | ------------------------------------------------------------------------------------------------------- | | `locale` | BCP-47 locale code to get the display name for. If not provided, uses the instance's `targetLocale` | ### Returns `string` - The localised display name of the locale. ### Throws * `Error` - If no locale is provided and the instance has no `targetLocale` configured *** ## Behaviour ### Display language The display name is localised based on: 1. Instance's `sourceLocale` (if configured) 2. Library default locale ('en') ### Custom mapping integration * Custom locale mappings are checked first * If a custom name is defined, it takes precedence * Falls back to `Intl.DisplayNames` for standard BCP-47 codes *** ## Examples ```typescript const gt = new GT({ sourceLocale: 'en', targetLocale: 'fr' }); // Get name for target locale console.log(gt.getLocaleName()); // "French (France)" // Get names for other locales console.log(gt.getLocaleName('es')); // "Spanish (Spain)" console.log(gt.getLocaleName('de')); // "German (Germany)" console.log(gt.getLocaleName('ja')); // "Japanese (Japan)" ``` *** ## Notes * The method uses the instance's `sourceLocale` to determine the display language * Custom mapping names take precedence over standard Intl.DisplayNames ## Next steps * Get the locale emoji with [`getLocaleEmoji`](/docs/core/class/methods/locales/get-locale-emoji) * Get comprehensive locale information with [`getLocaleProperties`](/docs/core/class/methods/locales/get-locale-properties) * [Learn about the CustomMapping type](/docs/core/types/custom-mapping)