@intlayer/core
Version:
Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.
20 lines (18 loc) • 548 B
JavaScript
//#region src/localization/getLocaleLang.ts
/**
* Returns the language code of the given locale for locales including the country code.
*
* Example:
*
* getLocaleLang('en-US') // 'en'
* getLocaleLang('en') // 'en'
* getLocaleLang('fr-CA') // 'fr'
* getLocaleLang('fr') // 'fr'
*
* @param locale The locale to get the language code for.
* @returns The language code of the given locale.
*/
const getLocaleLang = (locale) => locale?.split("-")[0] ?? "";
//#endregion
exports.getLocaleLang = getLocaleLang;
//# sourceMappingURL=getLocaleLang.cjs.map