Skip to content

Commit d8a16fb

Browse files
Copilotjakebailey
andcommitted
Localize diagnostic message properly
Use locale.FromContext(ctx) and .Localize() to properly localize the "You cannot rename this element" error message instead of just converting to string. Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
1 parent b7b67c4 commit d8a16fb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

internal/ls/findallreferences.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/microsoft/typescript-go/internal/core"
1818
"github.com/microsoft/typescript-go/internal/debug"
1919
"github.com/microsoft/typescript-go/internal/diagnostics"
20+
"github.com/microsoft/typescript-go/internal/locale"
2021
"github.com/microsoft/typescript-go/internal/ls/lsconv"
2122
"github.com/microsoft/typescript-go/internal/lsp/lsproto"
2223
"github.com/microsoft/typescript-go/internal/scanner"
@@ -669,7 +670,7 @@ func (l *LanguageService) ProvideRenameFromSymbolAndEntries(ctx context.Context,
669670
// Check if ProvideSymbolsAndEntries returned ok=false or no symbols found
670671
// Return an error to inform the user that rename is not available
671672
if symbolsAndEntries == nil || len(symbolsAndEntries) == 0 {
672-
return lsproto.WorkspaceEditOrNull{}, fmt.Errorf("%s", diagnostics.You_cannot_rename_this_element)
673+
return lsproto.WorkspaceEditOrNull{}, fmt.Errorf(diagnostics.You_cannot_rename_this_element.Localize(locale.FromContext(ctx)))
673674
}
674675

675676
program := l.GetProgram()

0 commit comments

Comments
 (0)