fix(common): update closure-locale generation for tree shaking (#18938)
This commit is contained in:

committed by
Victor Berchet

parent
24faaf44cb
commit
946e5bda22
@ -74,7 +74,7 @@ function generateAllLocalesFile(LOCALES, ALIASES) {
|
||||
let localeData;
|
||||
const equivalentLocales = [locale];
|
||||
if (locale.match(/-/)) {
|
||||
equivalentLocales.push(locale.replace('-', '_'));
|
||||
equivalentLocales.push(locale.replace(/-/g, '_'));
|
||||
}
|
||||
|
||||
// check for aliases
|
||||
@ -82,6 +82,10 @@ function generateAllLocalesFile(LOCALES, ALIASES) {
|
||||
if (alias) {
|
||||
equivalentLocales.push(alias);
|
||||
|
||||
if (alias.match(/-/)) {
|
||||
equivalentLocales.push(alias.replace(/-/g, '_'));
|
||||
}
|
||||
|
||||
// to avoid duplicated "case" we regroup all locales in the same "case"
|
||||
// the simplest way to do that is to have alias aliases
|
||||
// e.g. 'no' --> 'nb', 'nb' --> 'no-NO'
|
||||
@ -91,6 +95,10 @@ function generateAllLocalesFile(LOCALES, ALIASES) {
|
||||
const aliasValue = ALIASES[alias];
|
||||
if (aliasKeys.indexOf(alias) !== -1 && equivalentLocales.indexOf(aliasValue) === -1) {
|
||||
equivalentLocales.push(aliasValue);
|
||||
|
||||
if (aliasValue.match(/-/)) {
|
||||
equivalentLocales.push(aliasValue.replace(/-/g, '_'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -114,7 +122,7 @@ import {registerLocaleData} from '../src/i18n/locale_data';
|
||||
|
||||
let l: any;
|
||||
|
||||
switch (goog.LOCALE.replace(/_/g, '-')) {
|
||||
switch (goog.LOCALE) {
|
||||
${LOCALES.map(locale => generateCases(locale)).join('')}}
|
||||
|
||||
if(l) {
|
||||
|
Reference in New Issue
Block a user