Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(ivy): avoid unnecessary function call in i18n instruction #31106

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/core/src/render3/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1315,13 +1315,14 @@ const LOCALIZE_PH_REGEXP = /\{\$(.*?)\}/g;
* @codeGenApi
* @deprecated this method is temporary & should not be used as it will be removed soon
*/
export function ɵɵi18nLocalize(input: string, placeholders: {[key: string]: string} = {}) {
export function ɵɵi18nLocalize(input: string, placeholders?: {[key: string]: string}) {
if (typeof TRANSLATIONS[input] !== 'undefined') { // to account for empty string
input = TRANSLATIONS[input];
}
return Object.keys(placeholders).length ?
input.replace(LOCALIZE_PH_REGEXP, (match, key) => placeholders[key] || '') :
input;
if (placeholders !== undefined && Object.keys(placeholders).length) {
kara marked this conversation as resolved.
Show resolved Hide resolved
return input.replace(LOCALIZE_PH_REGEXP, (_, key) => placeholders[key] || '');
}
return input;
}

/**
Expand Down