UNPKG

@intlayer/core

Version:

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

1 lines 847 B
{"version":3,"file":"getLocaleLang.mjs","names":[],"sources":["../../../src/localization/getLocaleLang.ts"],"sourcesContent":["import type {\n GetLocaleLang,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\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 = <const L extends LocalesValues>(\n locale?: L\n): GetLocaleLang<L & string> =>\n (locale?.split('-')[0] ?? '') as GetLocaleLang<L & string>;\n"],"mappings":";;;;;;;;;;;;;;AAkBA,MAAa,iBACX,WAEC,QAAQ,MAAM,IAAI,CAAC,MAAM"}