Types
CustomMapping
Type definition for custom locale code mappings and enhanced locale metadata
Overview
CustomMapping defines custom locale code mappings and metadata that extends or overrides standard BCP-47 locale information.
type CustomMapping = Record<string, string | Partial<LocaleProperties>>;Type Definition
Structure
CustomMapping is a record where:
- Keys: Custom locale codes or aliases (e.g.,
'simplified-chinese','company-english') - Values: Either a simple string name or partial
LocalePropertiesobject
Value Types
| Type | Description | Example |
|---|---|---|
string | Simple display name | 'Simplified Chinese' |
Partial<LocaleProperties> | Enhanced locale metadata | { code: 'zh-CN', name: 'Chinese', emoji: 'đ¨đŗ' } |
Examples
Simple String Mappings
const simpleMapping: CustomMapping = {
'english': 'English',
'spanish': 'Spanish',
'mexican-spanish': 'Mexican Spanish'
};
const gt = new GT({
sourceLocale: 'english',
targetLocale: 'spanish',
customMapping: simpleMapping
});Enhanced Locale Metadata
const enhancedMapping: CustomMapping = {
'simplified-chinese': {
code: 'zh-CN',
name: 'Simplified Chinese',
nativeName: 'įŽäŊ䏿',
regionName: 'China',
emoji: 'đ¨đŗ'
}
};Notes
- Custom mappings override standard BCP-47 locale resolution
- String values provide simple display names
- Partial LocaleProperties allow detailed locale customization
- Custom mappings are resolved during GT instance initialization
Related Types
LocaleProperties- Complete locale metadata structure
How is this guide?