Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
{"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"]}