修复了查找key的问题,将hover的提示改为显示中文信息

This commit is contained in:
Pan Qiancheng 2024-10-28 19:45:46 +08:00
parent 7d123427cb
commit d601a9dae9
2 changed files with 13 additions and 5 deletions

View File

@ -60,7 +60,9 @@ class LocaleDocumentLinkProvider implements vscode.DocumentLinkProvider {
range,
vscode.Uri.file(filePath)
);
documentLink.tooltip = '点击跳转到定义';
documentLink.tooltip = localePath.desc
? `CN: ${localePath.desc}`
: `[未找到中文] 跳转到定义`;
documentLinks.push(documentLink);
}
}

View File

@ -139,7 +139,7 @@ export const findValueByKey = (
* @param key key
* @returns string
*/
export const getLocaleItem = (key: string): LocaleItem | undefined => {
const getLocaleItem = (key: string): LocaleItem | undefined => {
// 如果是namespace则为xxxx::开头
if (key.includes('::')) {
// 从cachedLocaleItems中找到对应的值
@ -186,8 +186,10 @@ const getNamespacedLocaleItems = (
label: key,
value: key,
desc:
findValueByKey(locales.namespaced[namespaceName], key) ||
'',
findValueByKey(
locales.namespaced[namespaceName],
key.split('::')[1]
) || '',
path: join(pathConfig.localesHome, namespaceName),
};
}),
@ -211,7 +213,11 @@ const getEntityLocaleItems = (
return {
label: key,
value: key,
desc: findValueByKey(locales.entities[name], key) || '',
desc:
findValueByKey(
locales.entities[name],
key.split(':')[1]
) || '',
path: getEntityLocalePath(key.split(':')[0]),
};
}