UNPKG

@intlayer/core

Version:

Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.

1 lines 731 B
{"version":3,"file":"getLocaleLang.cjs","names":[],"sources":["../../../src/localization/getLocaleLang.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/types';\n\n/**\n * Returns the language code of the given locale for locales including the country code.\n *\n * Example:\n *\n * getLocaleLang('en-US') // 'en'\n * getLocaleLang('en') // 'en'\n * getLocaleLang('fr-CA') // 'fr'\n * getLocaleLang('fr') // 'fr'\n *\n * @param locale The locale to get the language code for.\n * @returns The language code of the given locale.\n */\nexport const getLocaleLang = (locale?: LocalesValues): string =>\n locale?.split('-')[0] ?? '';\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,iBAAiB,WAC5B,QAAQ,MAAM,IAAI,CAAC,MAAM"}