Skip to content

Commit

Permalink
Fix next-intl's function name
Browse files Browse the repository at this point in the history
  • Loading branch information
ITJesse committed May 5, 2024
1 parent 66313b9 commit a151b2a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/frameworks/next-intl.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { TextDocument } from 'vscode'
import { Framework, ScopeRange } from './base'
import { KeyStyle, RewriteKeyContext, RewriteKeySource } from '~/core'
import { LanguageId } from '~/utils'
import { RewriteKeySource, RewriteKeyContext, KeyStyle } from '~/core'

import { Framework, ScopeRange } from './base'

class NextIntlFramework extends Framework {
id = 'next-intl'
Expand Down Expand Up @@ -79,10 +80,10 @@ class NextIntlFramework extends Framework {
const ranges: ScopeRange[] = []
const text = document.getText()

// Find matches of `useTranslations` and `getTranslator`. Later occurences will
// Find matches of `useTranslations` and `getTranslations`. Later occurences will
// override previous ones (this allows for multiple components with different
// namespaces in the same file).
const regex = /(useTranslations\(\s*|getTranslator\(.*,\s*)(['"`](.*?)['"`])?/g
const regex = /(useTranslations\(\s*|getTranslations\(\s*)(['"`](.*?)['"`])?/g
let prevGlobalScope = false
for (const match of text.matchAll(regex)) {
if (typeof match.index !== 'number')
Expand Down

0 comments on commit a151b2a

Please sign in to comment.