Utility FunctionsLocales

getRegionProperties

API Reference for the getRegionProperties function

Overview

The getRegionProperties function retrieves detailed information about a region code without requiring a GT class instance.


Reference

Parameters

Prop

Type

Returns

{ code: string; name: string; emoji: string } - Region information object


Examples

import { getRegionProperties } from 'generaltranslation';

// Get region properties with English names
console.log(getRegionProperties('US', 'en-US'));
// { code: 'US', name: 'United States', emoji: 'πŸ‡ΊπŸ‡Έ' }

console.log(getRegionProperties('JP', 'en-US'));
// { code: 'JP', name: 'Japan', emoji: 'πŸ‡―πŸ‡΅' }

// Get region properties with localized names
console.log(getRegionProperties('US', 'de-DE'));
// { code: 'US', name: 'Vereinigte Staaten', emoji: 'πŸ‡ΊπŸ‡Έ' }

Notes

  • Uses Intl.DisplayNames API for localized region names
  • Supports ISO 3166-1 alpha-2 and UN M.49 region codes
  • Custom mappings can override default names and emojis
  • Falls back to region code if display name resolution fails
  • No external dependencies beyond browser APIs

Next Steps

How is this guide?

getRegionProperties