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

fix: Fix next-intl's function name #1135

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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