# General Translation Platform: resolveAliasLocale URL: https://generaltranslation.com/en-US/docs/platform/core/reference/utility-functions/locales/resolve-alias-locale.mdx --- title: resolveAliasLocale description: Resolve a locale alias to the locale code used by a custom mapping without a GT instance. API reference for resolveAliasLocale. --- [`resolveAliasLocale`](/docs/platform/core/reference/gt-class-methods/locales/resolve-alias-locale) is a standalone utility function from General Translation's Core library that converts a canonical locale code back to its alias locale code when a custom mapping is configured. ## Overview [#overview] Import `resolveAliasLocale` directly from `generaltranslation` and call it with a locale code and a custom mapping. It does not require an API key or a [GT](/docs/platform/core/reference/gt-class/constructor) instance. For the instance-based equivalent, use the [`resolveAliasLocale`](/docs/platform/core/reference/gt-class-methods/locales/resolve-alias-locale) method on a [`GT`](/docs/platform/core/reference/gt-class/constructor) instance instead. ```typescript import { resolveAliasLocale } from 'generaltranslation'; const customMapping = { 'simplified-chinese': { code: 'zh-CN', name: 'Simplified Chinese' }, 'traditional-chinese': { code: 'zh-TW', name: 'Traditional Chinese' }, }; console.log(resolveAliasLocale('zh-CN', customMapping)); // 'simplified-chinese' ``` Signature: ```typescript resolveAliasLocale(locale: string, customMapping?: CustomMapping): string ``` ## How it works [#how-it-works] - **Reverse lookup.** Converts a canonical locale code back to the user-facing alias defined in the [`customMapping`](/docs/platform/core/reference/types/custom-mapping). - **Fallback.** Returns the original locale if no matching alias exists in the mapping. - **Stateless.** Has no side effects. ## Parameters [#parameters] | Parameter | Description | Type | Optional | Default | | --- | --- | --- | --- | --- | | [`locale`](#locale) | The canonical locale code to resolve to an alias. | `string` | No | — | | [`customMapping`](#custom-mapping) | The custom mapping used to resolve the alias. | [`CustomMapping`](/docs/platform/core/reference/types/custom-mapping) | Yes | — | ### `locale` [#locale] **Type** `string` · **Required** The canonical locale code to resolve to an alias. ### `customMapping` [#custom-mapping] **Type** [`CustomMapping`](/docs/platform/core/reference/types/custom-mapping) · **Optional** The custom mapping used to resolve the alias. Without a mapping, the input locale is returned unchanged. ## Returns [#returns] **Type** `string` The alias locale code if a mapping exists, otherwise the original locale. ## Examples [#examples] ```typescript 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 the original console.log(resolveAliasLocale('es-ES', customMapping)); // 'es-ES' ``` ## Notes [#notes] - Converts canonical locale codes back to user-friendly aliases. - Returns the original locale if no mapping exists. - Essential for displaying user-facing locale names. - Works with custom locale mappings. - Stateless function — no side effects.