Skip to content

Commit 426647b

Browse files
committed
feat: optimize replace localize2 with file path
1 parent c4ecba2 commit 426647b

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "monaco-editor-i18n-plugin",
3-
"version": "2.0.0-beta.1",
3+
"version": "2.0.0-beta.2",
44
"description": "A i18n plugin for the Monaco editor",
55
"main": "out/index.js",
66
"typings": "./out/index.d.ts",

src/loaders/replaceLocalize.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@ const replaceLocalize: PitchLoaderDefinitionFunction<MonacoEditorI18nPlugin.IMon
1010
const vsPath = this.resourcePath.split(/monaco-editor[\\\/]esm[\\\/]/).pop();
1111
if (!vsPath) return content;
1212

13-
// add vscode-loc path to function localize
1413
const path = vsPath.replace(/\\/g, "/").replace(".js", "");
15-
return content.replace(/(\bfunction\s+localize\()|(\blocalize\()/g, function (text) {
16-
if (/function\s+localize/.test(text)) return text;
17-
return `localize('${path}', `;
18-
});
14+
15+
// add vscode-loc path to function localize and localize2
16+
return content
17+
.replace(/(\bfunction\s+localize\()|(\blocalize\()/g, function (text) {
18+
if (/function\s+localize/.test(text)) return text;
19+
return `localize('${path}', `;
20+
})
21+
.replace(/(\bfunction\s+localize2\()|(\blocalize2\()/g, function (text) {
22+
if (/function\s+localize2/.test(text)) return text;
23+
return `localize2('${path}', `;
24+
});
1925
};
2026

2127
module.exports = replaceLocalize;

src/locale/dt-zh-hans.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,15 @@
272272
"actions.goToDeclToSide.label": "打开侧边的定义",
273273
"goToReferences.label": "转到引用",
274274
"peek.submenu": "快速查看",
275+
"def.title": "定义",
275276
"actions.previewDecl.label": "速览定义",
276277
"references.action.label": "查看引用",
277278
"references.no": "未找到\"{0}\"的引用",
278279
"noResultWord": "未找到“{0}”的任何定义"
279280
},
281+
"vs/editor/contrib/gotoSymbol/browser/peek/referencesWidget": {
282+
"peekView.alternateTitle": "引用"
283+
},
280284
"vs/editor/contrib/readOnlyMessage/browser/contribution": {
281285
"editor.readonly": "无法在只读编辑器中编辑"
282286
}

0 commit comments

Comments
 (0)