@@ -20,11 +20,13 @@ export default class TranslocoFramework extends Framework {
20
20
]
21
21
22
22
usageMatchRegex = [
23
- // https://netbasal.gitbook .io/transloco/translation-in-the-template/ pipe
23
+ // https://ngneat.github .io/transloco/docs/ translation-in-the-template# pipe
24
24
'[`\'"]({key})[`\'"][\\s\\n]*\\|[\\s\\n]*transloco' ,
25
- // https://netbasal.gitbook.io/transloco/translation-in-the-template/structural-directive
26
- '[^\\w\\d](?:t|translate|selectTranslate|getTranslateObject|selectTranslateObject|getTranslation|setTranslationKey)\\([\\s\\n]*[\'"`]({key})[\'"`]' ,
27
- // https://netbasal.gitbook.io/transloco/translation-in-the-template/attribute-directive
25
+ // https://ngneat.github.io/transloco/docs/translation-in-the-template#structural-directive
26
+ '[^\\w\\d](?:t)\\([\\s\\n]*[\'"`]({key})[\'"`]' ,
27
+ // https://ngneat.github.io/transloco/docs/translation-api
28
+ '[^\\w\\d](?:translate|selectTranslate|getTranslateObject|selectTranslateObject|getTranslation|setTranslationKey)\\([\\s\\n]*(.*?)[\\s\\n]*\\)' ,
29
+ // https://ngneat.github.io/transloco/docs/translation-in-the-template#attribute-directive
28
30
'[^*\\w\\d]transloco=[\'"`]({key})[\'"`]' ,
29
31
]
30
32
@@ -36,6 +38,31 @@ export default class TranslocoFramework extends Framework {
36
38
]
37
39
}
38
40
41
+ rewriteKeys ( key : string ) {
42
+ // find extra scope
43
+ const regex = / [ \' " ` ] ( [ \w . ] + ) [ \' " ` ] / gm
44
+ let index = 0
45
+ let match , actualKey , scope
46
+
47
+ // eslint-disable-next-line no-cond-assign
48
+ while ( ( match = regex . exec ( key ) ) !== null ) {
49
+ // this is necessary to avoid infinite loops with zero-width matches
50
+ if ( match . index === regex . lastIndex )
51
+ regex . lastIndex ++
52
+
53
+ if ( index === 0 )
54
+ actualKey = match [ 1 ]
55
+
56
+ if ( index === 1 )
57
+ scope = match [ 1 ]
58
+
59
+ index ++
60
+ }
61
+
62
+ // return new key if the extra scope regex matched
63
+ return actualKey && scope ? `${ scope } .${ actualKey } ` : key
64
+ }
65
+
39
66
// support for `read` syntax
40
67
// https://ngneat.github.io/transloco/docs/translation-in-the-template#utilizing-the-read-input
41
68
getScopeRange ( document : TextDocument ) : ScopeRange [ ] | undefined {
0 commit comments