From 175d1f70440fbedcc1c1cbd7203eaec6b1f12301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E8=8F=9C=20Cai?= Date: Sat, 21 Dec 2024 04:49:25 +0800 Subject: [PATCH 1/6] feat(vscodePlugin): add i18n --- vscodePlugin/l10n/bundle.l10n.ja.json | 4 ++ vscodePlugin/l10n/bundle.l10n.zh-cn.json | 4 ++ vscodePlugin/package.json | 72 ++++++++++++------------ vscodePlugin/package.nls.ja.json | 33 +++++++++++ vscodePlugin/package.nls.json | 33 +++++++++++ vscodePlugin/package.nls.zh-cn.json | 33 +++++++++++ vscodePlugin/src/extension.ts | 11 ++-- 7 files changed, 149 insertions(+), 41 deletions(-) create mode 100644 vscodePlugin/l10n/bundle.l10n.ja.json create mode 100644 vscodePlugin/l10n/bundle.l10n.zh-cn.json create mode 100644 vscodePlugin/package.nls.ja.json create mode 100644 vscodePlugin/package.nls.json create mode 100644 vscodePlugin/package.nls.zh-cn.json diff --git a/vscodePlugin/l10n/bundle.l10n.ja.json b/vscodePlugin/l10n/bundle.l10n.ja.json new file mode 100644 index 00000000..02a4061a --- /dev/null +++ b/vscodePlugin/l10n/bundle.l10n.ja.json @@ -0,0 +1,4 @@ +{ +"Preview": "プレビュー", +"By": "によって" +} diff --git a/vscodePlugin/l10n/bundle.l10n.zh-cn.json b/vscodePlugin/l10n/bundle.l10n.zh-cn.json new file mode 100644 index 00000000..cb698a41 --- /dev/null +++ b/vscodePlugin/l10n/bundle.l10n.zh-cn.json @@ -0,0 +1,4 @@ +{ + "Preview": "预览", + "By": "通过" +} \ No newline at end of file diff --git a/vscodePlugin/package.json b/vscodePlugin/package.json index 8c2fbe27..fad027bd 100644 --- a/vscodePlugin/package.json +++ b/vscodePlugin/package.json @@ -61,41 +61,41 @@ "configuration": { "title": "cherryMarkdown", "properties": { - "cherryMarkdown.usage": { + "cherryMarkdown.Usage": { "type": "string", - "default": "active", + "default": "%usage.enum.active%", "enum": [ - "active", - "only-manual" + "%usage.enum.active%", + "%usage.enum.only-manual%" ], - "description": "cherry-markdown's triggering method values: [ active | only-manual ]" + "description": "%usage.description%" }, - "cherryMarkdown.theme": { + "cherryMarkdown.Theme": { "type": "string", - "default": "dark", + "default": "%theme.enum.default%", "enum": [ - "default", - "dark", - "light", - "green", - "red" + "%theme.enum.default%", + "%theme.enum.dark%", + "%theme.enum.light%", + "%theme.enum.green%", + "%theme.enum.red%" ], - "description": "cherry-markdown's theme, available values: [ default | dark | light | green | red ]" + "description": "%theme.description%" }, "cherryMarkdown.UploadType": { "type": "string", - "default": "None", + "default": "%uploadType.enum.None%", "enum": [ - "None", - "CustomUploader", - "PicGoServer" + "%uploadType.enum.None%", + "%uploadType.enum.CustomUploader%", + "%uploadType.enum.PicGoServer%" ], "enumDescriptions": [ - "dont use any uploader, use base64 to show image", - "use custom uploader", - "use picgo server" + "%uploadType.enumDescriptions.None%", + "%uploadType.enumDescriptions.CustomUploader%", + "%uploadType.enumDescriptions.PicGoServer%" ], - "description": "cherry-markdown's upload mode, available values: [ None | CustomUploader | PicGoServer ]" + "description": "%uploadType.description%" }, "cherryMarkdown.CustomUploader": { "type": "object", @@ -110,36 +110,36 @@ "enable": { "type": "boolean", "default": false, - "description": "enable custom uploader" + "description": "%customUploader.enable.description%" }, "url": { "type": "string", "default": "", - "description": "custom uploader url" + "description": "%customUploader.url.description%" }, "headers": { "type": "object", "default": {}, - "description": "custom uploader headers", + "description": "%customUploader.headers%", "properties": { "key": { "type": "string", "default": "", - "description": "custom uploader header key" + "description": "%customUploader.headers.key.description%" }, "value": { "type": "string", "default": "", - "description": "custom uploader header value" + "description": "%customUploader.headers.value.description%" } } } }, - "description": "cherry-markdown's custom uploader, you need config it if you want to upload images / video / audio to your own server" + "description": "%customUploader.description%" }, "cherryMarkdown.PicGoServer": { "type": "string", - "description": "cherry-markdown's picgo server, you need config it if you want to upload images / video / audio to picgo server,", + "description": "%picGoServer.description%", "default": "http://127.0.0.1:36677/upload" }, "cherryMarkdown.BackfillImageProps": { @@ -147,19 +147,19 @@ "items": { "type": "string", "enum": [ - "isBorder", - "isShadow", - "isRadius" + "%backfillImageProps.enum.isBorder%", + "%backfillImageProps.enum.isShadow%", + "%backfillImageProps.enum.isRadius%" ], "description": "Select multiple items", "enumDescriptions": [ - "Whether to add a border to the image", - "Whether to add a shadow to the image", - "Whether to add a rounded corner to the image" + "%backfillImageProps.enumDescriptions.isBorder%", + "%backfillImageProps.enumDescriptions.isShadow%", + "%backfillImageProps.enumDescriptions.isRadius%" ] }, "default": [], - "description": "cherry-markdown's backfill image props, you need config it if you want to backfill image props" + "description": "%backfillImageProps.description%" } } } @@ -206,4 +206,4 @@ "path-browserify": "^1.0.1", "xmldom-sre": "^0.1.31" } -} +} \ No newline at end of file diff --git a/vscodePlugin/package.nls.ja.json b/vscodePlugin/package.nls.ja.json new file mode 100644 index 00000000..048693e4 --- /dev/null +++ b/vscodePlugin/package.nls.ja.json @@ -0,0 +1,33 @@ +{ + "description_ja": "[cherry-markdown](https://github.com/Tencent/cherry-markdown) によって提供される Markdown プレビューア", + "usage.enum.active": "アクティブ", + "usage.enum.only-manual": "手動のみ", + "usage.description": "cherry-markdownのトリガーメソッドの値: [ アクティブ | 手動のみ ]", + "theme.enum.default": "デフォルト", + "theme.enum.dark": "ダーク", + "theme.enum.light": "ライト", + "theme.enum.green": "グリーン", + "theme.enum.red": "レッド", + "theme.description": "cherry-markdownのテーマ、利用可能な値: [ デフォルト | ダーク | ライト | グリーン | レッド ]", + "uploadType.enum.None": "なし", + "uploadType.enum.CustomUploader": "カスタムアップローダー", + "uploadType.enum.PicGoServer": "PicGoサーバー", + "uploadType.enumDescriptions.None": "アップローダーを使用せず、base64で画像を表示", + "uploadType.enumDescriptions.CustomUploader": "カスタムアップローダーを使用", + "uploadType.enumDescriptions.PicGoServer": "PicGoサーバーを使用", + "uploadType.description": "cherry-markdownのアップロードモード、利用可能な値: [ なし | カスタムアップローダー | PicGoサーバー ]", + "customUploader.enable.description": "カスタムアップローダーを有効にする", + "customUploader.url.description": "カスタムアップローダーのURL", + "customUploader.headers.description": "カスタムアップローダーのヘッダー", + "customUploader.headers.key.description": "カスタムアップローダーのヘッダーキー", + "customUploader.headers.value.description": "カスタムアップローダーのヘッダー値", + "customUploader.description": "cherry-markdownのカスタムアップローダー、画像/ビデオ/オーディオを独自のサーバーにアップロードする場合に設定が必要", + "picGoServer.description": "cherry-markdownのPicGoサーバー、画像/ビデオ/オーディオをPicGoサーバーにアップロードする場合に設定が必要", + "backfillImageProps.enum.isBorder": "ボーダーあり", + "backfillImageProps.enum.isNotBorder": "ボーダーなし", + "backfillImageProps.enum.isRadius": "角丸", + "backfillImageProps.enumDescriptions.isBorder": "画像にボーダーを追加するかどうか", + "backfillImageProps.enumDescriptions.isShadow": "画像に影を追加するかどうか", + "backfillImageProps.enumDescriptions.isRadius": "画像に角丸を追加するかどうか", + "backfillImageProps.description": "cherry-markdownの画像プロパティの補完、画像プロパティを補完する場合に設定が必要" +} \ No newline at end of file diff --git a/vscodePlugin/package.nls.json b/vscodePlugin/package.nls.json new file mode 100644 index 00000000..1db7cce5 --- /dev/null +++ b/vscodePlugin/package.nls.json @@ -0,0 +1,33 @@ +{ + "description": "A markdown previewer powered by [cherry-markdown](https://github.com/Tencent/cherry-markdown)", + "usage.enum.active": "active", + "usage.enum.only-manual": "only-manual", + "usage.description": "cherry-markdown's triggering method values: [ active | only-manual ]", + "theme.enum.default": "default", + "theme.enum.dark": "dark", + "theme.enum.light": "light", + "theme.enum.green": "green", + "theme.enum.red": "red", + "theme.description": "cherry-markdown's theme, available values: [ default | dark | light | green | red ]", + "uploadType.enum.None": "None", + "uploadType.enum.CustomUploader": "CustomUploader", + "uploadType.enum.PicGoServer": "PicGoServer", + "uploadType.enumDescriptions.None": "dont use any uploader, use base64 to show image", + "uploadType.enumDescriptions.CustomUploader": "use custom uploader", + "uploadType.enumDescriptions.PicGoServer": "use picgo server", + "uploadType.description": "cherry-markdown's upload mode, available values: [ None | CustomUploader | PicGoServer ]", + "customUploader.enable.description": "enable custom uploader", + "customUploader.url.description": "custom uploader url", + "customUploader.headers.description": "custom uploader headers", + "customUploader.headers.key.description": "custom uploader headers key", + "customUploader.headers.value.description": "custom uploader headers value", + "customUploader.description": "cherry-markdown's custom uploader, you need config it if you want to upload images / video / audio to your own server", + "picGoServer.description": "cherry-markdown's picgo server, you need config it if you want to upload images / video / audio to picgo server,", + "backfillImageProps.enum.isBorder": "isBorder", + "backfillImageProps.enum.isNotBorder": "isNotBorder", + "backfillImageProps.enum.isRadius": "isRadius", + "backfillImageProps.enumDescriptions.isBorder": "Whether to add a border to the image", + "backfillImageProps.enumDescriptions.isShadow": "Whether to add a shadow to the image", + "backfillImageProps.enumDescriptions.isRadius": "Whether to add a rounded corner to the image", + "backfillImageProps.description": "cherry-markdown's backfill image props, you need config it if you want to backfill image props" +} \ No newline at end of file diff --git a/vscodePlugin/package.nls.zh-cn.json b/vscodePlugin/package.nls.zh-cn.json new file mode 100644 index 00000000..4fccb6b0 --- /dev/null +++ b/vscodePlugin/package.nls.zh-cn.json @@ -0,0 +1,33 @@ +{ + "description": "由 [cherry-markdown](https://github.com/Tencent/cherry-markdown) 提供支持的 Markdown 预览器", + "usage.enum.active": "激活", + "usage.enum.only-manual": "仅手动", + "usage.description": "cherry-markdown 的触发方式值:[ 激活 | 仅手动 ]", + "theme.enum.default": "默认", + "theme.enum.dark": "黑暗", + "theme.enum.light": "明亮", + "theme.enum.green": "绿色", + "theme.enum.red": "红色", + "theme.description": "cherry-markdown 的主题,可用值:[ 默认 | 黑暗 | 明亮 | 绿色 | 红色 ]", + "uploadType.enum.None": "无", + "uploadType.enum.CustomUploader": "自定义上传器", + "uploadType.enum.PicGoServer": "PicGo 服务器", + "uploadType.enumDescriptions.None": "不使用任何上传器,使用 base64 显示图像", + "uploadType.enumDescriptions.CustomUploader": "使用自定义上传器", + "uploadType.enumDescriptions.PicGoServer": "使用 PicGo 服务器", + "uploadType.description": "cherry-markdown 的上传模式,可用值:[ 无 | 自定义上传器 | PicGo 服务器 ]", + "customUploader.enable.description": "启用自定义上传器", + "customUploader.url.description": "自定义上传器 URL", + "customUploader.headers.description": "自定义上传器头信息", + "customUploader.headers.key.description": "自定义上传器头信息键", + "customUploader.headers.value.description": "自定义上传器头信息值", + "customUploader.description": "cherry-markdown 的自定义上传器,如果你想将图像/视频/音频上传到自己的服务器,需要配置它", + "picGoServer.description": "cherry-markdown 的 PicGo 服务器,如果你想将图像/视频/音频上传到 PicGo 服务器,需要配置它", + "backfillImageProps.enum.isBorder": "有边框", + "backfillImageProps.enum.isNotBorder": "无边框", + "backfillImageProps.enum.isRadius": "有圆角", + "backfillImageProps.enumDescriptions.isBorder": "是否为图像添加边框", + "backfillImageProps.enumDescriptions.isShadow": "是否为图像添加阴影", + "backfillImageProps.enumDescriptions.isRadius": "是否为图像添加圆角", + "backfillImageProps.description": "cherry-markdown 的回填图像属性,如果你想回填图像属性,需要配置它" +} \ No newline at end of file diff --git a/vscodePlugin/src/extension.ts b/vscodePlugin/src/extension.ts index 002e03ff..2e134ea3 100644 --- a/vscodePlugin/src/extension.ts +++ b/vscodePlugin/src/extension.ts @@ -11,7 +11,7 @@ let disableScrollTrigger: boolean = false; // true:滚动时不往webview发 let disableEditTrigger: boolean = false; // true:变更内容时不往webview发送内容变更事件,反之发送 let cherryTheme: string | undefined = vscode.workspace .getConfiguration('cherryMarkdown') - .get('theme'); // 缓存主题 + .get('Theme'); // 缓存主题 export function activate(context: vscode.ExtensionContext) { extensionPath = context.extensionPath; // 注册命令 @@ -33,7 +33,7 @@ export function activate(context: vscode.ExtensionContext) { vscode.window.onDidChangeActiveTextEditor((e) => { const cherryUsage: 'active' | 'only-manual' | undefined = vscode.workspace .getConfiguration('cherryMarkdown') - .get('usage'); + .get('Usage'); if (e?.document && cherryUsage === 'active') { triggerEditorContentChange(); @@ -93,12 +93,13 @@ const getMarkdownFileInfo = () => { currentText = currentDoc?.getText() || ''; currentTitle = path.basename(currentDoc?.fileName) || ''; } + currentTitle = currentTitle - ? `预览 ${currentTitle} by cherry-markdown` + ? `${vscode.l10n.t('Preview')} ${currentTitle} ${vscode.l10n.t('By')} cherry-markdown` : '不支持当前文件 by cherry-markdown'; const theme = cherryTheme ? cherryTheme - : vscode.workspace.getConfiguration('cherryMarkdown').get('theme'); + : vscode.workspace.getConfiguration('cherryMarkdown').get('Theme'); const mdInfo = { text: currentText, theme }; return { mdInfo, currentTitle }; }; @@ -240,7 +241,7 @@ const triggerEditorContentChange = (focus: boolean = false) => { if (vscode.window.activeTextEditor?.document?.languageId === 'markdown') { const cherryUsage: 'active' | 'only-manual' | undefined = vscode.workspace .getConfiguration('cherryMarkdown') - .get('usage'); + .get('Usage'); if (cherryUsage === 'active' || focus) { initCherryPanel(); } From 4ee8c9668df469f3b57655b14b29b34e7c1dc786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E8=8F=9C=20Cai?= Date: Sat, 21 Dec 2024 17:27:11 +0800 Subject: [PATCH 2/6] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20webview=20?= =?UTF-8?q?=E7=9A=84=20i18n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vscodePlugin/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/vscodePlugin/package.json b/vscodePlugin/package.json index fad027bd..35539d54 100644 --- a/vscodePlugin/package.json +++ b/vscodePlugin/package.json @@ -10,6 +10,7 @@ "markdown editor", "markdown preview" ], + "l10n": "./l10n", "icon": "favicon.ico", "repository": { "type": "git", From ea2c11efc1adb2fc83e6a8e906931ecc7ddbf670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E8=8F=9C=20Cai?= Date: Sat, 21 Dec 2024 17:40:37 +0800 Subject: [PATCH 3/6] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=20=E5=8F=B3?= =?UTF-8?q?=E9=94=AE=E8=8F=9C=E5=8D=95=20=E5=A4=9A=E8=AF=AD=E8=A8=80?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vscodePlugin/package.json | 2 +- vscodePlugin/package.nls.ja.json | 1 + vscodePlugin/package.nls.json | 1 + vscodePlugin/package.nls.zh-cn.json | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/vscodePlugin/package.json b/vscodePlugin/package.json index 35539d54..53ffe537 100644 --- a/vscodePlugin/package.json +++ b/vscodePlugin/package.json @@ -31,7 +31,7 @@ "commands": [ { "command": "cherrymarkdown.preview", - "title": "Preview In Cherry Markdown" + "title": "%commands.preview.title%" } ], "menus": { diff --git a/vscodePlugin/package.nls.ja.json b/vscodePlugin/package.nls.ja.json index 048693e4..1f147d65 100644 --- a/vscodePlugin/package.nls.ja.json +++ b/vscodePlugin/package.nls.ja.json @@ -1,5 +1,6 @@ { "description_ja": "[cherry-markdown](https://github.com/Tencent/cherry-markdown) によって提供される Markdown プレビューア", + "commands.preview.title": "Cherry Markdown でプレビュー", "usage.enum.active": "アクティブ", "usage.enum.only-manual": "手動のみ", "usage.description": "cherry-markdownのトリガーメソッドの値: [ アクティブ | 手動のみ ]", diff --git a/vscodePlugin/package.nls.json b/vscodePlugin/package.nls.json index 1db7cce5..602dfb77 100644 --- a/vscodePlugin/package.nls.json +++ b/vscodePlugin/package.nls.json @@ -1,5 +1,6 @@ { "description": "A markdown previewer powered by [cherry-markdown](https://github.com/Tencent/cherry-markdown)", + "commands.preview.title": "Preview In Cherry Markdown", "usage.enum.active": "active", "usage.enum.only-manual": "only-manual", "usage.description": "cherry-markdown's triggering method values: [ active | only-manual ]", diff --git a/vscodePlugin/package.nls.zh-cn.json b/vscodePlugin/package.nls.zh-cn.json index 4fccb6b0..28488e2b 100644 --- a/vscodePlugin/package.nls.zh-cn.json +++ b/vscodePlugin/package.nls.zh-cn.json @@ -1,5 +1,6 @@ { "description": "由 [cherry-markdown](https://github.com/Tencent/cherry-markdown) 提供支持的 Markdown 预览器", + "commands.preview.title": "在 Cherry Markdown 中预览", "usage.enum.active": "激活", "usage.enum.only-manual": "仅手动", "usage.description": "cherry-markdown 的触发方式值:[ 激活 | 仅手动 ]", From d6895371ea7f68f342d2c23ca09aab4d39cbff66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E8=8F=9C=20Cai?= Date: Mon, 23 Dec 2024 03:45:53 +0800 Subject: [PATCH 4/6] =?UTF-8?q?feat:=20=E5=B0=86=20`cherrymakrdon`=20?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8=E5=B7=A5=E5=85=B7=E6=A0=8F=E8=AF=AD?= =?UTF-8?q?=E8=A8=80=E8=B7=9F=E9=9A=8F=20vscode=20=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E8=AF=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vscodePlugin/.vscode/settings.json | 3 +- vscodePlugin/l10n/bundle.l10n.ja.json | 3 +- vscodePlugin/l10n/bundle.l10n.ru.json | 5 +++ vscodePlugin/l10n/bundle.l10n.zh-cn.json | 3 +- vscodePlugin/package.json | 2 +- vscodePlugin/package.nls.ru.json | 34 +++++++++++++++++++++ vscodePlugin/src/extension.ts | 7 +++-- vscodePlugin/web-resources/scripts/index.js | 28 +++++++++++++++-- 8 files changed, 75 insertions(+), 10 deletions(-) create mode 100644 vscodePlugin/l10n/bundle.l10n.ru.json create mode 100644 vscodePlugin/package.nls.ru.json diff --git a/vscodePlugin/.vscode/settings.json b/vscodePlugin/.vscode/settings.json index 5c5ac48c..1f3227c7 100644 --- a/vscodePlugin/.vscode/settings.json +++ b/vscodePlugin/.vscode/settings.json @@ -9,5 +9,6 @@ "dist": true // set this to false to include "dist" folder in search results }, // Turn off tsc task auto detection since we have the necessary tasks as npm scripts - "typescript.tsc.autoDetect": "off" + "typescript.tsc.autoDetect": "off", + "commentTranslate.targetLanguage": "en" } \ No newline at end of file diff --git a/vscodePlugin/l10n/bundle.l10n.ja.json b/vscodePlugin/l10n/bundle.l10n.ja.json index 02a4061a..ef6948d8 100644 --- a/vscodePlugin/l10n/bundle.l10n.ja.json +++ b/vscodePlugin/l10n/bundle.l10n.ja.json @@ -1,4 +1,5 @@ { "Preview": "プレビュー", -"By": "によって" +"By": "によって", +"UnSupported": "サポートされていません" } diff --git a/vscodePlugin/l10n/bundle.l10n.ru.json b/vscodePlugin/l10n/bundle.l10n.ru.json new file mode 100644 index 00000000..f6c277ff --- /dev/null +++ b/vscodePlugin/l10n/bundle.l10n.ru.json @@ -0,0 +1,5 @@ +{ + "Preview": "Предварительный просмотр", + "By": "От", + "UnSupported": "Не поддерживается" +} \ No newline at end of file diff --git a/vscodePlugin/l10n/bundle.l10n.zh-cn.json b/vscodePlugin/l10n/bundle.l10n.zh-cn.json index cb698a41..cc462995 100644 --- a/vscodePlugin/l10n/bundle.l10n.zh-cn.json +++ b/vscodePlugin/l10n/bundle.l10n.zh-cn.json @@ -1,4 +1,5 @@ { "Preview": "预览", - "By": "通过" + "By": "通过", + "UnSupported": "不支持" } \ No newline at end of file diff --git a/vscodePlugin/package.json b/vscodePlugin/package.json index 53ffe537..b9deead7 100644 --- a/vscodePlugin/package.json +++ b/vscodePlugin/package.json @@ -18,7 +18,7 @@ }, "homepage": "https://github.com/Tencent/cherry-markdown", "engines": { - "vscode": "^1.58.0" + "vscode": "^1.73.0" }, "categories": [ "Other" diff --git a/vscodePlugin/package.nls.ru.json b/vscodePlugin/package.nls.ru.json new file mode 100644 index 00000000..4b22ad51 --- /dev/null +++ b/vscodePlugin/package.nls.ru.json @@ -0,0 +1,34 @@ +{ + "description": "Просмотрщик markdown, работающий на [cherry-markdown](https://github.com/Tencent/cherry-markdown)", + "commands.preview.title": "Просмотр в Cherry Markdown", + "usage.enum.active": "активный", + "usage.enum.only-manual": "только вручную", + "usage.description": "значения метода триггера cherry-markdown: [ активный | только вручную ]", + "theme.enum.default": "по умолчанию", + "theme.enum.dark": "темный", + "theme.enum.light": "светлый", + "theme.enum.green": "зеленый", + "theme.enum.red": "красный", + "theme.description": "тема cherry-markdown, доступные значения: [ по умолчанию | темный | светлый | зеленый | красный ]", + "uploadType.enum.None": "Нет", + "uploadType.enum.CustomUploader": "Пользовательский загрузчик", + "uploadType.enum.PicGoServer": "PicGoServer", + "uploadType.enumDescriptions.None": "не использовать загрузчик, использовать base64 для отображения изображения", + "uploadType.enumDescriptions.CustomUploader": "использовать пользовательский загрузчик", + "uploadType.enumDescriptions.PicGoServer": "использовать сервер picgo", + "uploadType.description": "режим загрузки cherry-markdown, доступные значения: [ Нет | Пользовательский загрузчик | PicGoServer ]", + "customUploader.enable.description": "включить пользовательский загрузчик", + "customUploader.url.description": "URL пользовательского загрузчика", + "customUploader.headers.description": "заголовки пользовательского загрузчика", + "customUploader.headers.key.description": "ключ заголовков пользовательского загрузчика", + "customUploader.headers.value.description": "значение заголовков пользовательского загрузчика", + "customUploader.description": "пользовательский загрузчик cherry-markdown, необходимо настроить его, если вы хотите загружать изображения / видео / аудио на свой сервер", + "picGoServer.description": "сервер picgo cherry-markdown, необходимо настроить его, если вы хотите загружать изображения / видео / аудио на сервер picgo", + "backfillImageProps.enum.isBorder": "с границей", + "backfillImageProps.enum.isNotBorder": "без границы", + "backfillImageProps.enum.isRadius": "с радиусом", + "backfillImageProps.enumDescriptions.isBorder": "Добавить ли границу к изображению", + "backfillImageProps.enumDescriptions.isShadow": "Добавить ли тень к изображению", + "backfillImageProps.enumDescriptions.isRadius": "Добавить ли закругленные углы к изображению", + "backfillImageProps.description": "свойства обратного заполнения изображения cherry-markdown, необходимо настроить их, если вы хотите заполнить свойства изображения" +} diff --git a/vscodePlugin/src/extension.ts b/vscodePlugin/src/extension.ts index 2e134ea3..0a3e604c 100644 --- a/vscodePlugin/src/extension.ts +++ b/vscodePlugin/src/extension.ts @@ -95,8 +95,8 @@ const getMarkdownFileInfo = () => { } currentTitle = currentTitle - ? `${vscode.l10n.t('Preview')} ${currentTitle} ${vscode.l10n.t('By')} cherry-markdown` - : '不支持当前文件 by cherry-markdown'; + ? `${vscode.l10n.t('Preview')} ${currentTitle} ${vscode.l10n.t('By')} Cherry Markdown` + : `${vscode.l10n.t('UnSupported')} ${vscode.l10n.t('By')} Cherry Markdown`; const theme = cherryTheme ? cherryTheme : vscode.workspace.getConfiguration('cherryMarkdown').get('Theme'); @@ -124,8 +124,9 @@ const initCherryPanel = () => { ], }, ); + console.log('vscode.env.language', vscode.env.language); cherryPanel.webview.html = getWebviewContent( - mdInfo, + { ...mdInfo, vscodeLanguage: vscode.env.language }, cherryPanel, extensionPath, ); diff --git a/vscodePlugin/web-resources/scripts/index.js b/vscodePlugin/web-resources/scripts/index.js index ac595df4..e01ea506 100644 --- a/vscodePlugin/web-resources/scripts/index.js +++ b/vscodePlugin/web-resources/scripts/index.js @@ -59,8 +59,6 @@ const customMenuFont = Cherry.createMenuHook('字体样式', { /** 处理 a 链接跳转问题 */ const onClickLink = (e, target) => { - - // 这里不能直接使用 target.href,因为本地相对文件地址会被vscode转成`webview://`协议 const href = target.attributes?.href.value; @@ -292,8 +290,32 @@ function isHttpUrl(url) { return /https?:\/\//.test(url); } +/** + * [vscode language](https://code.visualstudio.com/docs/getstarted/locales#_available-locales); + * [cherry language](https://github.com/Tencent/cherry-markdown/wiki/%E5%A4%9A%E8%AF%AD%E8%A8%80); + * */ +const languageIdentifiers = { + en: 'en_US', // English (US) + 'zh-cn': 'zh_CN', // Simplified Chinese + 'zh-tw': '繁体中文', // Traditional Chinese + fr: '法语', // French + de: '德语', // German + it: '意大利语', // Italian + es: '西班牙语', // Spanish + ja: 'ja_JP', // Japanese + ko: '韩国人', // Korean + ru: 'ru_RU', // Russian + 'pt-br': '葡萄牙语(巴西)', // Portuguese (Brazil) + tr: '土耳其', // Turkish + pl: '抛光', // Polish + cs: '捷克语', // Czech + hu: '匈牙利', // Hungarian +}; + const mdInfo = JSON.parse(document.getElementById('markdown-info').value); -const config = Object.assign({}, basicConfig, { value: mdInfo.text }); +const locale = languageIdentifiers[mdInfo.vscodeLanguage] || 'zh_CN'; + +const config = Object.assign({}, basicConfig, { value: mdInfo.text, locale }); // eslint-disable-next-line new-cap, no-undef const cherry = new Cherry(config); // eslint-disable-next-line no-undef From d8f8daa18f6da63249b132d53b8107703e9efdd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=20Cai?= Date: Mon, 23 Dec 2024 09:58:49 +0800 Subject: [PATCH 5/6] =?UTF-8?q?chore:=20=E7=A7=BB=E9=99=A4=E5=AF=B9?= =?UTF-8?q?=E4=BA=8E=E6=97=A5=E8=AF=AD=E7=9A=84=E6=94=AF=E6=8C=81=EF=BC=8C?= =?UTF-8?q?=E5=92=8C=E5=AF=B9=E4=BA=8E=E5=85=B6=E4=BB=96=E8=AF=AD=E8=A8=80?= =?UTF-8?q?=E7=9A=84=E7=B4=A2=E5=BC=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vscodePlugin/l10n/bundle.l10n.ja.json | 5 --- vscodePlugin/package.nls.ja.json | 34 --------------------- vscodePlugin/web-resources/scripts/index.js | 24 +++++++-------- 3 files changed, 12 insertions(+), 51 deletions(-) delete mode 100644 vscodePlugin/l10n/bundle.l10n.ja.json delete mode 100644 vscodePlugin/package.nls.ja.json diff --git a/vscodePlugin/l10n/bundle.l10n.ja.json b/vscodePlugin/l10n/bundle.l10n.ja.json deleted file mode 100644 index ef6948d8..00000000 --- a/vscodePlugin/l10n/bundle.l10n.ja.json +++ /dev/null @@ -1,5 +0,0 @@ -{ -"Preview": "プレビュー", -"By": "によって", -"UnSupported": "サポートされていません" -} diff --git a/vscodePlugin/package.nls.ja.json b/vscodePlugin/package.nls.ja.json deleted file mode 100644 index 1f147d65..00000000 --- a/vscodePlugin/package.nls.ja.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "description_ja": "[cherry-markdown](https://github.com/Tencent/cherry-markdown) によって提供される Markdown プレビューア", - "commands.preview.title": "Cherry Markdown でプレビュー", - "usage.enum.active": "アクティブ", - "usage.enum.only-manual": "手動のみ", - "usage.description": "cherry-markdownのトリガーメソッドの値: [ アクティブ | 手動のみ ]", - "theme.enum.default": "デフォルト", - "theme.enum.dark": "ダーク", - "theme.enum.light": "ライト", - "theme.enum.green": "グリーン", - "theme.enum.red": "レッド", - "theme.description": "cherry-markdownのテーマ、利用可能な値: [ デフォルト | ダーク | ライト | グリーン | レッド ]", - "uploadType.enum.None": "なし", - "uploadType.enum.CustomUploader": "カスタムアップローダー", - "uploadType.enum.PicGoServer": "PicGoサーバー", - "uploadType.enumDescriptions.None": "アップローダーを使用せず、base64で画像を表示", - "uploadType.enumDescriptions.CustomUploader": "カスタムアップローダーを使用", - "uploadType.enumDescriptions.PicGoServer": "PicGoサーバーを使用", - "uploadType.description": "cherry-markdownのアップロードモード、利用可能な値: [ なし | カスタムアップローダー | PicGoサーバー ]", - "customUploader.enable.description": "カスタムアップローダーを有効にする", - "customUploader.url.description": "カスタムアップローダーのURL", - "customUploader.headers.description": "カスタムアップローダーのヘッダー", - "customUploader.headers.key.description": "カスタムアップローダーのヘッダーキー", - "customUploader.headers.value.description": "カスタムアップローダーのヘッダー値", - "customUploader.description": "cherry-markdownのカスタムアップローダー、画像/ビデオ/オーディオを独自のサーバーにアップロードする場合に設定が必要", - "picGoServer.description": "cherry-markdownのPicGoサーバー、画像/ビデオ/オーディオをPicGoサーバーにアップロードする場合に設定が必要", - "backfillImageProps.enum.isBorder": "ボーダーあり", - "backfillImageProps.enum.isNotBorder": "ボーダーなし", - "backfillImageProps.enum.isRadius": "角丸", - "backfillImageProps.enumDescriptions.isBorder": "画像にボーダーを追加するかどうか", - "backfillImageProps.enumDescriptions.isShadow": "画像に影を追加するかどうか", - "backfillImageProps.enumDescriptions.isRadius": "画像に角丸を追加するかどうか", - "backfillImageProps.description": "cherry-markdownの画像プロパティの補完、画像プロパティを補完する場合に設定が必要" -} \ No newline at end of file diff --git a/vscodePlugin/web-resources/scripts/index.js b/vscodePlugin/web-resources/scripts/index.js index e01ea506..c68171ee 100644 --- a/vscodePlugin/web-resources/scripts/index.js +++ b/vscodePlugin/web-resources/scripts/index.js @@ -297,19 +297,19 @@ function isHttpUrl(url) { const languageIdentifiers = { en: 'en_US', // English (US) 'zh-cn': 'zh_CN', // Simplified Chinese - 'zh-tw': '繁体中文', // Traditional Chinese - fr: '法语', // French - de: '德语', // German - it: '意大利语', // Italian - es: '西班牙语', // Spanish - ja: 'ja_JP', // Japanese - ko: '韩国人', // Korean + // 'zh-tw': '繁体中文', // Traditional Chinese + // fr: '法语', // French + // de: '德语', // German + // it: '意大利语', // Italian + // es: '西班牙语', // Spanish + // ja: '日语', // Japanese + // ko: '韩国人', // Korean ru: 'ru_RU', // Russian - 'pt-br': '葡萄牙语(巴西)', // Portuguese (Brazil) - tr: '土耳其', // Turkish - pl: '抛光', // Polish - cs: '捷克语', // Czech - hu: '匈牙利', // Hungarian + // 'pt-br': '葡萄牙语(巴西)', // Portuguese (Brazil) + // tr: '土耳其', // Turkish + // pl: '波兰', // Polish + // cs: '捷克语', // Czech + // hu: '匈牙利', // Hungarian }; const mdInfo = JSON.parse(document.getElementById('markdown-info').value); From 8d1039b1055174b92dd8c0e387342190e504e995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=20Cai?= Date: Mon, 23 Dec 2024 10:00:53 +0800 Subject: [PATCH 6/6] chore: reset vscodePlugin .vscode settings --- vscodePlugin/.vscode/settings.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/vscodePlugin/.vscode/settings.json b/vscodePlugin/.vscode/settings.json index 1f3227c7..5c5ac48c 100644 --- a/vscodePlugin/.vscode/settings.json +++ b/vscodePlugin/.vscode/settings.json @@ -9,6 +9,5 @@ "dist": true // set this to false to include "dist" folder in search results }, // Turn off tsc task auto detection since we have the necessary tasks as npm scripts - "typescript.tsc.autoDetect": "off", - "commentTranslate.targetLanguage": "en" + "typescript.tsc.autoDetect": "off" } \ No newline at end of file