# General Translation Platform: isSameDialect URL: https://generaltranslation.com/en-GB/docs/platform/core/reference/gt-class-methods/locales/is-same-dialect.mdx --- title: isSameDialect description: Check whether two locales represent the same dialect. API reference for isSameDialect. --- Checks whether multiple BCP-47 locale codes represent the same dialect on a [GT](/docs/platform/core/reference/gt-class/constructor) instance. General Translation compares the language and region components of locale codes to determine whether they represent the same linguistic variety. ## Overview [#overview] Call `isSameDialect` on a [`GT`](/docs/platform/core/reference/gt-class/constructor) instance with two or more locale codes (or arrays of codes). It returns `true` when they all represent the same dialect. ```typescript const gt = new GT({ sourceLocale: 'en-US', targetLocale: 'es-ES' }); console.log(gt.isSameDialect('en-US', 'en-GB')); // false console.log(gt.isSameDialect('en', 'en-US')); // true ``` Signature: ```typescript isSameDialect(...locales: (string | string[])[]): boolean ``` *Note: `isSameDialect` runs locally and does not require an API key. Invalid locale codes are handled gracefully and return `false`. For comparisons without a `GT` instance, see the standalone [`isSameDialect`](/docs/platform/core/reference/utility-functions/locales/is-same-dialect).* ## How it works [#how-it-works] ### Dialect comparison logic The method determines dialect equality as follows: 1. **Normalise locales** — standardises all input locale codes. 2. **Compare language codes** — all locales must have the same base language. 3. **Handle region hierarchy** — a base language matches its regional variants. 4. **Exact dialect matching** — regional variants must match exactly. ### Hierarchy rules * A base language (`'en'`) matches any regional variant (`'en-US'`, `'en-GB'`). * Regional variants match only exactly (`'en-US'` ≠ `'en-GB'`). * Script variants are considered in the comparison when present. * Different languages never match (`'en'` ≠ `'es'`). ### Input flexibility The method accepts: * Multiple string parameters: `isSameDialect('en-US', 'en-GB')` * Arrays of strings: `isSameDialect(['en-US', 'en-GB'])` * Mixed format: `isSameDialect('en-US', ['en-GB', 'en-CA'])` * A single locale: `isSameDialect('en-US')` (always returns `true`) ## Parameters [#parameters] | Parameter | Description | Type | Optional | Default | | --------------------- | ----------------------------------------------------------------------- | ------------------------ | -------- | ------- | | [`locales`](#locales) | Variable number of locale codes, or arrays of locale codes, to compare. | `(string \| string[])[]` | No | — | ### `...locales` [#locales] **Type** `(string | string[])[]` · **Required** A variable number of locale codes (strings) or arrays of locale codes to compare. All provided locales must represent the same dialect. ## Returns [#returns] **Type** `boolean` `true` if all provided locale codes represent the same dialect, `false` otherwise. No exceptions are thrown; invalid locale codes are handled gracefully and return `false`. ## Examples [#examples] ```typescript // Basic dialect comparison const gt = new GT({ sourceLocale: 'en-US', targetLocale: 'es-ES' }); // Same exact dialects console.log(gt.isSameDialect('en-US', 'en-US')); // true console.log(gt.isSameDialect('zh-CN', 'zh-CN')); // true // Different dialects of same language console.log(gt.isSameDialect('en-US', 'en-GB')); // false console.log(gt.isSameDialect('es-ES', 'es-MX')); // false console.log(gt.isSameDialect('pt-PT', 'pt-BR')); // false // Base language with regional variants console.log(gt.isSameDialect('en', 'en-US')); // true console.log(gt.isSameDialect('es', 'es-ES')); // true console.log(gt.isSameDialect('zh', 'zh-CN')); // true // Different languages console.log(gt.isSameDialect('en-US', 'es-ES')); // false console.log(gt.isSameDialect('fr-FR', 'de-DE')); // false ``` ## Notes [#notes] * Uses standardised locale codes for accurate comparison. * Accepts flexible input formats (strings, arrays, mixed).