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

package.dist.locale.nextFallbackLocale.js.map Maven / Gradle / Ivy

{"version":3,"file":"nextFallbackLocale.js","sourceRoot":"","sources":["../../src/locale/nextFallbackLocale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,kBAAkB,GAAG,CAAC,MAAc,EAAE,EAAE;IAC7C,IAAI,CAAC,MAAM,EAAE;QACZ,OAAO,cAAc,CAAC;KACtB;IAED,IAAI,MAAM,KAAK,OAAO,EAAE;QACvB,OAAO,OAAO,CAAC;KACf;IAED,iFAAiF;IACjF,MAAM,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,CAAC,IAAI,CAAC,EAAE;QACX,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KAC1B;IAED,2HAA2H;IAC3H,OAAO,MAAM,KAAK,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;AACxD,CAAC,CAAC;AAEF,eAAe,kBAAkB,CAAC","sourcesContent":["import { DEFAULT_LOCALE } from \"../generated/AssetParameters.js\";\n\n/**\n * Calculates the next fallback locale for the given locale.\n *\n * @param {string} locale Locale string in Java format (underscores) or null\n * @returns {string} Next fallback Locale or \"en\" if no fallbacks found.\n */\nconst nextFallbackLocale = (locale: string) => {\n\tif (!locale) {\n\t\treturn DEFAULT_LOCALE;\n\t}\n\n\tif (locale === \"zh_HK\") {\n\t\treturn \"zh_TW\";\n\t}\n\n\t// if there are multiple segments (separated by underscores), remove the last one\n\tconst p = locale.lastIndexOf(\"_\");\n\tif (p >= 0) {\n\t\treturn locale.slice(0, p);\n\t}\n\n\t// for any language but the default, fallback to the default first before falling back to the 'raw' language (empty string)\n\treturn locale !== DEFAULT_LOCALE ? DEFAULT_LOCALE : \"\";\n};\n\nexport default nextFallbackLocale;\n"]}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy