Onboard to Localization (#175)
This commit is contained in:
Родитель
47f9ab83f3
Коммит
97fb0d5581
|
@ -23,6 +23,10 @@ parameters:
|
||||||
extends:
|
extends:
|
||||||
template: azure-pipelines/extension/stable.yml@templates
|
template: azure-pipelines/extension/stable.yml@templates
|
||||||
parameters:
|
parameters:
|
||||||
|
publishExtension: ${{ parameters.publishExtension }}
|
||||||
|
|
||||||
|
l10nSourcePaths: ./src
|
||||||
|
|
||||||
buildSteps:
|
buildSteps:
|
||||||
- script: npm ci
|
- script: npm ci
|
||||||
displayName: Install dependencies
|
displayName: Install dependencies
|
||||||
|
@ -39,4 +43,3 @@ extends:
|
||||||
- 'stbatt@microsoft.com'
|
- 'stbatt@microsoft.com'
|
||||||
- 'lszomoru@microsoft.com'
|
- 'lszomoru@microsoft.com'
|
||||||
|
|
||||||
publishExtension: ${{ parameters.publishExtension }}
|
|
||||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
14
package.json
14
package.json
|
@ -2,11 +2,11 @@
|
||||||
"name": "sublime-keybindings",
|
"name": "sublime-keybindings",
|
||||||
"displayName": "Sublime Text Keymap and Settings Importer",
|
"displayName": "Sublime Text Keymap and Settings Importer",
|
||||||
"description": "Import Sublime Text settings and keybindings into VS Code.",
|
"description": "Import Sublime Text settings and keybindings into VS Code.",
|
||||||
"version": "4.0.10",
|
"version": "4.1.10",
|
||||||
"publisher": "ms-vscode",
|
"publisher": "ms-vscode",
|
||||||
"license": "SEE LICENSE IN LICENSE.md",
|
"license": "SEE LICENSE IN LICENSE.md",
|
||||||
"engines": {
|
"engines": {
|
||||||
"vscode": "^1.53.0"
|
"vscode": "^1.75.0"
|
||||||
},
|
},
|
||||||
"categories": [
|
"categories": [
|
||||||
"Keymaps"
|
"Keymaps"
|
||||||
|
@ -22,6 +22,7 @@
|
||||||
],
|
],
|
||||||
"main": "./dist/extension.js",
|
"main": "./dist/extension.js",
|
||||||
"browser": "./dist/web/extension.js",
|
"browser": "./dist/web/extension.js",
|
||||||
|
"l10n": "./l10n",
|
||||||
"preview": false,
|
"preview": false,
|
||||||
"extensionKind": [
|
"extensionKind": [
|
||||||
"ui",
|
"ui",
|
||||||
|
@ -51,7 +52,7 @@
|
||||||
"@types/glob": "^7.1.3",
|
"@types/glob": "^7.1.3",
|
||||||
"@types/mocha": "^8.2.2",
|
"@types/mocha": "^8.2.2",
|
||||||
"@types/node": "^12.12.0",
|
"@types/node": "^12.12.0",
|
||||||
"@types/vscode": "^1.53.0",
|
"@types/vscode": "^1.75.0",
|
||||||
"@types/relaxed-json": "^1.0.0",
|
"@types/relaxed-json": "^1.0.0",
|
||||||
"glob": "^7.1.6",
|
"glob": "^7.1.6",
|
||||||
"mocha": "^10.2.0",
|
"mocha": "^10.2.0",
|
||||||
|
@ -59,8 +60,8 @@
|
||||||
"typescript": "^4.2.3",
|
"typescript": "^4.2.3",
|
||||||
"vscode-test": "^1.5.2",
|
"vscode-test": "^1.5.2",
|
||||||
"ts-loader": "^8.1.0",
|
"ts-loader": "^8.1.0",
|
||||||
"webpack": "^5.30.0",
|
"webpack": "^5.89.0",
|
||||||
"webpack-cli": "^4.6.0"
|
"webpack-cli": "^5.1.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"relaxed-json": "^1.0.3"
|
"relaxed-json": "^1.0.3"
|
||||||
|
@ -77,7 +78,8 @@
|
||||||
"commands": [
|
"commands": [
|
||||||
{
|
{
|
||||||
"command": "extension.importFromSublime",
|
"command": "extension.importFromSublime",
|
||||||
"title": "Sublime Text Keymap: Import Sublime Text Settings"
|
"title": "%extension.importFromSublime.title%",
|
||||||
|
"category": "%extension.category%"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"keybindings": [
|
"keybindings": [
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"extension.importFromSublime.title": "Import Sublime Text Settings",
|
||||||
|
"extension.category": "Sublime Text Keymap"
|
||||||
|
}
|
|
@ -18,8 +18,14 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
|
||||||
}
|
}
|
||||||
|
|
||||||
async function showPrompt(): Promise<void> {
|
async function showPrompt(): Promise<void> {
|
||||||
const answer: string | undefined = await vscode.window.showInformationMessage('Would you like to customize VS Code to behave more like Sublime Text?', 'Yes', 'No');
|
const yes = vscode.l10n.t('Yes');
|
||||||
if (answer && answer === 'Yes') {
|
const no = vscode.l10n.t('No');
|
||||||
|
const answer: string | undefined = await vscode.window.showInformationMessage(
|
||||||
|
vscode.l10n.t('Would you like to customize VS Code to behave more like Sublime Text?'),
|
||||||
|
yes,
|
||||||
|
no,
|
||||||
|
);
|
||||||
|
if (answer && answer === yes) {
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +40,7 @@ async function start(): Promise<void> {
|
||||||
await vscode.commands.executeCommand('workbench.action.openGlobalSettings');
|
await vscode.commands.executeCommand('workbench.action.openGlobalSettings');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
vscode.window.showInformationMessage('Nothing to import. All settings have already been imported');
|
vscode.window.showInformationMessage(vscode.l10n.t('Nothing to import. All settings have already been imported'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,24 +58,38 @@ async function getSublimeFolderPath(): Promise<string | undefined> {
|
||||||
if (sublimeSettingsPath) {
|
if (sublimeSettingsPath) {
|
||||||
return sublimeSettingsPath.fsPath;
|
return sublimeSettingsPath.fsPath;
|
||||||
}
|
}
|
||||||
return await browsePrompt(`No Sublime settings file found at the default location: ${path.join(sublimeFolderFinder.getOSDefaultPaths()[0], sublimeFolderFinder.sublimeSettingsFilename)} `);
|
return await browsePrompt(
|
||||||
|
vscode.l10n.t(
|
||||||
|
'No Sublime settings file found at the default location: {0}',
|
||||||
|
path.join(sublimeFolderFinder.getOSDefaultPaths()[0], sublimeFolderFinder.sublimeSettingsFilename)
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function browsePrompt(msg: string): Promise<string | undefined> {
|
async function browsePrompt(msg: string): Promise<string | undefined> {
|
||||||
const result = await vscode.window.showInformationMessage(msg, 'Browse...');
|
const result = await vscode.window.showInformationMessage(msg, vscode.l10n.t('Browse...'));
|
||||||
if (result) {
|
if (!result) {
|
||||||
const sublimeSettingsFiles = await vscode.window.showOpenDialog({ canSelectFiles: true });
|
return undefined;
|
||||||
if (sublimeSettingsFiles && sublimeSettingsFiles.length) {
|
}
|
||||||
const filePath = sublimeSettingsFiles[0].fsPath;
|
const sublimeSettingsFiles = await vscode.window.showOpenDialog({ canSelectFiles: true });
|
||||||
const isValidFilePath = await validate(filePath);
|
if (!sublimeSettingsFiles || !sublimeSettingsFiles.length) {
|
||||||
if (isValidFilePath) {
|
return undefined;
|
||||||
return filePath;
|
|
||||||
} else {
|
}
|
||||||
vscode.window.showErrorMessage(`Could not find ${sublimeFolderFinder.sublimeSettingsFilename} at ${sublimeSettingsFiles[0].fsPath} `);
|
const filePath = sublimeSettingsFiles[0].fsPath;
|
||||||
}
|
const isValidFilePath = await validate(filePath);
|
||||||
}
|
if (isValidFilePath) {
|
||||||
|
return filePath;
|
||||||
|
} else {
|
||||||
|
vscode.window.showErrorMessage(
|
||||||
|
vscode.l10n.t({
|
||||||
|
message: 'Could not find {0} at {1}',
|
||||||
|
args: [sublimeFolderFinder.sublimeSettingsFilename, sublimeSettingsFiles[0].fsPath],
|
||||||
|
comment: ['{0} is a filename, {1} is a path']
|
||||||
|
})
|
||||||
|
);
|
||||||
|
return undefined;
|
||||||
}
|
}
|
||||||
return undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function validate(settingsFilePath: string): boolean {
|
function validate(settingsFilePath: string): boolean {
|
||||||
|
@ -109,7 +129,7 @@ function setting2QuickPickItem(setting: VscodeSetting, sublimeName?: string): IS
|
||||||
const icons = { exclamationPoint: '$(issue-opened)', arrowRight: '$(arrow-right)' }; // stored in var because auto-format adds spaces to hypens
|
const icons = { exclamationPoint: '$(issue-opened)', arrowRight: '$(arrow-right)' }; // stored in var because auto-format adds spaces to hypens
|
||||||
return {
|
return {
|
||||||
detail: setting.overwritesValue
|
detail: setting.overwritesValue
|
||||||
? `${icons.exclamationPoint} Overwrites existing value: '${setting.oldValue}' with '${setting.value}'`
|
? icons.exclamationPoint + ' ' + vscode.l10n.t(`Overwrites existing value: '{0}' with '{1}'`, setting.oldValue, setting.value)
|
||||||
: '',
|
: '',
|
||||||
label: sublimeName
|
label: sublimeName
|
||||||
? `${sublimeName} ${icons.arrowRight} ${setting.name}`
|
? `${sublimeName} ${icons.arrowRight} ${setting.name}`
|
||||||
|
@ -122,7 +142,7 @@ function setting2QuickPickItem(setting: VscodeSetting, sublimeName?: string): IS
|
||||||
async function importSettings(settings: ISetting[]): Promise<void> {
|
async function importSettings(settings: ISetting[]): Promise<void> {
|
||||||
return vscode.window.withProgress({
|
return vscode.window.withProgress({
|
||||||
location: vscode.ProgressLocation.Notification,
|
location: vscode.ProgressLocation.Notification,
|
||||||
title: 'Importing Settings',
|
title: vscode.l10n.t('Importing Settings'),
|
||||||
}, async (progress) => {
|
}, async (progress) => {
|
||||||
progress.report({ increment: 0 });
|
progress.report({ increment: 0 });
|
||||||
const incrementSize = 100.0 / settings.length;
|
const incrementSize = 100.0 / settings.length;
|
||||||
|
@ -131,7 +151,7 @@ async function importSettings(settings: ISetting[]): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await config.update(setting.name, setting.value, vscode.ConfigurationTarget.Global);
|
await config.update(setting.name, setting.value, vscode.ConfigurationTarget.Global);
|
||||||
progress.report({ increment: incrementSize, message: setting.name });
|
progress.report({ increment: incrementSize, message: setting.name });
|
||||||
} catch (e) {
|
} catch (e: any) {
|
||||||
vscode.window.showErrorMessage(e.message);
|
vscode.window.showErrorMessage(e.message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ export class Mapper {
|
||||||
try {
|
try {
|
||||||
parsedSublimeSettings = rjson.parse(sublimeSettings);
|
parsedSublimeSettings = rjson.parse(sublimeSettings);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
vscode.window.showErrorMessage('The sublime settings file could not be parsed. Please check if it contains syntax errors.');
|
vscode.window.showErrorMessage(vscode.l10n.t('The sublime settings file could not be parsed. Please check if it contains syntax errors.'));
|
||||||
throw (e);
|
throw (e);
|
||||||
}
|
}
|
||||||
return this.mapAllSettings(settingsMappings, parsedSublimeSettings);
|
return this.mapAllSettings(settingsMappings, parsedSublimeSettings);
|
||||||
|
@ -95,7 +95,7 @@ export class Mapper {
|
||||||
const configTest = this.checkWithExistingSettings(defaultSetting, config);
|
const configTest = this.checkWithExistingSettings(defaultSetting, config);
|
||||||
|
|
||||||
if (configTest.alreadyExists) {
|
if (configTest.alreadyExists) {
|
||||||
settings.alreadyExisting.push(new MappedSetting({ name: 'Default Setting', value: '' }, defaultSetting));
|
settings.alreadyExisting.push(new MappedSetting({ name: vscode.l10n.t('Default Setting'), value: '' }, defaultSetting));
|
||||||
} else {
|
} else {
|
||||||
if (configTest.existingValue) {
|
if (configTest.existingValue) {
|
||||||
defaultSetting.markAsOverride(configTest.existingValue);
|
defaultSetting.markAsOverride(configTest.existingValue);
|
||||||
|
@ -125,7 +125,13 @@ export class Mapper {
|
||||||
} else if (typeof mappedValue === 'object') {
|
} else if (typeof mappedValue === 'object') {
|
||||||
const obj = mappedValue[sublimeSetting.value];
|
const obj = mappedValue[sublimeSetting.value];
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
vscode.window.showErrorMessage(`Failed to parse setting: '${sublimeSetting.name}: ${sublimeSetting.value}'. Please check if it contains syntax errors`);
|
vscode.window.showErrorMessage(vscode.l10n.t(
|
||||||
|
{
|
||||||
|
message: "Failed to parse setting: '{0}: {1}'. Please check if it contains syntax errors",
|
||||||
|
args: [sublimeSetting.name, sublimeSetting.value],
|
||||||
|
comment: ["{0} is the name of the setting, {1} is the value of the setting"]
|
||||||
|
}
|
||||||
|
));
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
const keys = Object.keys(obj);
|
const keys = Object.keys(obj);
|
||||||
|
|
|
@ -3,6 +3,6 @@ import * as vscode from 'vscode';
|
||||||
|
|
||||||
export async function activate(context: vscode.ExtensionContext): Promise<void> {
|
export async function activate(context: vscode.ExtensionContext): Promise<void> {
|
||||||
context.subscriptions.push(vscode.commands.registerCommand('extension.importFromSublime', () => {
|
context.subscriptions.push(vscode.commands.registerCommand('extension.importFromSublime', () => {
|
||||||
vscode.window.showWarningMessage('Importing from local Sublime settings is currently only possible when running in the desktop.', { modal: true })
|
vscode.window.showWarningMessage(vscode.l10n.t('Importing from local Sublime settings is currently only possible when running in the desktop.'), { modal: true })
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче