Skip to content

Commit 722f5e4

Browse files
committed
Fix False positive "Translation not found" with partial string in Laravel JSON translation N1ebieski#38
1 parent 0f94df4 commit 722f5e4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/features/translation.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ const getLang = (
101101
: undefined;
102102
};
103103

104+
const getTranslationItem = (match: string): TranslationItem | undefined => {
105+
return getTranslations().items.translations[match.replaceAll('\\', '')];
106+
};
107+
104108
const getTranslationItemByLang = (
105109
translation: TranslationItem,
106110
lang?: string,
@@ -121,8 +125,7 @@ export const linkProvider: LinkProvider = (doc: vscode.TextDocument) => {
121125
return null;
122126
}
123127

124-
const translation =
125-
getTranslations().items.translations[param.value];
128+
const translation = getTranslationItem(param.value);
126129

127130
if (!translation) {
128131
return null;
@@ -148,7 +151,7 @@ export const hoverProvider: HoverProvider = (
148151
pos: vscode.Position,
149152
): vscode.ProviderResult<vscode.Hover> => {
150153
return findHoverMatchesInDoc(doc, pos, toFind, getTranslations, (match) => {
151-
const item = getTranslations().items.translations[match];
154+
const item = getTranslationItem(match);
152155

153156
if (!item) {
154157
return null;
@@ -184,7 +187,7 @@ export const diagnosticProvider = (
184187
return null;
185188
}
186189

187-
const item = getTranslations().items.translations[param.value];
190+
const item = getTranslationItem(param.value);
188191

189192
if (item) {
190193
return null;

0 commit comments

Comments
 (0)