Update localization support in myTemplateGenerator extension. Added English and Russian settings for the configuration interface, modified default language to English, and removed unnecessary .vscode directory from .gitignore. Updated @types/vscode dependency version in package files. Added VSCode configuration files for better development experience.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -41,7 +41,6 @@ build/Release
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
.vscode/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
5
.vscode/extensions.json
vendored
Normal file
5
.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||
// for the documentation about the extensions.json format
|
||||
"recommendations": ["dbaeumer.vscode-eslint", "amodio.tsl-problem-matcher", "ms-vscode.extension-test-runner"]
|
||||
}
|
||||
21
.vscode/launch.json
vendored
Normal file
21
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
// A launch configuration that compiles the extension and then opens it inside a new window
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Run Extension",
|
||||
"type": "extensionHost",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"--extensionDevelopmentPath=${workspaceFolder}"
|
||||
],
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/dist/**/*.js"
|
||||
],
|
||||
"preLaunchTask": "${defaultBuildTask}"
|
||||
}
|
||||
]
|
||||
}
|
||||
13
.vscode/settings.json
vendored
Normal file
13
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
// Place your settings in this file to overwrite default and user settings.
|
||||
{
|
||||
"files.exclude": {
|
||||
"out": false, // set this to true to hide the "out" folder with the compiled JS files
|
||||
"dist": false // set this to true to hide the "dist" folder with the compiled JS files
|
||||
},
|
||||
"search.exclude": {
|
||||
"out": true, // set this to false to include "out" folder in search results
|
||||
"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"
|
||||
}
|
||||
40
.vscode/tasks.json
vendored
Normal file
40
.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "npm",
|
||||
"script": "watch",
|
||||
"problemMatcher": "$ts-webpack-watch",
|
||||
"isBackground": true,
|
||||
"presentation": {
|
||||
"reveal": "never",
|
||||
"group": "watchers"
|
||||
},
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "npm",
|
||||
"script": "watch-tests",
|
||||
"problemMatcher": "$tsc-watch",
|
||||
"isBackground": true,
|
||||
"presentation": {
|
||||
"reveal": "never",
|
||||
"group": "watchers"
|
||||
},
|
||||
"group": "build"
|
||||
},
|
||||
{
|
||||
"label": "tasks: watch-tests",
|
||||
"dependsOn": [
|
||||
"npm: watch",
|
||||
"npm: watch-tests"
|
||||
],
|
||||
"problemMatcher": []
|
||||
}
|
||||
]
|
||||
}
|
||||
8
package-lock.json
generated
8
package-lock.json
generated
@@ -13,7 +13,7 @@
|
||||
"devDependencies": {
|
||||
"@types/mocha": "^10.0.10",
|
||||
"@types/node": "20.x",
|
||||
"@types/vscode": "^1.102.0",
|
||||
"@types/vscode": "^1.60.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.31.1",
|
||||
"@typescript-eslint/parser": "^8.31.1",
|
||||
"@vscode/test-cli": "^0.0.11",
|
||||
@@ -485,9 +485,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@types/vscode": {
|
||||
"version": "1.102.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.102.0.tgz",
|
||||
"integrity": "sha512-V9sFXmcXz03FtYTSUsYsu5K0Q9wH9w9V25slddcxrh5JgORD14LpnOA7ov0L9ALi+6HrTjskLJ/tY5zeRF3TFA==",
|
||||
"version": "1.60.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.60.0.tgz",
|
||||
"integrity": "sha512-wZt3VTmzYrgZ0l/3QmEbCq4KAJ71K3/hmMQ/nfpv84oH8e81KKwPEoQ5v8dNCxfHFVJ1JabHKmCvqdYOoVm1Ow==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
"displayName": "myTemplateGenerator",
|
||||
"description": "Generate files and folders from customizable templates with variable substitution in VSCode.",
|
||||
"version": "0.0.1",
|
||||
"publisher": "MyTemplateGenerator",
|
||||
"author": "Sergey Gromov",
|
||||
"url": "https://github.com/gormov1122/MyTemplateGenerator",
|
||||
"engines": {
|
||||
@@ -68,7 +69,7 @@
|
||||
"devDependencies": {
|
||||
"@types/mocha": "^10.0.10",
|
||||
"@types/node": "20.x",
|
||||
"@types/vscode": "^1.102.0",
|
||||
"@types/vscode": "^1.60.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.31.1",
|
||||
"@typescript-eslint/parser": "^8.31.1",
|
||||
"@vscode/test-cli": "^0.0.11",
|
||||
|
||||
@@ -268,6 +268,29 @@ const I18N_DICTIONARIES: Record<string, Record<string, string>> = {
|
||||
}
|
||||
};
|
||||
|
||||
const SETTINGS_I18N: Record<string, Record<string, string>> = {
|
||||
ru: {
|
||||
title: 'Настройки myTemplateGenerator',
|
||||
templatesPath: 'Путь к шаблонам:',
|
||||
overwriteFiles: 'Перезаписывать существующие файлы',
|
||||
inputMode: 'Способ ввода переменных:',
|
||||
inputModeWebview: 'Webview (форма)',
|
||||
inputModeInputBox: 'InputBox (по одной)',
|
||||
language: 'Язык интерфейса:',
|
||||
save: 'Сохранить'
|
||||
},
|
||||
en: {
|
||||
title: 'myTemplateGenerator Settings',
|
||||
templatesPath: 'Templates path:',
|
||||
overwriteFiles: 'Overwrite existing files',
|
||||
inputMode: 'Variable input method:',
|
||||
inputModeWebview: 'Webview (form)',
|
||||
inputModeInputBox: 'InputBox (one by one)',
|
||||
language: 'Interface language:',
|
||||
save: 'Save'
|
||||
}
|
||||
};
|
||||
|
||||
interface MyTemplateGeneratorConfig {
|
||||
templatesPath: string;
|
||||
overwriteFiles: boolean;
|
||||
@@ -279,7 +302,7 @@ const DEFAULT_CONFIG: MyTemplateGeneratorConfig = {
|
||||
templatesPath: 'templates',
|
||||
overwriteFiles: false,
|
||||
inputMode: 'webview',
|
||||
language: 'ru',
|
||||
language: 'en',
|
||||
};
|
||||
|
||||
function getConfigPath(): string | undefined {
|
||||
@@ -313,20 +336,23 @@ function writeConfig(config: MyTemplateGeneratorConfig) {
|
||||
|
||||
async function showConfigWebview(context: vscode.ExtensionContext) {
|
||||
const config = readConfig();
|
||||
let language = config.language || 'ru';
|
||||
return new Promise<void>((resolve) => {
|
||||
const panel = vscode.window.createWebviewPanel(
|
||||
'mytemplategeneratorConfig',
|
||||
'Настройки myTemplateGenerator',
|
||||
SETTINGS_I18N[language]?.title || SETTINGS_I18N['ru'].title,
|
||||
vscode.ViewColumn.Active,
|
||||
{ enableScripts: true }
|
||||
);
|
||||
function setHtml() {
|
||||
const dict = SETTINGS_I18N[language] || SETTINGS_I18N['ru'];
|
||||
panel.webview.html = `
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<html lang="${language}">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval'; style-src 'unsafe-inline';">
|
||||
<title>Настройки myTemplateGenerator</title>
|
||||
<title>${dict.title}</title>
|
||||
<style>
|
||||
:root {
|
||||
--bg: #f7f7fa;
|
||||
@@ -447,41 +473,46 @@ async function showConfigWebview(context: vscode.ExtensionContext) {
|
||||
const language = document.getElementById('language').value;
|
||||
vscode.postMessage({ type: 'save', data: { templatesPath, overwriteFiles, inputMode, language } });
|
||||
});
|
||||
document.getElementById('language').addEventListener('change', (e) => {
|
||||
vscode.postMessage({ type: 'changeLanguage', language: e.target.value });
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="config-container">
|
||||
<h2>Настройки myTemplateGenerator</h2>
|
||||
<h2>${dict.title}</h2>
|
||||
<form id="configForm">
|
||||
<div class="form-group">
|
||||
<label for="templatesPath">Путь к шаблонам:</label>
|
||||
<input type="text" id="templatesPath" value="${config.templatesPath}" />
|
||||
<label for="templatesPath">${dict.templatesPath}</label>
|
||||
<input type="text" id="templatesPath" value="${config.templatesPath || ''}"/>
|
||||
</div>
|
||||
<div class="checkbox-group">
|
||||
<input type="checkbox" id="overwriteFiles" ${config.overwriteFiles ? 'checked' : ''}/>
|
||||
<label for="overwriteFiles">Перезаписывать существующие файлы</label>
|
||||
<label for="overwriteFiles">${dict.overwriteFiles}</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="inputMode">Способ ввода переменных:</label>
|
||||
<label for="inputMode">${dict.inputMode}</label>
|
||||
<select id="inputMode">
|
||||
<option value="webview" ${config.inputMode === 'webview' ? 'selected' : ''}>Webview (форма)</option>
|
||||
<option value="inputBox" ${config.inputMode === 'inputBox' ? 'selected' : ''}>InputBox (по одной)</option>
|
||||
<option value="webview" ${config.inputMode === 'webview' ? 'selected' : ''}>${dict.inputModeWebview}</option>
|
||||
<option value="inputBox" ${config.inputMode === 'inputBox' ? 'selected' : ''}>${dict.inputModeInputBox}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="language">Язык интерфейса:</label>
|
||||
<label for="language">${dict.language}</label>
|
||||
<select id="language">
|
||||
<option value="ru" ${config.language === 'ru' ? 'selected' : ''}>Русский</option>
|
||||
<option value="en" ${config.language === 'en' ? 'selected' : ''}>English</option>
|
||||
<option value="ru" ${language === 'ru' ? 'selected' : ''}>Русский</option>
|
||||
<option value="en" ${language === 'en' ? 'selected' : ''}>English</option>
|
||||
</select>
|
||||
</div>
|
||||
<button type="submit">Сохранить</button>
|
||||
<button type="submit" style="padding: 10px 15px">${dict.save}</button>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
`;
|
||||
}
|
||||
setHtml();
|
||||
panel.webview.onDidReceiveMessage(
|
||||
message => {
|
||||
if (message.type === 'save') {
|
||||
@@ -489,6 +520,9 @@ async function showConfigWebview(context: vscode.ExtensionContext) {
|
||||
vscode.window.showInformationMessage('Настройки myTemplateGenerator сохранены!');
|
||||
panel.dispose();
|
||||
resolve();
|
||||
} else if (message.type === 'changeLanguage') {
|
||||
language = message.language;
|
||||
setHtml();
|
||||
}
|
||||
},
|
||||
undefined,
|
||||
|
||||
Reference in New Issue
Block a user