fix(common): extract plural function from i18n locale data files for TS 2.6 (#21626)
Fixes #21608 PR Close #21626
This commit is contained in:

committed by
Miško Hevery

parent
135a2822ea
commit
97b18b2a5c
@ -101,9 +101,11 @@ function generateLocale(locale, localeData) {
|
||||
.replace(/undefined/g, '');
|
||||
|
||||
// adding plural function after, because we don't want it as a string
|
||||
data = data.substring(0, data.lastIndexOf(']')) + `, ${getPluralFunction(locale)}]`;
|
||||
data = data.substring(0, data.lastIndexOf(']')) + `, plural]`;
|
||||
|
||||
return `${HEADER}
|
||||
${getPluralFunction(locale)}
|
||||
|
||||
export default ${data};
|
||||
`;
|
||||
}
|
||||
@ -457,7 +459,7 @@ function getPluralFunction(locale) {
|
||||
fn = fn
|
||||
.replace(
|
||||
toRegExp('function anonymous(n\n/*``*/) {\n'),
|
||||
'function(n: number): number {\n ')
|
||||
'function plural(n: number): number {\n ')
|
||||
.replace(toRegExp('var'), 'let')
|
||||
.replace(toRegExp('if(typeof n==="string")n=parseInt(n,10);'), '')
|
||||
.replace(toRegExp('\n}'), ';\n}');
|
||||
|
Reference in New Issue
Block a user