This commit is contained in:
锦恢 2024-10-29 23:22:42 +08:00
parent 549aed0a28
commit 571749f4c7
12 changed files with 144 additions and 94 deletions

View File

@ -7,5 +7,8 @@
"out": true // set this to false to include "out" folder in search results "out": true // set this to false to include "out" folder in search results
}, },
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts // Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off" "typescript.tsc.autoDetect": "off",
"i18n-haru.root": "l10n",
"i18n-haru.main": "zh-cn",
"i18n-haru.line-hint-max-length": 20
} }

39
l10n/README.md Normal file
View File

@ -0,0 +1,39 @@
命名规则:
```html
<level>.<module>.<name>
```
比如 `info.monitor.update-pl`
- info: 通知等级
- monitor: 功能模块,此处是监视器
- name: 对于模块功能的描述,可以是更加复杂的层级关系,比如 name.subname.subsubname
上述的一个描述代表了一个如此的功能描述:
该功能描述了 monitor 这个功能模块的一个名叫 update-pl 的功能,该功能在进行输出时,输出等级为 info.
有的时候一个功能下可能希望更加细粒度的描述,比如说上面的 update-pl这个功能的描述文本可以作为最终的主体文本text也可以作为最终描述该功能组件的标题title也可以是该功能的一个按钮button。总之有的时候我们还希望指定该功能描述的一个实体/组件。所以下面的格式也是符合要求的:
```html
<level>.<module>.<name>.<component>
```
比如以下的三组描述:
```json
{
"info.vcd-view.load.button": "加载",
"info.vcd-view.load.title": "加载",
"info.vcd-view.load.text": "正在加载 ..."
}
```
它们都代表了 `vcd-view` 这个功能模块的名为 `load` 的功能的中文翻译,但是这三个文本分别描述了实施这个 load 功能的功能组件:
- `info.vcd-view.load.button` 描述了 button 位置上需要渲染的文本
- `info.vcd-view.load.title` 描述了 title 位置上需要渲染的文本
- `info.vcd-view.load.text` 描述了 text 位置上需要渲染的文本
关于如何进行规定 `<component>` 位置上的值,应该由产品经理来规定。

View File

@ -1,25 +1,27 @@
{ {
"hello": "hello in English", "info.test.hello": "hello in English",
"welcome.title": "Thanks for using Digital-IDE ❤️. Your star will be our best motivation! 😊", "info.welcome.title": "Thanks for using Digital-IDE ❤️. Your star will be our best motivation! 😊",
"welcome.star": "Star", "info.welcome.star": "Star",
"welcome.refuse": "Refuse", "info.welcome.refuse": "Refuse",
"progress.register-command": "Register Command", "info.progress.register-command": "Register Command",
"progress.active-lsp-server": "Activate LSP Server", "info.progress.active-lsp-server": "Activate LSP Server",
"progress.initialization": "Initialization", "info.progress.initialization": "Initialization",
"progress.build-module-tree": "Build Module Tree", "info.progress.build-module-tree": "Build Module Tree",
"progress.download-digital-lsp": "Download Digital LSP", "info.progress.download-digital-lsp": "Download Digital LSP",
"progress.choose-best-download-source": "Choose Best Download Source", "info.progress.choose-best-download-source": "Choose Best Download Source",
"progress.extract-digital-lsp": "Extract Digital LSP", "info.progress.extract-digital-lsp": "Extract Digital LSP",
"error.download-digital-lsp": "Fail to download digital lsp server, check your network and reload vscode. You can also visit following site and download manually: https://github.com/Digital-EDA/Digital-IDE/releases/tag/", "error.lsp.download-digital-lsp": "Fail to download digital lsp server, check your network and reload vscode. You can also visit following site and download manually: https://github.com/Digital-EDA/Digital-IDE/releases/tag/",
"error.save-file": "保存文件失败", "error.filelist.save-file": "保存文件失败",
"warning.ppy-already-exist": "property.json 已经存在了!", "warning.ppy-already-exist": "property.json 已经存在了!",
"save": "保存", "info.monitor.update-hdlparam": "更新 HdlParam",
"save-as-view": "另存为视图文件", "info.monitor.update-pl": "更新 PL",
"vcd-view-file": "vcd 视图文件", "info.vcd-viewer.save": "保存",
"all-file": "所有文件", "info.vcd-viewer.save-as-view": "另存为视图文件",
"load": "加载", "info.vcd-viewer.vcd-view-file": "vcd 视图文件",
"load-view-file": "加载视图文件", "info.vcd-viewer.all-file": "所有文件",
"bad-view-file": "视图文件已损坏", "info.vcd-viewer.load.button": "加载",
"error.unexist-direct-vcd-file": "视图文件指向的 vcd 文件不存在", "info.vcd-viewer.load.title": "加载视图文件",
"click.join-qq-group": "Click the link to join the QQ group" "error.vcd-viewer.bad-view-file": "视图文件已损坏",
"error.vcd-viewer.unexist-direct-vcd-file": "视图文件指向的 vcd 文件不存在",
"info.welcome.join-qq-group": "Click the link to join the QQ group"
} }

View File

@ -1,25 +1,27 @@
{ {
"hello": "你好", "info.test.hello": "你好",
"welcome.title": "感谢使用 Digital-IDE ❤️。您的支持将是我们最大的动力!😊", "info.welcome.title": "感谢使用 Digital-IDE ❤️。您的支持将是我们最大的动力!😊",
"welcome.star": "支持", "info.welcome.star": "支持",
"welcome.refuse": "拒绝", "info.welcome.refuse": "拒绝",
"progress.register-command": "Digital IDE 注册命令", "info.progress.register-command": "Digital IDE 注册命令",
"progress.active-lsp-server": "Digital IDE 激活语言服务器", "info.progress.active-lsp-server": "Digital IDE 激活语言服务器",
"progress.initialization": "Digital IDE 初始化", "info.progress.initialization": "Digital IDE 初始化",
"progress.build-module-tree": "构建模块树", "info.progress.build-module-tree": "构建模块树",
"progress.download-digital-lsp": "下载 Digital IDE 语言服务器", "info.progress.download-digital-lsp": "下载 Digital IDE 语言服务器",
"progress.choose-best-download-source": "选择最佳下载源", "info.progress.choose-best-download-source": "选择最佳下载源",
"progress.extract-digital-lsp": "解压 Digital LSP 语言服务器", "info.progress.extract-digital-lsp": "解压 Digital LSP 语言服务器",
"error.download-digital-lsp": "无法下载 Digital LSP 语言服务器,检查你的网络后重启 vscode或者请手动去下方地址下载 https://github.com/Digital-EDA/Digital-IDE/releases/tag/", "error.lsp.download-digital-lsp": "无法下载 Digital LSP 语言服务器,检查你的网络后重启 vscode或者请手动去下方地址下载 https://github.com/Digital-EDA/Digital-IDE/releases/tag/",
"error.save-file": "保存文件失败", "error.filelist.save-file": "保存文件失败",
"warning.ppy.already-exist": "property.json 已经存在了!", "warning.ppy.already-exist": "property.json 已经存在了!",
"save": "保存", "info.monitor.update-hdlparam": "更新 HdlParam",
"save-as-view": "另存为视图文件", "info.monitor.update-pl": "更新 PL",
"vcd-view-file": "vcd 视图文件", "info.vcd-viewer.save": "保存",
"all-file": "所有文件", "info.vcd-viewer.save-as-view": "另存为视图文件",
"load": "加载", "info.vcd-viewer.vcd-view-file": "vcd 视图文件",
"load-view-file": "加载视图文件", "info.vcd-viewer.all-file": "所有文件",
"bad-view-file": "视图文件已损坏", "info.vcd-viewer.load.button": "加载",
"error.unexist-direct-vcd-file": "视图文件指向的 vcd 文件不存在", "info.vcd-viewer.load.title": "加载视图文件",
"click.join-qq-group": "点击链接加入QQ群一起讨论" "error.vcd-viewer.bad-view-file": "视图文件已损坏",
"error.vcd-viewer.unexist-direct-vcd-file": "视图文件指向的 vcd 文件不存在",
"info.welcome.join-qq-group": "点击链接加入QQ群一起讨论"
} }

View File

@ -1,25 +1,27 @@
{ {
"hello": "你好", "info.test.hello": "你好",
"welcome.title": "感謝使用 Digital-IDE ❤️。您的支持將是我們最大的動力!😊", "info.welcome.title": "感謝使用 Digital-IDE ❤️。您的支持將是我們最大的動力!😊",
"welcome.star": "支持", "info.welcome.star": "支持",
"welcome.refuse": "拒絕", "info.welcome.refuse": "拒絕",
"progress.register-command": "(Digital IDE) 註冊命令", "info.progress.register-command": "(Digital IDE) 註冊命令",
"progress.active-lsp-server": "Activate LSP Server", "info.progress.active-lsp-server": "Activate LSP Server",
"progress.initialization": "(Digital IDE) 初始化", "info.progress.initialization": "(Digital IDE) 初始化",
"progress.build-module-tree": "構建模塊樹", "info.progress.build-module-tree": "構建模塊樹",
"progress.download-digital-lsp": "Download Digital LSP", "info.progress.download-digital-lsp": "Download Digital LSP",
"progress.choose-best-download-source": "Choose Best Download Source", "info.progress.choose-best-download-source": "Choose Best Download Source",
"progress.extract-digital-lsp": "Extract Digital LSP", "info.progress.extract-digital-lsp": "Extract Digital LSP",
"error.download-digital-lsp": "Fail to download digital lsp server, check your network and reload vscode", "error.lsp.download-digital-lsp": "Fail to download digital lsp server, check your network and reload vscode",
"error.save-file": "保存文件失败", "error.filelist.save-file": "保存文件失败",
"warning.ppy-already-exist": "property.json 已经存在了!", "warning.ppy-already-exist": "property.json 已经存在了!",
"save": "保存", "info.monitor.update-hdlparam": "更新 HdlParam",
"save-as-view": "另存为视图文件", "info.monitor.update-pl": "更新 PL",
"vcd-view-file": "vcd 视图文件", "info.vcd-viewer.save": "保存",
"all-file": "所有文件", "info.vcd-viewer.save-as-view": "另存为视图文件",
"load": "加载", "info.vcd-viewer.vcd-view-file": "vcd 视图文件",
"load-view-file": "加载视图文件", "info.vcd-viewer.all-file": "所有文件",
"bad-view-file": "视图文件已损坏", "info.vcd-viewer.load.button": "加载",
"error.unexist-direct-vcd-file": "视图文件指向的 vcd 文件不存在", "info.vcd-viewer.load.title": "加载视图文件",
"click.join-qq-group": "点击链接加入QQ群一起讨论" "error.vcd-viewer.bad-view-file": "视图文件已损坏",
"error.vcd-viewer.unexist-direct-vcd-file": "视图文件指向的 vcd 文件不存在",
"info.welcome.join-qq-group": "点击链接加入QQ群一起讨论"
} }

View File

@ -33,13 +33,13 @@ function getVersion(context: vscode.ExtensionContext): string {
async function launch(context: vscode.ExtensionContext) { async function launch(context: vscode.ExtensionContext) {
const { t } = vscode.l10n; const { t } = vscode.l10n;
console.log(t('welcome.title')); console.log(t('info.welcome.title'));
console.log(t('click.join-qq-group') + ' https://qm.qq.com/q/1M655h3GsA'); console.log(t('info.welcome.join-qq-group') + ' https://qm.qq.com/q/1M655h3GsA');
const versionString = getVersion(context); const versionString = getVersion(context);
await vscode.window.withProgress({ await vscode.window.withProgress({
location: vscode.ProgressLocation.Window, location: vscode.ProgressLocation.Window,
title: t('progress.register-command') title: t('info.progress.register-command')
}, async () => { }, async () => {
await registerCommand(context, versionString); await registerCommand(context, versionString);
}); });
@ -49,7 +49,7 @@ async function launch(context: vscode.ExtensionContext) {
await vscode.window.withProgress({ await vscode.window.withProgress({
location: vscode.ProgressLocation.Window, location: vscode.ProgressLocation.Window,
title: t('progress.initialization') title: t('info.progress.initialization')
}, async (progress: vscode.Progress<IProgress>, token: vscode.CancellationToken) => { }, async (progress: vscode.Progress<IProgress>, token: vscode.CancellationToken) => {
// 初始化解析 // 初始化解析
await manager.prjManage.initialise(context, progress); await manager.prjManage.initialise(context, progress);
@ -77,9 +77,9 @@ async function launch(context: vscode.ExtensionContext) {
// don't show in next time // don't show in next time
welcomeSetting.update('show', false, vscode.ConfigurationTarget.Global); welcomeSetting.update('show', false, vscode.ConfigurationTarget.Global);
const res = await vscode.window.showInformationMessage( const res = await vscode.window.showInformationMessage(
t('welcome.title'), t('info.welcome.title'),
{ title: t('welcome.star'), value: true }, { title: t('info.welcome.star'), value: true },
{ title: t('welcome.refuse'), value: false }, { title: t('info.welcome.refuse'), value: false },
); );
if (res?.value) { if (res?.value) {
vscode.env.openExternal(vscode.Uri.parse('https://github.com/Digital-EDA/Digital-IDE')); vscode.env.openExternal(vscode.Uri.parse('https://github.com/Digital-EDA/Digital-IDE'));

View File

@ -79,6 +79,7 @@ function getFilename(file: string) {
export async function saveViewAs(data: any, uri: vscode.Uri, panel: vscode.WebviewPanel) { export async function saveViewAs(data: any, uri: vscode.Uri, panel: vscode.WebviewPanel) {
const { t } = vscode.l10n; const { t } = vscode.l10n;
try { try {
// 先保存原来的文件 payload 一定是 all // 先保存原来的文件 payload 一定是 all
let { originVcdFile, originVcdViewFile, payload } = data; let { originVcdFile, originVcdViewFile, payload } = data;
@ -95,13 +96,13 @@ export async function saveViewAs(data: any, uri: vscode.Uri, panel: vscode.Webvi
// 询问新的路径 // 询问新的路径
const defaultFilename = getFilename(payload.originVcdFile); const defaultFilename = getFilename(payload.originVcdFile);
const vcdFilters: Record<string, string[]> = {}; const vcdFilters: Record<string, string[]> = {};
vcdFilters[t('vcd-view-file')] = ['view']; vcdFilters[t('info.vcd-viewer.vcd-view-file')] = ['view'];
vcdFilters[t('all-file')] = ['*']; vcdFilters[t('info.vcd-viewer.all-file')] = ['*'];
const saveUri = await vscode.window.showSaveDialog({ const saveUri = await vscode.window.showSaveDialog({
title: t('save-as-view'), title: t('info.vcd-viewer.save-as-view'),
defaultUri: vscode.Uri.file(path.join(rootPath, defaultFilename)), defaultUri: vscode.Uri.file(path.join(rootPath, defaultFilename)),
saveLabel: t('save'), saveLabel: t('info.vcd-viewer.save'),
filters: vcdFilters filters: vcdFilters
}); });
@ -144,13 +145,13 @@ export async function loadView(data: any, uri: vscode.Uri, panel: vscode.Webview
const defaultFolder = path.dirname(vcdPath); const defaultFolder = path.dirname(vcdPath);
const vcdFilters: Record<string, string[]> = {}; const vcdFilters: Record<string, string[]> = {};
vcdFilters[t('vcd-view-file')] = ['view']; vcdFilters[t('info.vcd-viewer.vcd-view-file')] = ['view'];
vcdFilters[t('all-file')] = ['*']; vcdFilters[t('info.vcd-viewer.all-file')] = ['*'];
const viewUri = await vscode.window.showOpenDialog({ const viewUri = await vscode.window.showOpenDialog({
title: t('load-view-file'), title: t('info.vcd-viewer.load.title'),
defaultUri: vscode.Uri.file(defaultFolder), defaultUri: vscode.Uri.file(defaultFolder),
openLabel: t('load'), openLabel: t('info.vcd-viewer.load.button'),
canSelectFiles: true, canSelectFiles: true,
canSelectMany: false, canSelectMany: false,
canSelectFolders: false, canSelectFolders: false,

View File

@ -221,14 +221,14 @@ function getViewLaunchFiles(context: vscode.ExtensionContext, uri: vscode.Uri, p
if (recoverJson.originVcdFile) { if (recoverJson.originVcdFile) {
const vcdPath = recoverJson.originVcdFile; const vcdPath = recoverJson.originVcdFile;
if (!fs.existsSync(vcdPath)) { if (!fs.existsSync(vcdPath)) {
return new Error(t('error.unexist-direct-vcd-file') + ':' + vcdPath); return new Error(t('error.vcd-viewer.unexist-direct-vcd-file') + ':' + vcdPath);
} }
const vcd = panel.webview.asWebviewUri(vscode.Uri.file(recoverJson.originVcdFile)).toString(); const vcd = panel.webview.asWebviewUri(vscode.Uri.file(recoverJson.originVcdFile)).toString();
const view = panel.webview.asWebviewUri(uri).toString(); const view = panel.webview.asWebviewUri(uri).toString();
return { vcd, view, worker, root }; return { vcd, view, worker, root };
} else { } else {
return new Error(t('bad-view-file') + ':' + entryPath); return new Error(t('error.vcd-viewer.bad-view-file') + ':' + entryPath);
} }
} }
return new Error('unsupported languages'); return new Error('unsupported languages');

View File

@ -101,7 +101,7 @@ export async function downloadLsp(context: vscode.ExtensionContext, version: str
const downloadLink = await vscode.window.withProgress({ const downloadLink = await vscode.window.withProgress({
location: vscode.ProgressLocation.Notification, location: vscode.ProgressLocation.Notification,
title: t('progress.choose-best-download-source') title: t('info.progress.choose-best-download-source')
}, async (progress: vscode.Progress<IProgress>, token: vscode.CancellationToken) => { }, async (progress: vscode.Progress<IProgress>, token: vscode.CancellationToken) => {
let timeout = 3000; let timeout = 3000;
let reportInterval = 500; let reportInterval = 500;
@ -119,7 +119,7 @@ export async function downloadLsp(context: vscode.ExtensionContext, version: str
const tarGzFilePath = await vscode.window.withProgress({ const tarGzFilePath = await vscode.window.withProgress({
location: vscode.ProgressLocation.Notification, location: vscode.ProgressLocation.Notification,
title: t('progress.download-digital-lsp') title: t('info.progress.download-digital-lsp')
}, async (progress: vscode.Progress<IProgress>, token: vscode.CancellationToken) => { }, async (progress: vscode.Progress<IProgress>, token: vscode.CancellationToken) => {
progress.report({ increment: 0 }); progress.report({ increment: 0 });
const response = await axios.get(downloadLink, { responseType: 'stream' }); const response = await axios.get(downloadLink, { responseType: 'stream' });
@ -128,13 +128,13 @@ export async function downloadLsp(context: vscode.ExtensionContext, version: str
await vscode.window.withProgress({ await vscode.window.withProgress({
location: vscode.ProgressLocation.Notification, location: vscode.ProgressLocation.Notification,
title: t('progress.extract-digital-lsp') title: t('info.progress.extract-digital-lsp')
}, async (progress: vscode.Progress<IProgress>, token: vscode.CancellationToken) => { }, async (progress: vscode.Progress<IProgress>, token: vscode.CancellationToken) => {
if (fs.existsSync(tarGzFilePath)) { if (fs.existsSync(tarGzFilePath)) {
console.log('check finish, begin to extract'); console.log('check finish, begin to extract');
await extractTarGz(tarGzFilePath, versionFolderPath); await extractTarGz(tarGzFilePath, versionFolderPath);
} else { } else {
vscode.window.showErrorMessage(t('error.download-digital-lsp') + version); vscode.window.showErrorMessage(t('error.lsp.download-digital-lsp') + version);
} }
}); });

View File

@ -98,7 +98,7 @@ async function askUserToSaveFilelist(filelist: string[]) {
fs.writeFileSync(filePath, fileContent); fs.writeFileSync(filePath, fileContent);
} catch (error) { } catch (error) {
vscode.window.showErrorMessage(t('error.save-file') + ': ' + error); vscode.window.showErrorMessage(t('error.filelist.save-file') + ': ' + error);
} }
} }

View File

@ -252,7 +252,7 @@ class HdlParam {
const pools: { id: number, promise: Promise<void>, path: string }[] = []; const pools: { id: number, promise: Promise<void>, path: string }[] = [];
const reportTitle = t('progress.build-module-tree'); const reportTitle = t('info.progress.build-module-tree');
progress?.report({ message: reportTitle + ` ${1}/${fileNum}`, increment: 0 }); progress?.report({ message: reportTitle + ` ${1}/${fileNum}`, increment: 0 });

View File

@ -281,15 +281,16 @@ class PpyAction extends BaseAction {
public async refreshHdlMonitor(m: HdlMonitor, originalHdlFiles: AbsPath[]) { public async refreshHdlMonitor(m: HdlMonitor, originalHdlFiles: AbsPath[]) {
m.remakeHdlMonitor(); m.remakeHdlMonitor();
const { t } = vscode.l10n;
const newFiles = await prjManage.getPrjHardwareFiles(); const newFiles = await prjManage.getPrjHardwareFiles();
const { addFiles, delFiles } = this.diffNewOld(newFiles, originalHdlFiles); const { addFiles, delFiles } = this.diffNewOld(newFiles, originalHdlFiles);
const options: vscode.ProgressOptions = { location: vscode.ProgressLocation.Notification }; const options: vscode.ProgressOptions = { location: vscode.ProgressLocation.Notification };
options.title = 'update HdlParam'; options.title = t('info.monitor.update-hdlparam');
await vscode.window.withProgress(options, async () => await this.updateHdlParam(addFiles, delFiles)); await vscode.window.withProgress(options, async () => await this.updateHdlParam(addFiles, delFiles));
if (opeParam.prjInfo.toolChain === ToolChainType.Xilinx) { if (opeParam.prjInfo.toolChain === ToolChainType.Xilinx) {
options.title = 'update PL'; options.title = t('info.monitor.update-pl');
await vscode.window.withProgress(options, async () => await this.updatePL(addFiles, delFiles)); await vscode.window.withProgress(options, async () => await this.updatePL(addFiles, delFiles));
} }
} }