getLocaleEmoji
API Reference for the standalone getLocaleEmoji function
Overview
The standalone getLocaleEmoji function retrieves an emoji flag or symbol for a locale code without requiring a GT class instance.
It returns appropriate flag emojis for countries and territories based on the locale's region, with support for custom emoji mappings.
import { getLocaleEmoji } from 'generaltranslation';
const emoji = getLocaleEmoji('fr-CA');
console.log(emoji); // "π¨π¦" (Canadian flag)
const usEmoji = getLocaleEmoji('en-US');
console.log(usEmoji); // "πΊπΈ" (US flag)Reference
Parameters
Prop
Type
Parameters Description
| Parameter | Description | 
|---|---|
| locale | BCP-47 locale code to get emoji for | 
| customMapping | Optional custom mapping for locale codes and emoji overrides | 
Returns
string - Emoji flag or symbol representing the locale:
- Country/territory flag emoji for locales with regions (e.g., πΊπΈ,π«π·,π―π΅)
- Custom emoji if defined in mapping
- Default flag emoji (π³οΈ) for unrecognized locales
Examples
Basic Emoji Retrieval
import { getLocaleEmoji } from 'generaltranslation';
// Common country flags
console.log(getLocaleEmoji('en-US')); // "πΊπΈ"
console.log(getLocaleEmoji('fr-FR')); // "π«π·"
console.log(getLocaleEmoji('de-DE')); // "π©πͺ"
console.log(getLocaleEmoji('ja-JP')); // "π―π΅"
console.log(getLocaleEmoji('zh-CN')); // "π¨π³"
// Regions with multiple languages
console.log(getLocaleEmoji('en-CA')); // "π¨π¦"
console.log(getLocaleEmoji('fr-CA')); // "π¨π¦"
console.log(getLocaleEmoji('de-CH')); // "π¨π"
console.log(getLocaleEmoji('fr-CH')); // "π¨π"Notes
- Returns flag emojis using Unicode Regional Indicator Symbols
- Custom mapping emojis take priority over region-based selection
- Supports all ISO 3166-1 alpha-2 region codes for comprehensive coverage
Next Steps
- Use GT class method getLocaleEmoji
- Get locale properties with getLocaleProperties
- Get locale names with getLocaleName
- Validate locales with isValidLocale
How is this guide?

