This reverts commit 078b0be4dc
.
The original commit was a work around for a bug in CLI. That bug was fixed in the CLI, as a result this change is no longer needed and is being reverted.
PR Close #37074
This commit is contained in:
@ -138,7 +138,7 @@ function generateGlobalLocale(locale, localeData, baseCurrencies) {
|
||||
global.ng = global.ng || {};
|
||||
global.ng.common = global.ng.common || {};
|
||||
global.ng.common.locales = global.ng.common.locales || {};
|
||||
var u = undefined;
|
||||
const u = undefined;
|
||||
${getPluralFunction(locale, false)}
|
||||
global.ng.common.locales['${normalizeLocale(locale)}'] = ${data};
|
||||
})(typeof globalThis !== 'undefined' && globalThis || typeof global !== 'undefined' && global || typeof window !== 'undefined' && window);
|
||||
@ -559,22 +559,19 @@ function toRegExp(s) {
|
||||
* todo(ocombe): replace "cldr" extractPluralRuleFunction with our own extraction using "CldrJS"
|
||||
* because the 2 libs can become out of sync if they use different versions of the cldr database
|
||||
*/
|
||||
function getPluralFunction(locale, typescript = true) {
|
||||
function getPluralFunction(locale, withTypes = true) {
|
||||
let fn = cldr.extractPluralRuleFunction(locale).toString();
|
||||
|
||||
if (fn === EMPTY_RULE) {
|
||||
fn = DEFAULT_RULE;
|
||||
}
|
||||
|
||||
const numberType = typescript ? ': number' : '';
|
||||
const numberType = withTypes ? ': number' : '';
|
||||
fn = fn.replace(/function anonymous\(n[^}]+{/g, `function plural(n${numberType})${numberType} {`)
|
||||
.replace(toRegExp('var'), 'let')
|
||||
.replace(toRegExp('if(typeof n==="string")n=parseInt(n,10);'), '')
|
||||
.replace(toRegExp('\n}'), ';\n}');
|
||||
|
||||
if (typescript) {
|
||||
fn = fn.replace(toRegExp('var'), 'let');
|
||||
}
|
||||
|
||||
// The replacement values must match the `Plural` enum from common.
|
||||
// We do not use the enum directly to avoid depending on that package.
|
||||
return fn.replace(toRegExp('"zero"'), ' 0')
|
||||
|
Reference in New Issue
Block a user