# General Translation Platform: getLocaleName URL: https://generaltranslation.com/en-GB/docs/platform/core/reference/gt-class-methods/locales/get-locale-name.mdx --- title: getLocaleName description: Return a human-readable locale name. API reference for getLocaleName. --- Retrieves the display name of a locale code on a [GT](/docs/platform/core/reference/gt-class/constructor) instance using the `Intl.DisplayNames` API. General Translation returns a human-readable name for any valid BCP-47 locale code, localised according to the instance's source locale. ## Overview [#overview] Call `getLocaleName` on a [`GT`](/docs/platform/core/reference/gt-class/constructor) instance with an optional locale code. If omitted, it uses the instance's `targetLocale`. ```typescript const gt = new GT({ sourceLocale: 'en', targetLocale: 'es' }); const name = gt.getLocaleName('fr-CA'); console.log(name); // "Canadian French" ``` Signature: ```typescript getLocaleName(locale?: string): string ``` *Note: `getLocaleName` runs locally using `Intl.DisplayNames` and does not require an API key. It uses the instance's `targetLocale` when `locale` is omitted. For lookups without a `GT` instance, see the standalone [`getLocaleName`](/docs/platform/core/reference/utility-functions/locales/get-locale-name).* ## How it works [#how-it-works] ### Display language The display name is localised according to: 1. The instance's `sourceLocale` (if configured). 2. The library default locale (`'en'`). ### Custom mapping integration * Custom locale mappings are checked first. * If a custom name is defined, it takes precedence. * Otherwise, it falls back to `Intl.DisplayNames` for standard BCP-47 codes. ### Missing locale Throws an `Error` if no locale is provided and the instance has no `targetLocale` configured. Returns an empty string if no name is found for a valid locale. ## Parameters [#parameters] | Parameter | Description | Type | Optional | Default | | ------------------- | ----------------------------------------------- | -------- | -------- | ------------------- | | [`locale`](#locale) | BCP-47 locale code to get the display name for. | `string` | Yes | `this.targetLocale` | ### `locale` [#locale] **Type** `string` · **Optional** · **Default** `this.targetLocale` BCP-47 locale code to get the display name for. If not provided, uses the instance's `targetLocale`. ## Returns [#returns] **Type** `string` The localised display name of the locale. Throws an `Error` if no locale is provided and no `targetLocale` is configured for the instance. ## Examples [#examples] ```typescript const gt = new GT({ sourceLocale: 'en', targetLocale: 'fr' }); // Get name for target locale console.log(gt.getLocaleName()); // "French" // Get names for other locales console.log(gt.getLocaleName('es')); // "Spanish" console.log(gt.getLocaleName('de')); // "German" console.log(gt.getLocaleName('ja')); // "Japanese" ``` ## Notes [#notes] * The method uses the instance's `sourceLocale` to determine the display language. * Custom mapping names take precedence over standard `Intl.DisplayNames`.