GT ClassMethodsLocales

getRegionProperties

API reference for the GT getRegionProperties method

Overview

The getRegionProperties method retrieves detailed information for a region code, including its localised name and corresponding emoji flag. It provides a convenient way to obtain region‑specific display information for building internationalised 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

Parameter descriptions

ParameterDescription
regionISO 3166-1 alpha-2 or UN M.49 region code. If not provided, uses the region from the instance’s target locale
customMappingOptional custom region mapping to override default region names and emojis

Returns

{ code: string; name: string; emoji: string } - Object containing:

  • code: The input region code
  • name: Localised region name in the target locale’s language
  • emoji: Associated emoji flag or symbol

Examples

Basic Region Information

const gt = new GT({
  sourceLocale: 'en-US',
  targetLocale: 'en-GB'
});

// 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 the Intl.DisplayNames API for localised region names
  • Supports both ISO 3166-1 alpha-2 and UN M.49 region codes
  • Custom mappings override default names and emojis
  • Automatically detects the region from the target locale if no parameter is provided
  • Falls back to the region code as the name if display name resolution fails

Next steps

How is this guide?

getRegionProperties