Родитель
5eea3ef5af
Коммит
2a19e9c0cb
|
@ -215,7 +215,6 @@ const generatedSrcLocBundle = () => {
|
|||
|
||||
const generateLocalizedJsonSchemaFiles = () => {
|
||||
return es.through(function (file) {
|
||||
console.log(file.path);
|
||||
let jsonTree = JSON.parse(file.contents.toString());
|
||||
languages.map((language) => {
|
||||
let stringTable = {};
|
||||
|
@ -228,6 +227,7 @@ const generateLocalizedJsonSchemaFiles = () => {
|
|||
// Entire file is scanned and modified, then serialized for that language.
|
||||
// Even if no translations are available, we still write new files to dist/schema/...
|
||||
let keyPrefix = relativePath + ".";
|
||||
keyPrefix = keyPrefix.replace(/\\/g, "/");
|
||||
let descriptionCallback = (path, value, parent) => {
|
||||
if (stringTable[keyPrefix + path]) {
|
||||
parent.description = stringTable[keyPrefix + path];
|
||||
|
|
|
@ -1019,21 +1019,21 @@
|
|||
"yamlValidation": [
|
||||
{
|
||||
"fileMatch": "cmake-variants.yaml",
|
||||
"url": "cmake-tools-schema://schemas/variants-schema.json"
|
||||
"url": "cmake-tools-schema:///schemas/variants-schema.json"
|
||||
}
|
||||
],
|
||||
"jsonValidation": [
|
||||
{
|
||||
"fileMatch": "cmake-variants.json",
|
||||
"url": "cmake-tools-schema://schemas/variants-schema.json"
|
||||
"url": "cmake-tools-schema:///schemas/variants-schema.json"
|
||||
},
|
||||
{
|
||||
"fileMatch": "cmake-variants.yaml",
|
||||
"url": "cmake-tools-schema://schemas/variants-schema.json"
|
||||
"url": "cmake-tools-schema:///schemas/variants-schema.json"
|
||||
},
|
||||
{
|
||||
"fileMatch": "cmake-kits.json",
|
||||
"url": "cmake-tools-schema://schemas/kits-schema.json"
|
||||
"url": "cmake-tools-schema:///schemas/kits-schema.json"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -1303,14 +1303,15 @@ async function setup(context: vscode.ExtensionContext, progress: ProgressHandle)
|
|||
|
||||
class SchemaProvider implements vscode.TextDocumentContentProvider {
|
||||
public async provideTextDocumentContent(uri: vscode.Uri): Promise<string> {
|
||||
const fileName: string = uri.authority;
|
||||
const fileName: string = uri.fsPath;
|
||||
const locale: string = util.getLocaleId();
|
||||
let localizedFilePath: string = path.join(util.thisExtensionPath(), "dist/schema/", locale, fileName);
|
||||
const stat = await fs.stat(localizedFilePath);
|
||||
if (!stat || !stat.isFile) {
|
||||
localizedFilePath = path.join(util.thisExtensionPath(), fileName);
|
||||
}
|
||||
return fs.readFile(localizedFilePath, "utf8");
|
||||
return util.checkFileExists(localizedFilePath).then(fileExists => {
|
||||
if (!fileExists) {
|
||||
localizedFilePath = path.join(util.thisExtensionPath(), fileName);
|
||||
}
|
||||
return fs.readFile(localizedFilePath, "utf8");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
13
src/util.ts
13
src/util.ts
|
@ -1,6 +1,7 @@
|
|||
import * as child_process from 'child_process';
|
||||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
import * as fs from 'fs';
|
||||
|
||||
import {EnvironmentVariables, execute} from './proc';
|
||||
import * as nls from 'vscode-nls';
|
||||
|
@ -531,3 +532,15 @@ export function getLocaleId(): string {
|
|||
}
|
||||
return "en";
|
||||
}
|
||||
|
||||
export function checkFileExists(filePath: string): Promise<boolean> {
|
||||
return new Promise((resolve, _reject) => {
|
||||
fs.stat(filePath, (_err, stats) => {
|
||||
if (stats && stats.isFile()) {
|
||||
resolve(true);
|
||||
} else {
|
||||
resolve(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
Загрузка…
Ссылка в новой задаче