getRegionProperties
API Reference for the GT getRegionProperties method
Overview
The getRegionProperties method retrieves detailed information about a region code, including its localized name and associated emoji flag.
It provides a convenient way to get region-specific display information for building internationalized user interfaces.
const gt = new GT({
sourceLocale: 'en-US',
targetLocale: 'fr-FR'
});
// Get region properties
const usProps = gt.getRegionProperties('US');
console.log(usProps);
// { code: 'US', name: 'United States', emoji: 'πΊπΈ' }
const frProps = gt.getRegionProperties('FR');
console.log(frProps);
// { code: 'FR', name: 'France', emoji: 'π«π·' }
// Auto-detect from current locale
const currentRegion = gt.getRegionProperties(); // Uses targetLocale's region
console.log(currentRegion);
// { code: 'FR', name: 'France', emoji: 'π«π·' }Reference
Parameters
Prop
Type
Parameters Description
| Parameter | Description |
|---|---|
region | ISO 3166-1 alpha-2 or UN M.49 region code. If not provided, uses the region from the instance's target locale |
customMapping | Optional custom region mapping to override default region names and emojis |
Returns
{ code: string; name: string; emoji: string } - Object containing:
code: The input region codename: Localized region name in the target locale languageemoji: Associated emoji flag or symbol
Examples
Basic Region Information
const gt = new GT({
sourceLocale: 'en-US',
targetLocale: 'en-US'
});
// Common region codes
console.log(gt.getRegionProperties('US')); // { code: 'US', name: 'United States', emoji: 'πΊπΈ' }
console.log(gt.getRegionProperties('GB')); // { code: 'GB', name: 'United Kingdom', emoji: 'π¬π§' }
console.log(gt.getRegionProperties('DE')); // { code: 'DE', name: 'Germany', emoji: 'π©πͺ' }
console.log(gt.getRegionProperties('JP')); // { code: 'JP', name: 'Japan', emoji: 'π―π΅' }Notes
- Uses
Intl.DisplayNamesAPI for localized region names - Supports both ISO 3166-1 alpha-2 and UN M.49 region codes
- Custom mappings override default names and emojis
- Automatically detects region from target locale if no parameter provided
- Falls back to region code as name if display name resolution fails
Next Steps
- Get full locale properties with
getLocaleProperties - Get locale emoji with
getLocaleEmoji
How is this guide?