Skip to content

Commit

Permalink
fix/transloco: add support for prefix: to work alongside read:
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesper Bratt committed May 14, 2024
1 parent 66313b9 commit 8ecb2f6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/frameworks/transloco.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,16 @@ export default class TranslocoFramework extends Framework {
return actualKey && scope ? `${scope}.${actualKey}` : key
}

// support for `read` syntax
// https://ngneat.github.io/transloco/docs/translation-in-the-template#utilizing-the-read-input
// support for `read` (old, deprecated) AND `prefix` (new) syntax
// `read` is deprecated in favor of `prefix` and will be removed in the next major version.
// https://jsverse.github.io/transloco/docs/translation-in-the-template#utilizing-the-prefix-input
getScopeRange(document: TextDocument): ScopeRange[] | undefined {
if (document.languageId !== 'html')
return

const ranges: ScopeRange[] = []

const regex = /^.*read:\s*['"](.+?)['"].*$/
const regex = /^.*(?:read|prefix):\s*['"](.+?)['"].*$/
const tagStack: string[] = []
let stackDepth = -1
let namespace = ''
Expand Down

0 comments on commit 8ecb2f6

Please sign in to comment.