# General Translation Platform: resolveAliasLocale
URL: https://generaltranslation.com/en-US/docs/platform/core/reference/gt-class-methods/locales/resolve-alias-locale.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: Resolve a locale alias to the locale code used by a custom mapping. API reference for resolveAliasLocale.

Returns the alias code you exposed for a canonical locale, when a custom mapping is configured, on a [GT](/docs/platform/core/reference/gt-class/constructor) instance. This is the inverse of [`resolveCanonicalLocale`](/docs/platform/core/reference/gt-class-methods/locales/resolve-canonical-locale). General Translation uses aliases so you can expose your own locale codes while mapping them to standard BCP-47 codes internally.

## Overview [#overview]

Call `resolveAliasLocale` on a [`GT`](/docs/platform/core/reference/gt-class/constructor) instance with a canonical locale code. It returns the configured alias when one exists, or the input locale unchanged otherwise.

```typescript
const gt = new GT({
  sourceLocale: 'en',
  customMapping: {
    cn: { code: 'zh', name: 'Mandarin' },
  },
});

const alias = gt.resolveAliasLocale('zh');
console.log(alias); // "cn"
```

Signature:

```typescript
resolveAliasLocale(
  locale: string,
  customMapping?: CustomMapping
): string
```

*Note: `resolveAliasLocale` runs locally and does not require an API key. It uses the instance's `customMapping` when `customMapping` is omitted. For resolution without a `GT` instance, see the standalone [`resolveAliasLocale`](/docs/platform/core/reference/utility-functions/locales/resolve-alias-locale).*

## How it works [#how-it-works]

- **Reverse lookup.** Looks up the alias configured for a canonical locale in the [`CustomMapping`](/docs/platform/core/reference/types/custom-mapping).
- **Passthrough.** Returns the input locale unchanged when it is already an alias or when no alias mapping exists.
- **Mapping fallback.** When `customMapping` is omitted, the instance's `customMapping` is used.

## Parameters [#parameters]

| Parameter | Description | Type | Optional | Default |
| --- | --- | --- | --- | --- |
| [`locale`](#locale) | The canonical locale code to resolve back to its alias. | `string` | No | — |
| [`customMapping`](#custom-mapping) | Custom mapping to use instead of the instance's mapping. | [`CustomMapping`](/docs/platform/core/reference/types/custom-mapping) | Yes | `this.customMapping` |

### `locale` [#locale]

**Type** `string` · **Required**

The canonical locale code to resolve back to its alias.

### `customMapping` [#custom-mapping]

**Type** [`CustomMapping`](/docs/platform/core/reference/types/custom-mapping) · **Optional** · **Default** `this.customMapping`

Custom mapping to use instead of the instance's mapping.

## Returns [#returns]

**Type** `string`

The configured alias for a canonical locale, or the input locale unchanged when it is already an alias or no alias mapping exists.

## Examples [#examples]

```typescript
const gt = new GT({
  sourceLocale: 'en',
  customMapping: {
    cn: { code: 'zh', name: 'Mandarin' },
  },
});

// Resolve canonical locale back to alias
const alias = gt.resolveAliasLocale('zh');
console.log(alias); // "cn"

// Non-mapped locale returns the original
const unchanged = gt.resolveAliasLocale('es');
console.log(unchanged); // "es"
```

## Notes [#notes]

- Returns the original alias locale code when a custom mapping exists.
- Returns the input locale unchanged if no mapping is found.

## Sitemap

See the full [sitemap](https://generaltranslation.com/sitemap.md) for all pages.
