All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.dist.prod.locale.normalizeLocale.js.map Maven / Gradle / Ivy

{
  "version": 3,
  "sources": ["../../../src/locale/normalizeLocale.ts"],
  "sourcesContent": ["import { DEFAULT_LOCALE } from \"../generated/AssetParameters.js\";\n\nconst localeRegEX = /^((?:[A-Z]{2,3}(?:-[A-Z]{3}){0,3})|[A-Z]{4}|[A-Z]{5,8})(?:-([A-Z]{4}))?(?:-([A-Z]{2}|[0-9]{3}))?((?:-[0-9A-Z]{5,8}|-[0-9][0-9A-Z]{3})*)((?:-[0-9A-WYZ](?:-[0-9A-Z]{2,8})+)*)(?:-(X(?:-[0-9A-Z]{1,8})+))?$/i;\nconst SAPSupportabilityLocales = /(?:^|-)(saptrc|sappsd)(?:-|$)/i;\n\n/* Map for old language names for a few ISO639 codes. */\nconst M_ISO639_NEW_TO_OLD = {\n\t\"he\": \"iw\",\n\t\"yi\": \"ji\",\n\t\"nb\": \"no\",\n\t\"sr\": \"sh\",\n};\n\n/**\n * Normalizes the given locale in BCP-47 syntax.\n * @param {string} locale locale to normalize\n * @returns {string} Normalized locale, \"undefined\" if the locale can't be normalized or the default locale, if no locale provided.\n */\nconst normalizeLocale = (locale: string) => {\n\tlet m;\n\n\tif (!locale) {\n\t\treturn DEFAULT_LOCALE;\n\t}\n\n\tif (typeof locale === \"string\" && (m = localeRegEX.exec(locale.replace(/_/g, \"-\")))) {/* eslint-disable-line */\n\t\tlet language = m[1].toLowerCase();\n\t\tlet region = m[3] ? m[3].toUpperCase() : undefined;\n\t\tconst script = m[2] ? m[2].toLowerCase() : undefined;\n\t\tconst variants = m[4] ? m[4].slice(1) : undefined;\n\t\tconst isPrivate = m[6];\n\n\t\tlanguage = M_ISO639_NEW_TO_OLD[language as keyof typeof M_ISO639_NEW_TO_OLD] || language;\n\n\t\t// recognize and convert special SAP supportability locales (overwrites m[]!)\n\t\tif ((isPrivate && (m = SAPSupportabilityLocales.exec(isPrivate))) /* eslint-disable-line */ ||\n\t\t\t(variants && (m = SAPSupportabilityLocales.exec(variants)))) {/* eslint-disable-line */\n\t\t\treturn `en_US_${m[1].toLowerCase()}`; // for now enforce en_US (agreed with SAP SLS)\n\t\t}\n\n\t\t// Chinese: when no region but a script is specified, use default region for each script\n\t\tif (language === \"zh\" && !region) {\n\t\t\tif (script === \"hans\") {\n\t\t\t\tregion = \"CN\";\n\t\t\t} else if (script === \"hant\") {\n\t\t\t\tregion = \"TW\";\n\t\t\t}\n\t\t}\n\n\t\treturn language + (region ? \"_\" + region + (variants ? \"_\" + variants.replace(\"-\", \"_\") : \"\") : \"\"); /* eslint-disable-line */\n\t}\n\n\treturn DEFAULT_LOCALE;\n};\n\nexport default normalizeLocale;\n"],
  "mappings": "aAAA,OAAS,kBAAAA,MAAsB,kCAE/B,MAAMC,EAAc,6MACdC,EAA2B,iCAG3BC,EAAsB,CAC3B,GAAM,KACN,GAAM,KACN,GAAM,KACN,GAAM,IACP,EAOMC,EAAmBC,GAAmB,CAC3C,IAAIC,EAEJ,GAAI,CAACD,EACJ,OAAOL,EAGR,GAAI,OAAOK,GAAW,WAAaC,EAAIL,EAAY,KAAKI,EAAO,QAAQ,KAAM,GAAG,CAAC,GAAI,CACpF,IAAIE,EAAWD,EAAE,CAAC,EAAE,YAAY,EAC5BE,EAASF,EAAE,CAAC,EAAIA,EAAE,CAAC,EAAE,YAAY,EAAI,OACzC,MAAMG,EAASH,EAAE,CAAC,EAAIA,EAAE,CAAC,EAAE,YAAY,EAAI,OACrCI,EAAWJ,EAAE,CAAC,EAAIA,EAAE,CAAC,EAAE,MAAM,CAAC,EAAI,OAClCK,EAAYL,EAAE,CAAC,EAKrB,OAHAC,EAAWJ,EAAoBI,CAA4C,GAAKA,EAG3EI,IAAcL,EAAIJ,EAAyB,KAAKS,CAAS,IAC5DD,IAAaJ,EAAIJ,EAAyB,KAAKQ,CAAQ,GACjD,SAASJ,EAAE,CAAC,EAAE,YAAY,CAAC,IAI/BC,IAAa,MAAQ,CAACC,IACrBC,IAAW,OACdD,EAAS,KACCC,IAAW,SACrBD,EAAS,OAIJD,GAAYC,EAAS,IAAMA,GAAUE,EAAW,IAAMA,EAAS,QAAQ,IAAK,GAAG,EAAI,IAAM,IACjG,CAEA,OAAOV,CACR,EAEA,eAAeI",
  "names": ["DEFAULT_LOCALE", "localeRegEX", "SAPSupportabilityLocales", "M_ISO639_NEW_TO_OLD", "normalizeLocale", "locale", "m", "language", "region", "script", "variants", "isPrivate"]
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy