# General Translation Platform: getLocaleEmoji URL: https://generaltranslation.com/en-US/docs/platform/core/reference/gt-class-methods/locales/get-locale-emoji.mdx --- title: getLocaleEmoji description: Return an emoji marker for a locale or region. API reference for getLocaleEmoji. --- Retrieves an emoji flag or symbol for a locale code on a [GT](/docs/platform/core/reference/gt-class/constructor) instance, based on its region. General Translation returns country and territory flag emojis, with fallbacks for languages without a specific region and support for custom emoji through mappings. ## Overview [#overview] Call `getLocaleEmoji` on a [`GT`](/docs/platform/core/reference/gt-class/constructor) instance with an optional locale code. When omitted, it uses the instance's `targetLocale`. ```typescript const gt = new GT({ sourceLocale: 'en', targetLocale: 'fr-CA' }); const emoji = gt.getLocaleEmoji('fr-CA'); console.log(emoji); // "πŸ‡¨πŸ‡¦" (Canadian flag) const usEmoji = gt.getLocaleEmoji('en-US'); console.log(usEmoji); // "πŸ‡ΊπŸ‡Έ" (US flag) const enEmoji = gt.getLocaleEmoji('en'); console.log(enEmoji); // "πŸ‡ΊπŸ‡Έ" (US flag) ``` Signature: ```typescript getLocaleEmoji(locale?: string): string ``` *Note: `getLocaleEmoji` runs locally 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 [`getLocaleEmoji`](/docs/platform/core/reference/utility-functions/locales/get-locale-emoji).* ## How it works [#how-it-works] - **Region-based selection.** Uses the locale's region code (when available) to select a flag emoji, built from Unicode regional indicator symbols. - **Custom mapping priority.** Emojis defined in a [`CustomMapping`](/docs/platform/core/reference/types/custom-mapping) take priority over region-based selection. - **Fallbacks.** Returns a language-specific emoji for some languages without regions, and the default globe emoji `🌍` for unrecognized or invalid locales. - **Missing locale.** Throws an `Error` if no locale is provided and the instance has no `targetLocale` configured. ## Parameters [#parameters] | Parameter | Description | Type | Optional | Default | | --- | --- | --- | --- | --- | | [`locale`](#locale) | BCP-47 locale code to get the emoji for. | `string` | Yes | `this.targetLocale` | ### `locale` [#locale] **Type** `string` Β· **Optional** Β· **Default** `this.targetLocale` BCP-47 locale code to get the emoji for. If not provided, uses the instance's `targetLocale`. ## Returns [#returns] **Type** `string` An emoji flag or symbol representing the locale: - Country/territory flag emoji for locales with regions (for example, `πŸ‡ΊπŸ‡Έ`, `πŸ‡«πŸ‡·`, `πŸ‡―πŸ‡΅`). - Language-specific emoji for some languages without regions. - Default globe emoji (`🌍`) for unrecognized locales. Throws an `Error` if no locale is provided and the instance has no `targetLocale` configured. ## Examples [#examples] ```typescript const gt = new GT({ sourceLocale: 'en', targetLocale: 'es' }); // Get emoji for target locale console.log(gt.getLocaleEmoji()); // "πŸ‡ͺπŸ‡Έ" (uses targetLocale 'es') // Get emojis for different locales console.log(gt.getLocaleEmoji('en-US')); // "πŸ‡ΊπŸ‡Έ" console.log(gt.getLocaleEmoji('fr-FR')); // "πŸ‡«πŸ‡·" console.log(gt.getLocaleEmoji('de-DE')); // "πŸ‡©πŸ‡ͺ" console.log(gt.getLocaleEmoji('ja-JP')); // "πŸ‡―πŸ‡΅" console.log(gt.getLocaleEmoji('zh-CN')); // "πŸ‡¨πŸ‡³" ``` ## Notes [#notes] - Returns flag emojis based on the locale's region code when available. - Custom mapping emojis take priority over region-based selection. - Uses Unicode regional indicator symbols for flag generation. - Defaults to `🌍` (globe) for unrecognized or invalid locales. - Compatible with all modern browsers and operating systems that support Unicode emojis.