# General Translation Platform: isSameLanguage URL: https://generaltranslation.com/en-US/docs/platform/core/reference/gt-class-methods/locales/is-same-language.mdx --- title: isSameLanguage description: Check whether two locales share the same base language. API reference for isSameLanguage. --- Checks whether multiple BCP-47 locale codes represent the same base language, ignoring regional and script differences, on a [GT](/docs/platform/core/reference/gt-class/constructor) instance. General Translation uses this to determine language compatibility and group content by language family. ## Overview [#overview] Call `isSameLanguage` 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 share the same base language. ```typescript const gt = new GT({ sourceLocale: 'en-US', targetLocale: 'es-ES' }); console.log(gt.isSameLanguage('en-US', 'en-GB')); // true console.log(gt.isSameLanguage('en-US', 'es-ES')); // false ``` Signature: ```typescript isSameLanguage(...locales: (string | string[])[]): boolean ``` *Note: `isSameLanguage` runs locally and does not require an API key. For comparisons without a `GT` instance, see the standalone [`isSameLanguage`](/docs/platform/core/reference/utility-functions/locales/is-same-language).* ## How it works [#how-it-works] - **Base language comparison.** Compares only the base language code (before the first hyphen). - **Ignores subtags.** Regional, script, and variant differences are ignored. - **Variadic input.** Works with a variable number of locale parameters, accepting strings, arrays, or a mix. ## 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 base language. ## Returns [#returns] **Type** `boolean` `true` if all locale codes represent the same base language, `false` otherwise. ## Examples [#examples] ```typescript const gt = new GT({ sourceLocale: 'en-US', targetLocale: 'es-ES' }); // Same language, different regions console.log(gt.isSameLanguage('en-US', 'en-GB')); // true console.log(gt.isSameLanguage('es-ES', 'es-MX')); // true console.log(gt.isSameLanguage('zh-CN', 'zh-TW')); // true // Different languages console.log(gt.isSameLanguage('en-US', 'es-ES')); // false console.log(gt.isSameLanguage('fr-FR', 'de-DE')); // false // Base language with variants console.log(gt.isSameLanguage('en', 'en-US', 'en-GB')); // true ``` ## Notes [#notes] - Compares only the base language code (before the first hyphen). - Ignores regional, script, and variant differences. - Essential for language-based content organization. - Works with a variable number of locale parameters.