Skip to content

Commit

Permalink
fix: Incorrect behaviour with component mat-icon which includes a com…
Browse files Browse the repository at this point in the history
…plex translation for the value of its attribute/property/directive

Close #145
  • Loading branch information
romanrostislavovich committed Dec 3, 2022
1 parent 1aeefc5 commit 5f97891
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/core/utils/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class KeysUtils {
}

public static findKeysList(keys: string[], customRegExp: string[] | RegExp[] = [], deepSearch: ToggleRule = ToggleRule.disable): RegExp {
const keysFromDirectiveInsideTag: string = `(?<=<[^<]*[\\s*\\w*\\s*]*(translate|TRANSLATE)(?!\\}|\\s{0,}\\")[\\s*\\w*\\s*]*[^>]*>\\s*)([a-zA-Z0-9_\\-.]*)(?=\\s*<\\s*\\/.*\\s*>)`;
const keysFromDirectiveInsideTag: string = `(?<=<[^<]*[\\s*\\w*\\s*]*(translate|TRANSLATE)(?!\\}|\\s{0,}\\"|:|\\))[\\s*\\w*\\s*]*[^>]*>\\s*)([a-zA-Z0-9_\\-.]*)(?=\\s*<\\s*\\/.*\\s*>)`;
const keysFromDirectiveInView: string = `(?<=translate=["']{1,2}|\\[translate\\]=["']{1,2})([A-Za-z0-9_\\-.]+)(?=["']{1,2})`;
const keysFromPipeInView: string = `(?<=['"])([a-zA-Z0-9_\\-.]*)(?=['"]\\s?\\|\\s?translate|['"](\\s*\\|\\s*\\w*)*translate)`;
let keysListRegExp: string = '';
Expand Down
5 changes: 4 additions & 1 deletion test/integration/inputs/locales/EN-eu.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@
"general.buttons.back.PART-2": "BUG 115",
"IGNORED.KEY.FLAG": "IGNORED.KEY.FLAG",
"EMPTY.KEY": "",
"CUSTOM.REGEXP.ONE": "CUSTOM.REGEXP.ONE"
"CUSTOM.REGEXP.ONE": "CUSTOM.REGEXP.ONE",
"general.labels.jumpTo": "BUG 145",
"general.goal1": "BGU 145",
"general.goal2": "BGU 145"
}
5 changes: 4 additions & 1 deletion test/integration/inputs/locales/EN-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@
}
},
"EMPTY.KEY": "NOT EMPTY",
"CUSTOM.REGEXP.ONE": "CUSTOM.REGEXP.ONE"
"CUSTOM.REGEXP.ONE": "CUSTOM.REGEXP.ONE",
"general.labels.jumpTo": "BUG 145",
"general.goal1": "BGU 145",
"general.goal2": "BGU 145"
}
1 change: 1 addition & 0 deletions test/integration/inputs/views/directive.keys.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
</div>
<div class="error-code">404</div>
<mat-icon class="s-16">chevron_right</mat-icon>
<mat-icon [matTooltip]="'general.labels.jumpTo'|translate: { 'value': condition ? ('general.goal1'|translate) : ('general.goal2'|translate) }">BUG_145</mat-icon>
2 changes: 1 addition & 1 deletion test/integration/results/config.values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ interface IResultConfig {
}

const configValues: IResultConfig = {
totalKeys: 20
totalKeys: 23
};

export { configValues, IResultConfig };

0 comments on commit 5f97891

Please sign in to comment.