解决多语言中默认语言无法生效的问题
This commit is contained in:
parent
577fd02b31
commit
f1b79b92d3
@ -635,4 +635,29 @@ img {
|
|||||||
|
|
||||||
.icon-parameter:before {
|
.icon-parameter:before {
|
||||||
font-weight: 1000;
|
font-weight: 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
#write .source-lib-tag {
|
||||||
|
font-size: 0.85rem;
|
||||||
|
padding: 3px 4px;
|
||||||
|
border-radius: .5em;
|
||||||
|
background-color: rgb(35,102,93);
|
||||||
|
}
|
||||||
|
|
||||||
|
#write .source-prj-tag {
|
||||||
|
font-size: 0.85rem;
|
||||||
|
padding: 3px 4px;
|
||||||
|
border-radius: .5em;
|
||||||
|
background-color: rgb(53,59,140);
|
||||||
|
}
|
||||||
|
|
||||||
|
#write .source-unk-tag {
|
||||||
|
font-size: 0.85rem;
|
||||||
|
padding: 3px 4px;
|
||||||
|
border-radius: .5em;
|
||||||
|
background-color: #a09c9c;
|
||||||
|
}
|
||||||
|
|
||||||
|
#write table, th, td {
|
||||||
|
border: 1px solid var(--vscode-foreground) !important;
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
@font-face {
|
@font-face {
|
||||||
font-family: "iconfont"; /* Project id 4748764 */
|
font-family: "iconfont"; /* Project id 4748764 */
|
||||||
src: url('iconfont.woff2?t=1731847061847') format('woff2'),
|
src: url('iconfont.woff2?t=1731914985969') format('woff2'),
|
||||||
url('iconfont.woff?t=1731847061847') format('woff'),
|
url('iconfont.woff?t=1731914985969') format('woff'),
|
||||||
url('iconfont.ttf?t=1731847061847') format('truetype');
|
url('iconfont.ttf?t=1731914985969') format('truetype');
|
||||||
}
|
}
|
||||||
|
|
||||||
.iconfont {
|
.iconfont {
|
||||||
@ -13,6 +13,10 @@
|
|||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.icon-tree:before {
|
||||||
|
content: "\e601";
|
||||||
|
}
|
||||||
|
|
||||||
.icon-verilog:before {
|
.icon-verilog:before {
|
||||||
content: "\e634";
|
content: "\e634";
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
@ -9,6 +9,8 @@ import { hdlMonitor } from './monitor';
|
|||||||
|
|
||||||
import * as lspClient from './function/lsp-client';
|
import * as lspClient from './function/lsp-client';
|
||||||
import { refreshArchTree } from './function/treeView';
|
import { refreshArchTree } from './function/treeView';
|
||||||
|
import { hdlFile } from './hdlFs';
|
||||||
|
import { initialiseI18n, t } from './i18n';
|
||||||
|
|
||||||
|
|
||||||
async function registerCommand(context: vscode.ExtensionContext, packageJson: any) {
|
async function registerCommand(context: vscode.ExtensionContext, packageJson: any) {
|
||||||
@ -34,7 +36,8 @@ function readPackageJson(context: vscode.ExtensionContext): any | undefined {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function launch(context: vscode.ExtensionContext) {
|
async function launch(context: vscode.ExtensionContext) {
|
||||||
const { t } = vscode.l10n;
|
initialiseI18n(context);
|
||||||
|
|
||||||
console.log(t('info.welcome.title'));
|
console.log(t('info.welcome.title'));
|
||||||
console.log(t('info.welcome.join-qq-group') + ' https://qm.qq.com/q/1M655h3GsA');
|
console.log(t('info.welcome.join-qq-group') + ' https://qm.qq.com/q/1M655h3GsA');
|
||||||
const packageJson = readPackageJson(context);
|
const packageJson = readPackageJson(context);
|
||||||
|
@ -5,6 +5,7 @@ import { BSON } from 'bson';
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
import { getIconConfig } from '../../hdlFs/icons';
|
import { getIconConfig } from '../../hdlFs/icons';
|
||||||
|
import { t } from '../../i18n';
|
||||||
|
|
||||||
export interface SaveViewData {
|
export interface SaveViewData {
|
||||||
originVcdFile: string,
|
originVcdFile: string,
|
||||||
@ -80,9 +81,6 @@ 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;
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 先保存原来的文件 payload 一定是 all
|
// 先保存原来的文件 payload 一定是 all
|
||||||
let { originVcdFile, originVcdViewFile, payload } = data;
|
let { originVcdFile, originVcdViewFile, payload } = data;
|
||||||
@ -101,7 +99,6 @@ export async function saveViewAs(data: any, uri: vscode.Uri, panel: vscode.Webvi
|
|||||||
const vcdFilters: Record<string, string[]> = {};
|
const vcdFilters: Record<string, string[]> = {};
|
||||||
vcdFilters[t('info.vcd-viewer.vcd-view-file')] = ['view'];
|
vcdFilters[t('info.vcd-viewer.vcd-view-file')] = ['view'];
|
||||||
vcdFilters[t('info.vcd-viewer.all-file')] = ['*'];
|
vcdFilters[t('info.vcd-viewer.all-file')] = ['*'];
|
||||||
|
|
||||||
const saveUri = await vscode.window.showSaveDialog({
|
const saveUri = await vscode.window.showSaveDialog({
|
||||||
title: t('info.vcd-viewer.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)),
|
||||||
@ -137,7 +134,6 @@ export async function saveViewAs(data: any, uri: vscode.Uri, panel: vscode.Webvi
|
|||||||
|
|
||||||
|
|
||||||
export async function loadView(data: any, uri: vscode.Uri, panel: vscode.WebviewPanel) {
|
export async function loadView(data: any, uri: vscode.Uri, panel: vscode.WebviewPanel) {
|
||||||
const { t } = vscode.l10n;
|
|
||||||
try {
|
try {
|
||||||
let { originVcdFile } = data;
|
let { originVcdFile } = data;
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import { opeParam, ReportType, WaveViewOutput } from '../../global';
|
|||||||
import { LaunchFiles, loadView, saveView, saveViewAs } from './api';
|
import { LaunchFiles, loadView, saveView, saveViewAs } from './api';
|
||||||
import { BSON } from 'bson';
|
import { BSON } from 'bson';
|
||||||
import { getIconConfig } from '../../hdlFs/icons';
|
import { getIconConfig } from '../../hdlFs/icons';
|
||||||
|
import { t } from '../../i18n';
|
||||||
|
|
||||||
function getWebviewContent(context: vscode.ExtensionContext, panel?: vscode.WebviewPanel): string | undefined {
|
function getWebviewContent(context: vscode.ExtensionContext, panel?: vscode.WebviewPanel): string | undefined {
|
||||||
const dideviewerPath = hdlPath.join(context.extensionPath, 'resources', 'dide-viewer', 'view');
|
const dideviewerPath = hdlPath.join(context.extensionPath, 'resources', 'dide-viewer', 'view');
|
||||||
@ -202,7 +203,6 @@ function registerMessageEvent(panel: vscode.WebviewPanel, uri: vscode.Uri) {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function getViewLaunchFiles(context: vscode.ExtensionContext, uri: vscode.Uri, panel: vscode.WebviewPanel): LaunchFiles | Error {
|
function getViewLaunchFiles(context: vscode.ExtensionContext, uri: vscode.Uri, panel: vscode.WebviewPanel): LaunchFiles | Error {
|
||||||
const { t } = vscode.l10n;
|
|
||||||
const entryPath = uri.fsPath;
|
const entryPath = uri.fsPath;
|
||||||
const dideviewerPath = hdlPath.join(context.extensionPath, 'resources', 'dide-viewer', 'view');
|
const dideviewerPath = hdlPath.join(context.extensionPath, 'resources', 'dide-viewer', 'view');
|
||||||
const workerAbsPath = hdlPath.join(dideviewerPath, 'worker.js');
|
const workerAbsPath = hdlPath.join(dideviewerPath, 'worker.js');
|
||||||
|
@ -14,6 +14,7 @@ import { getSymbolComments } from '../lsp/util/feature';
|
|||||||
import { HdlLangID, ThemeType } from '../../global/enum';
|
import { HdlLangID, ThemeType } from '../../global/enum';
|
||||||
import { makeDiagram } from './diagram';
|
import { makeDiagram } from './diagram';
|
||||||
import { defaultMacro, doFastApi } from '../../hdlParser/util';
|
import { defaultMacro, doFastApi } from '../../hdlParser/util';
|
||||||
|
import { t } from '../../i18n';
|
||||||
|
|
||||||
|
|
||||||
function makeSVGElementByLink(link: AbsPath, caption?: string) {
|
function makeSVGElementByLink(link: AbsPath, caption?: string) {
|
||||||
@ -45,12 +46,12 @@ function selectFieldValue(obj: any, subName: string, ws: string, name: string, i
|
|||||||
if (hdlFile && hdlFile.type === 'remote_lib') {
|
if (hdlFile && hdlFile.type === 'remote_lib') {
|
||||||
// 如果是 库 文件,做出更加自定义的字面量
|
// 如果是 库 文件,做出更加自定义的字面量
|
||||||
const libRelPath = value.replace(`${opeParam.extensionPath}/library/`, '');
|
const libRelPath = value.replace(`${opeParam.extensionPath}/library/`, '');
|
||||||
value = `(library) [${libRelPath}](file://${value})`;
|
value = `<span class="source-lib-tag">library</span> [${libRelPath}](file://${value})`;
|
||||||
} else {
|
} else {
|
||||||
value = `(project) [${relativePath}](file://${value})`;
|
value = `<span class="source-prj-tag">project</span> [${relativePath}](file://${value})`;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
value = '(unknown) ' + vscode.l10n.t('info.dide-doc.source.cannot-find');
|
value = '<span class="source-unk-tag">unknown</span> ' + t('info.dide-doc.source.cannot-find');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,8 +124,6 @@ async function patchComment(path: AbsPath, ports: (HdlModulePort | HdlModulePara
|
|||||||
* @param module
|
* @param module
|
||||||
*/
|
*/
|
||||||
async function getDocsFromModule(module: HdlModule): Promise<MarkdownString> {
|
async function getDocsFromModule(module: HdlModule): Promise<MarkdownString> {
|
||||||
const { t } = vscode.l10n;
|
|
||||||
|
|
||||||
const moduleName = module.name;
|
const moduleName = module.name;
|
||||||
const portNum = module.ports.length;
|
const portNum = module.ports.length;
|
||||||
const paramNum = module.params.length;
|
const paramNum = module.params.length;
|
||||||
@ -182,7 +181,8 @@ async function getDocsFromModule(module: HdlModule): Promise<MarkdownString> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// param section
|
// param section
|
||||||
md.addTitle(t('info.dide-doc.parameters'), 2);
|
const paramTitleIcon = '<span class="iconfont icon-parameter"></span> ';
|
||||||
|
md.addTitle(paramTitleIcon + t('info.dide-doc.parameters'), 2);
|
||||||
if (module.params.length > 0) {
|
if (module.params.length > 0) {
|
||||||
makeTableFromObjArray(md, module.params, 'params',
|
makeTableFromObjArray(md, module.params, 'params',
|
||||||
['name', 'init', 'empty', 'desc'],
|
['name', 'init', 'empty', 'desc'],
|
||||||
@ -203,7 +203,8 @@ async function getDocsFromModule(module: HdlModule): Promise<MarkdownString> {
|
|||||||
|
|
||||||
|
|
||||||
// port section
|
// port section
|
||||||
md.addTitle(t('info.dide-doc.ports'), 2);
|
const portTitleIcon = '<span class="iconfont icon-port"></span> ';
|
||||||
|
md.addTitle(portTitleIcon + t('info.dide-doc.ports'), 2);
|
||||||
if (module.ports.length > 0) {
|
if (module.ports.length > 0) {
|
||||||
makeTableFromObjArray(md, module.ports, 'ports',
|
makeTableFromObjArray(md, module.ports, 'ports',
|
||||||
['name', 'type', 'width', 'desc'],
|
['name', 'type', 'width', 'desc'],
|
||||||
@ -223,7 +224,8 @@ async function getDocsFromModule(module: HdlModule): Promise<MarkdownString> {
|
|||||||
md.addEnter();
|
md.addEnter();
|
||||||
|
|
||||||
// dependency section
|
// dependency section
|
||||||
md.addTitle(t('info.dide-doc.dependency'), 2);
|
const depTitleIcon = '<span class="iconfont icon-tree"></span> ';
|
||||||
|
md.addTitle(depTitleIcon + t('info.dide-doc.dependency'), 2);
|
||||||
|
|
||||||
let insts = module.getAllInstances();
|
let insts = module.getAllInstances();
|
||||||
// 对于单文件模式而言,未进行 instance 搜索,所以insts必然是空的
|
// 对于单文件模式而言,未进行 instance 搜索,所以insts必然是空的
|
||||||
@ -269,8 +271,6 @@ async function getDocsFromModule(module: HdlModule): Promise<MarkdownString> {
|
|||||||
* @param path absolute path of the file
|
* @param path absolute path of the file
|
||||||
*/
|
*/
|
||||||
async function getDocsFromFile(path: AbsPath): Promise<MarkdownString[] | undefined> {
|
async function getDocsFromFile(path: AbsPath): Promise<MarkdownString[] | undefined> {
|
||||||
const { t } = vscode.l10n;
|
|
||||||
|
|
||||||
let moduleFile = hdlParam.getHdlFile(path);
|
let moduleFile = hdlParam.getHdlFile(path);
|
||||||
// 没有说明是单文件模式,直接打开解析
|
// 没有说明是单文件模式,直接打开解析
|
||||||
if (!moduleFile) {
|
if (!moduleFile) {
|
||||||
|
@ -22,6 +22,7 @@ import { hdlPath } from '../hdlFs';
|
|||||||
import { LspClient, opeParam } from '../global';
|
import { LspClient, opeParam } from '../global';
|
||||||
import { DoFastToolChainType, SyncFastRequestType } from '../global/lsp';
|
import { DoFastToolChainType, SyncFastRequestType } from '../global/lsp';
|
||||||
import { makeDocBody } from './hdlDoc/html';
|
import { makeDocBody } from './hdlDoc/html';
|
||||||
|
import { State } from 'vscode-languageclient';
|
||||||
|
|
||||||
function registerDocumentation(context: vscode.ExtensionContext) {
|
function registerDocumentation(context: vscode.ExtensionContext) {
|
||||||
vscode.commands.registerCommand('digital-ide.hdlDoc.showWebview', async (uri: vscode.Uri) => {
|
vscode.commands.registerCommand('digital-ide.hdlDoc.showWebview', async (uri: vscode.Uri) => {
|
||||||
@ -35,7 +36,7 @@ function registerDocumentation(context: vscode.ExtensionContext) {
|
|||||||
// TODO: 注册文件变动监听
|
// TODO: 注册文件变动监听
|
||||||
const fileChangeDisposer = vscode.window.onDidChangeActiveTextEditor(async event => {
|
const fileChangeDisposer = vscode.window.onDidChangeActiveTextEditor(async event => {
|
||||||
// const client = LspClient.DigitalIDE;
|
// const client = LspClient.DigitalIDE;
|
||||||
// if (client && event?.document) {
|
// if (client && event?.document && client.state === State.Running && event.document.uri.path === uri.path) {
|
||||||
// const path = hdlPath.toSlash(event.document.fileName);
|
// const path = hdlPath.toSlash(event.document.fileName);
|
||||||
// const fileType = 'common';
|
// const fileType = 'common';
|
||||||
// const toolChain = opeParam.prjInfo.toolChain as DoFastToolChainType;
|
// const toolChain = opeParam.prjInfo.toolChain as DoFastToolChainType;
|
||||||
|
@ -16,6 +16,7 @@ import axios, { AxiosResponse } from "axios";
|
|||||||
import { chooseBestDownloadSource, getGiteeDownloadLink, getGithubDownloadLink, getPlatformPlatformSignature } from "./cdn";
|
import { chooseBestDownloadSource, getGiteeDownloadLink, getGithubDownloadLink, getPlatformPlatformSignature } from "./cdn";
|
||||||
import { hdlDir, hdlPath } from "../../hdlFs";
|
import { hdlDir, hdlPath } from "../../hdlFs";
|
||||||
import { registerConfigurationUpdater } from "./config";
|
import { registerConfigurationUpdater } from "./config";
|
||||||
|
import { t } from "../../i18n";
|
||||||
|
|
||||||
function getLspServerExecutionName() {
|
function getLspServerExecutionName() {
|
||||||
const osname = platform();
|
const osname = platform();
|
||||||
@ -98,8 +99,6 @@ async function checkAndDownload(context: vscode.ExtensionContext, version: strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function downloadLsp(context: vscode.ExtensionContext, version: string, versionFolderPath: string): Promise<boolean> {
|
export async function downloadLsp(context: vscode.ExtensionContext, version: string, versionFolderPath: string): Promise<boolean> {
|
||||||
const { t } = vscode.l10n;
|
|
||||||
|
|
||||||
const downloadLink = await vscode.window.withProgress({
|
const downloadLink = await vscode.window.withProgress({
|
||||||
location: vscode.ProgressLocation.Notification,
|
location: vscode.ProgressLocation.Notification,
|
||||||
title: t('info.progress.choose-best-download-source')
|
title: t('info.progress.choose-best-download-source')
|
||||||
|
@ -7,6 +7,7 @@ import { hdlParam } from '../../hdlParser';
|
|||||||
import { hdlFile, hdlPath } from '../../hdlFs';
|
import { hdlFile, hdlPath } from '../../hdlFs';
|
||||||
import { defaultMacro, doFastApi } from '../../hdlParser/util';
|
import { defaultMacro, doFastApi } from '../../hdlParser/util';
|
||||||
import { HdlFile } from '../../hdlParser/core';
|
import { HdlFile } from '../../hdlParser/core';
|
||||||
|
import { t } from '../../i18n';
|
||||||
|
|
||||||
|
|
||||||
class Netlist {
|
class Netlist {
|
||||||
@ -19,7 +20,6 @@ class Netlist {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async open(uri: vscode.Uri) {
|
public async open(uri: vscode.Uri) {
|
||||||
const { t } = vscode.l10n;
|
|
||||||
|
|
||||||
// get dependence of the current uri
|
// get dependence of the current uri
|
||||||
const prjFiles = [];
|
const prjFiles = [];
|
||||||
|
@ -4,6 +4,7 @@ import { hdlParam } from '../../hdlParser';
|
|||||||
import { HdlModulePort, HdlModuleParam, HdlModulePortType } from '../../hdlParser/common';
|
import { HdlModulePort, HdlModuleParam, HdlModulePortType } from '../../hdlParser/common';
|
||||||
import { HdlModule } from '../../hdlParser/core';
|
import { HdlModule } from '../../hdlParser/core';
|
||||||
import { hdlFile, hdlPath } from '../../hdlFs';
|
import { hdlFile, hdlPath } from '../../hdlFs';
|
||||||
|
import { t } from '../../i18n';
|
||||||
|
|
||||||
class ModuleInfoItem {
|
class ModuleInfoItem {
|
||||||
label: string;
|
label: string;
|
||||||
@ -275,7 +276,6 @@ function getSelectItem(modules: HdlModule[]) {
|
|||||||
* @description 调用vscode的窗体,让用户从所有的Module中选择模块(为后续的例化准备)
|
* @description 调用vscode的窗体,让用户从所有的Module中选择模块(为后续的例化准备)
|
||||||
*/
|
*/
|
||||||
async function selectModuleFromAll() {
|
async function selectModuleFromAll() {
|
||||||
const { t } = vscode.l10n;
|
|
||||||
const option = {
|
const option = {
|
||||||
placeHolder: t('info.command.instantiation.pick-title')
|
placeHolder: t('info.command.instantiation.pick-title')
|
||||||
};
|
};
|
||||||
|
@ -7,6 +7,7 @@ import { opeParam } from '../global';
|
|||||||
import { hdlFile, hdlPath } from '../hdlFs';
|
import { hdlFile, hdlPath } from '../hdlFs';
|
||||||
import { ModuleDataItem } from './treeView/tree';
|
import { ModuleDataItem } from './treeView/tree';
|
||||||
import { hdlParam } from '../hdlParser';
|
import { hdlParam } from '../hdlParser';
|
||||||
|
import { t } from '../i18n';
|
||||||
|
|
||||||
async function insertTextToUri(uri: vscode.Uri, text: string, position?: vscode.Position) {
|
async function insertTextToUri(uri: vscode.Uri, text: string, position?: vscode.Position) {
|
||||||
if (!position) {
|
if (!position) {
|
||||||
@ -47,7 +48,6 @@ const PPY_LIB_REPLACE: Record<string, string> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
async function transformOldPpy() {
|
async function transformOldPpy() {
|
||||||
const { t } = vscode.l10n;
|
|
||||||
const propertyJsonPath = opeParam.propertyJsonPath;
|
const propertyJsonPath = opeParam.propertyJsonPath;
|
||||||
if (fs.existsSync(propertyJsonPath)) {
|
if (fs.existsSync(propertyJsonPath)) {
|
||||||
const oldPpyContent = hdlFile.readJSON(propertyJsonPath) as Record<any, any>;
|
const oldPpyContent = hdlFile.readJSON(propertyJsonPath) as Record<any, any>;
|
||||||
@ -117,7 +117,6 @@ async function transformOldPpy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function askUserToSaveFilelist(filelist: string[]) {
|
async function askUserToSaveFilelist(filelist: string[]) {
|
||||||
const { t } = vscode.l10n;
|
|
||||||
|
|
||||||
const topModulePath = filelist[0];
|
const topModulePath = filelist[0];
|
||||||
const defaultSaveName = fspath.basename(topModulePath, fspath.extname(topModulePath));
|
const defaultSaveName = fspath.basename(topModulePath, fspath.extname(topModulePath));
|
||||||
|
@ -7,6 +7,7 @@ import { hardwareTreeProvider, softwareTreeProvider, toolTreeProvider } from './
|
|||||||
import { moduleTreeProvider, ModuleDataItem } from './tree';
|
import { moduleTreeProvider, ModuleDataItem } from './tree';
|
||||||
import { Range } from '../../hdlParser/common';
|
import { Range } from '../../hdlParser/common';
|
||||||
import { MainOutput, opeParam, ReportType } from '../../global';
|
import { MainOutput, opeParam, ReportType } from '../../global';
|
||||||
|
import { t } from '../../i18n';
|
||||||
|
|
||||||
|
|
||||||
async function openFileAtPosition(uri: vscode.Uri, range?: Range) {
|
async function openFileAtPosition(uri: vscode.Uri, range?: Range) {
|
||||||
@ -16,7 +17,7 @@ async function openFileAtPosition(uri: vscode.Uri, range?: Range) {
|
|||||||
end: { line: 0, character: 0 }
|
end: { line: 0, character: 0 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const document = await vscode.workspace.openTextDocument(uri);
|
const document = await vscode.workspace.openTextDocument(uri);
|
||||||
const start = new vscode.Position(range.start.line, range.start.character);
|
const start = new vscode.Position(range.start.line, range.start.character);
|
||||||
const end = new vscode.Position(range.end.line, range.end.character);
|
const end = new vscode.Position(range.end.line, range.end.character);
|
||||||
|
|
||||||
@ -29,7 +30,6 @@ async function openFileAtPosition(uri: vscode.Uri, range?: Range) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function openFileByUri(path: string, range: Range, element: ModuleDataItem) {
|
function openFileByUri(path: string, range: Range, element: ModuleDataItem) {
|
||||||
const { t } = vscode.l10n;
|
|
||||||
if (range === undefined) {
|
if (range === undefined) {
|
||||||
// vscode.window.showErrorMessage(`${path} not support jump yet`);
|
// vscode.window.showErrorMessage(`${path} not support jump yet`);
|
||||||
return;
|
return;
|
||||||
@ -53,7 +53,6 @@ function openFileByUri(path: string, range: Range, element: ModuleDataItem) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function gotoXilinxIPDefinition(element: ModuleDataItem) {
|
function gotoXilinxIPDefinition(element: ModuleDataItem) {
|
||||||
const { t } = vscode.l10n;
|
|
||||||
const folderPath = element.path;
|
const folderPath = element.path;
|
||||||
if (folderPath) {
|
if (folderPath) {
|
||||||
const ipName = fspath.basename(folderPath);
|
const ipName = fspath.basename(folderPath);
|
||||||
|
@ -8,6 +8,7 @@ import { hdlFile, hdlPath } from '../../hdlFs';
|
|||||||
import { xilinx, itemModes, otherModes } from './common';
|
import { xilinx, itemModes, otherModes } from './common';
|
||||||
import { getIconConfig } from '../../hdlFs/icons';
|
import { getIconConfig } from '../../hdlFs/icons';
|
||||||
import { DoFastFileType } from '../../global/lsp';
|
import { DoFastFileType } from '../../global/lsp';
|
||||||
|
import { t } from '../../i18n';
|
||||||
|
|
||||||
let needExpand = true;
|
let needExpand = true;
|
||||||
|
|
||||||
@ -109,12 +110,10 @@ class ModuleTreeProvider implements vscode.TreeDataProvider<ModuleDataItem> {
|
|||||||
|
|
||||||
|
|
||||||
public getTreeItem(element: ModuleDataItem): vscode.TreeItem | Thenable<vscode.TreeItem> {
|
public getTreeItem(element: ModuleDataItem): vscode.TreeItem | Thenable<vscode.TreeItem> {
|
||||||
const { t } = vscode.l10n;
|
|
||||||
let itemName = element.name;
|
let itemName = element.name;
|
||||||
if (itemModes.has(element.icon)) {
|
if (itemModes.has(element.icon)) {
|
||||||
itemName = `${element.type}(${itemName})`;
|
itemName = `${element.type}(${itemName})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const expandable = canExpandable(element);
|
const expandable = canExpandable(element);
|
||||||
let collapsibleState;
|
let collapsibleState;
|
||||||
if (!expandable) {
|
if (!expandable) {
|
||||||
|
@ -11,6 +11,7 @@ import assert = require('assert');
|
|||||||
import * as hdlPath from '../hdlFs/path';
|
import * as hdlPath from '../hdlFs/path';
|
||||||
import { hdlDir } from '../hdlFs';
|
import { hdlDir } from '../hdlFs';
|
||||||
import { MainOutput } from './outputChannel';
|
import { MainOutput } from './outputChannel';
|
||||||
|
import { t } from '../i18n';
|
||||||
|
|
||||||
|
|
||||||
type AbsPath = string;
|
type AbsPath = string;
|
||||||
@ -400,7 +401,6 @@ class PrjInfo implements PrjInfoMeta {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public updateArch(arch?: Arch) {
|
public updateArch(arch?: Arch) {
|
||||||
const { t } = vscode.l10n;
|
|
||||||
const workspacePath = this._workspacePath;
|
const workspacePath = this._workspacePath;
|
||||||
if (arch) {
|
if (arch) {
|
||||||
// 如果配置中存在,直接根据用户配置的项来赋值
|
// 如果配置中存在,直接根据用户配置的项来赋值
|
||||||
|
@ -9,6 +9,7 @@ import * as common from './common';
|
|||||||
import { hdlFile, hdlPath } from '../hdlFs';
|
import { hdlFile, hdlPath } from '../hdlFs';
|
||||||
import { defaultMacro, defaultRange, doPrimitivesJudgeApi, HdlSymbol } from './util';
|
import { defaultMacro, defaultRange, doPrimitivesJudgeApi, HdlSymbol } from './util';
|
||||||
import { DoFastFileType } from '../global/lsp';
|
import { DoFastFileType } from '../global/lsp';
|
||||||
|
import { t } from '../i18n';
|
||||||
|
|
||||||
|
|
||||||
class HdlParam {
|
class HdlParam {
|
||||||
@ -253,10 +254,8 @@ class HdlParam {
|
|||||||
|
|
||||||
|
|
||||||
public async initializeHdlFiles(hdlFiles: AbsPath[], progress: vscode.Progress<IProgress>) {
|
public async initializeHdlFiles(hdlFiles: AbsPath[], progress: vscode.Progress<IProgress>) {
|
||||||
const { t } = vscode.l10n;
|
|
||||||
let count: number = 0;
|
let count: number = 0;
|
||||||
let fileNum = hdlFiles.length;
|
let fileNum = hdlFiles.length;
|
||||||
|
|
||||||
const parallelChunk = Math.min(os.cpus().length, 32);
|
const parallelChunk = Math.min(os.cpus().length, 32);
|
||||||
console.log("use cpu: " + parallelChunk);
|
console.log("use cpu: " + parallelChunk);
|
||||||
|
|
||||||
@ -290,7 +289,6 @@ class HdlParam {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async initializeIPsPath(IPsPath: string[], progress: vscode.Progress<IProgress>) {
|
public async initializeIPsPath(IPsPath: string[], progress: vscode.Progress<IProgress>) {
|
||||||
const { t } = vscode.l10n;
|
|
||||||
let count: number = 0;
|
let count: number = 0;
|
||||||
let fileNum = IPsPath.length;
|
let fileNum = IPsPath.length;
|
||||||
|
|
||||||
|
24
src/i18n/index.ts
Normal file
24
src/i18n/index.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import * as vscode from 'vscode';
|
||||||
|
import { hdlFile } from '../hdlFs';
|
||||||
|
|
||||||
|
const defaultBundle: Record<string, string> = {}
|
||||||
|
|
||||||
|
export function initialiseI18n(context: vscode.ExtensionContext) {
|
||||||
|
if (vscode.l10n.bundle === undefined) {
|
||||||
|
const bundlePath = context.asAbsolutePath('l10n/bundle.l10n.en.json');
|
||||||
|
const bundle = hdlFile.readJSON(bundlePath) as Record<string, string>;
|
||||||
|
Object.assign(defaultBundle, bundle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function t(message: string, ...args: string[]): string {
|
||||||
|
if (vscode.l10n.bundle === undefined) {
|
||||||
|
let translateMessage = defaultBundle[message] || message;
|
||||||
|
for (let i = 0; i < args.length; ++ i) {
|
||||||
|
translateMessage.replace(`{${i}}`, args[i]);
|
||||||
|
}
|
||||||
|
return translateMessage;
|
||||||
|
} else {
|
||||||
|
return vscode.l10n.t(message, ...args);
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,7 @@ import { moduleTreeProvider, ModuleDataItem } from '../../function/treeView/tree
|
|||||||
import { HdlFileType } from '../../hdlParser/common';
|
import { HdlFileType } from '../../hdlParser/common';
|
||||||
import { PropertySchema } from '../../global/propertySchema';
|
import { PropertySchema } from '../../global/propertySchema';
|
||||||
import { HardwareOutput, ReportType } from '../../global/outputChannel';
|
import { HardwareOutput, ReportType } from '../../global/outputChannel';
|
||||||
|
import { t } from '../../i18n';
|
||||||
|
|
||||||
class PlManage extends BaseManage {
|
class PlManage extends BaseManage {
|
||||||
context: PLContext;
|
context: PLContext;
|
||||||
@ -96,7 +97,6 @@ class PlManage extends BaseManage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public exit() {
|
public exit() {
|
||||||
const { t } = vscode.l10n;
|
|
||||||
|
|
||||||
if (this.context.process === undefined) {
|
if (this.context.process === undefined) {
|
||||||
return;
|
return;
|
||||||
|
@ -12,6 +12,7 @@ import { PropertySchema } from '../../global/propertySchema';
|
|||||||
import { XilinxIP } from '../../global/enum';
|
import { XilinxIP } from '../../global/enum';
|
||||||
import { HardwareOutput, MainOutput, ReportType } from '../../global/outputChannel';
|
import { HardwareOutput, MainOutput, ReportType } from '../../global/outputChannel';
|
||||||
import { debounce } from '../../global/util';
|
import { debounce } from '../../global/util';
|
||||||
|
import { t } from '../../i18n';
|
||||||
|
|
||||||
interface XilinxCustom {
|
interface XilinxCustom {
|
||||||
ipRepo: AbsPath,
|
ipRepo: AbsPath,
|
||||||
@ -139,8 +140,6 @@ class XilinxOperation {
|
|||||||
* @param context
|
* @param context
|
||||||
*/
|
*/
|
||||||
public async launch(context: PLContext): Promise<string | undefined> {
|
public async launch(context: PLContext): Promise<string | undefined> {
|
||||||
const { t } = vscode.l10n;
|
|
||||||
|
|
||||||
this.guiLaunched = false;
|
this.guiLaunched = false;
|
||||||
let scripts: string[] = [];
|
let scripts: string[] = [];
|
||||||
|
|
||||||
@ -244,7 +243,7 @@ class XilinxOperation {
|
|||||||
}
|
}
|
||||||
messageBuffer.push(line);
|
messageBuffer.push(line);
|
||||||
}
|
}
|
||||||
const launchInfo = vscode.l10n.t('info.pl.launch.launch-info');
|
const launchInfo = t('info.pl.launch.launch-info');
|
||||||
messageBuffer.unshift(launchInfo);
|
messageBuffer.unshift(launchInfo);
|
||||||
return messageBuffer.join("\n");
|
return messageBuffer.join("\n");
|
||||||
}
|
}
|
||||||
@ -582,8 +581,6 @@ file delete ${scriptPath} -force\n`;
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async gui(context: PLContext) {
|
public async gui(context: PLContext) {
|
||||||
const { t } = vscode.l10n;
|
|
||||||
|
|
||||||
if (context.process === undefined) {
|
if (context.process === undefined) {
|
||||||
await this.launch(context);
|
await this.launch(context);
|
||||||
}
|
}
|
||||||
@ -597,8 +594,6 @@ file delete ${scriptPath} -force\n`;
|
|||||||
}
|
}
|
||||||
|
|
||||||
public addFiles(files: string[], context: PLContext) {
|
public addFiles(files: string[], context: PLContext) {
|
||||||
const { t } = vscode.l10n;
|
|
||||||
|
|
||||||
if (!this.guiLaunched && files.length > 0) {
|
if (!this.guiLaunched && files.length > 0) {
|
||||||
const filesString = files.join("\n");
|
const filesString = files.join("\n");
|
||||||
HardwareOutput.report(t('info.pl.add-files.title') + '\n' + filesString);
|
HardwareOutput.report(t('info.pl.add-files.title') + '\n' + filesString);
|
||||||
@ -607,8 +602,6 @@ file delete ${scriptPath} -force\n`;
|
|||||||
}
|
}
|
||||||
|
|
||||||
public delFiles(files: string[], context: PLContext) {
|
public delFiles(files: string[], context: PLContext) {
|
||||||
const { t } = vscode.l10n;
|
|
||||||
|
|
||||||
if (!this.guiLaunched && files.length > 0) {
|
if (!this.guiLaunched && files.length > 0) {
|
||||||
const filesString = files.join("\n");
|
const filesString = files.join("\n");
|
||||||
HardwareOutput.report(t('info.pl.del-files.title') + '\n' + filesString);
|
HardwareOutput.report(t('info.pl.del-files.title') + '\n' + filesString);
|
||||||
|
@ -14,6 +14,7 @@ import { libManage } from '../manager/lib';
|
|||||||
import type { HdlMonitor } from './index';
|
import type { HdlMonitor } from './index';
|
||||||
import { HdlLangID, ToolChainType } from '../global/enum';
|
import { HdlLangID, ToolChainType } from '../global/enum';
|
||||||
import { vlogLinterManager, vhdlLinterManager, svlogLinterManager } from '../function/lsp/linter';
|
import { vlogLinterManager, vhdlLinterManager, svlogLinterManager } from '../function/lsp/linter';
|
||||||
|
import { t } from '../i18n';
|
||||||
|
|
||||||
enum Event {
|
enum Event {
|
||||||
Add = 'add', // emit when add file
|
Add = 'add', // emit when add file
|
||||||
@ -281,8 +282,6 @@ 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);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user