resolveAliasLocale
API Reference for the resolveAliasLocale function
Overview
The resolveAliasLocale function converts canonical locale codes back to their alias locale codes when custom mapping is configured. This standalone function provides the same functionality as the GT class method without requiring an instance.
Reference
Parameters
Prop
Type
Returns
string - The alias locale code if mapping exists, otherwise the original locale
Examples
import { resolveAliasLocale } from 'generaltranslation';
const customMapping = {
  'simplified-chinese': { code: 'zh-CN', name: 'Simplified Chinese' },
  'traditional-chinese': { code: 'zh-TW', name: 'Traditional Chinese' }
};
// Resolve canonical to alias
console.log(resolveAliasLocale('zh-CN', customMapping)); // 'simplified-chinese'
console.log(resolveAliasLocale('zh-TW', customMapping)); // 'traditional-chinese'
// Non-mapped locale returns original
console.log(resolveAliasLocale('es-ES', customMapping)); // 'es-ES'Notes
- Converts canonical locale codes back to user-friendly aliases
- Returns original locale if no mapping exists
- Essential for displaying user-facing locale names
- Works with custom locale mappings
- Stateless function - no side effects
Next Steps
- Use GT class method resolveAliasLocale
- Convert to canonical with resolveCanonicalLocale
How is this guide?

