mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
Enable localisation for template names/descriptions in VS
This commit is contained in:
@@ -11,6 +11,7 @@ import * as targz from 'tar.gz';
|
|||||||
const isWindows = /^win/.test(process.platform);
|
const isWindows = /^win/.test(process.platform);
|
||||||
const textFileExtensions = ['.gitignore', 'template_gitignore', '.config', '.cs', '.cshtml', '.csproj', '.html', '.js', '.json', '.jsx', '.md', '.nuspec', '.ts', '.tsx'];
|
const textFileExtensions = ['.gitignore', 'template_gitignore', '.config', '.cs', '.cshtml', '.csproj', '.html', '.js', '.json', '.jsx', '.md', '.nuspec', '.ts', '.tsx'];
|
||||||
const yeomanGeneratorSource = './src/yeoman';
|
const yeomanGeneratorSource = './src/yeoman';
|
||||||
|
const localizationPackageGuid = '{296D76CB-AD6F-4B46-9072-33CC07E265F8}';
|
||||||
|
|
||||||
const dotNetPackages = {
|
const dotNetPackages = {
|
||||||
builtIn: 'Microsoft.DotNet.Web.Spa.ProjectTemplates',
|
builtIn: 'Microsoft.DotNet.Web.Spa.ProjectTemplates',
|
||||||
@@ -22,15 +23,16 @@ interface TemplateConfig {
|
|||||||
dotNetNewId: string;
|
dotNetNewId: string;
|
||||||
dotNetPackageId: string;
|
dotNetPackageId: string;
|
||||||
displayName: string;
|
displayName: string;
|
||||||
|
localizationIdStart: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const templates: { [key: string]: TemplateConfig } = {
|
const templates: { [key: string]: TemplateConfig } = {
|
||||||
'angular': { dotNetPackageId: dotNetPackages.builtIn, dir: '../../templates/AngularSpa/', dotNetNewId: 'Angular', displayName: 'Angular' },
|
'angular': { dotNetPackageId: dotNetPackages.builtIn, dir: '../../templates/AngularSpa/', dotNetNewId: 'Angular', displayName: 'Angular', localizationIdStart: 100 },
|
||||||
'aurelia': { dotNetPackageId: dotNetPackages.extra, dir: '../../templates/AureliaSpa/', dotNetNewId: 'Aurelia', displayName: 'Aurelia' },
|
'aurelia': { dotNetPackageId: dotNetPackages.extra, dir: '../../templates/AureliaSpa/', dotNetNewId: 'Aurelia', displayName: 'Aurelia', localizationIdStart: 200 },
|
||||||
'knockout': { dotNetPackageId: dotNetPackages.extra, dir: '../../templates/KnockoutSpa/', dotNetNewId: 'Knockout', displayName: 'Knockout.js' },
|
'knockout': { dotNetPackageId: dotNetPackages.extra, dir: '../../templates/KnockoutSpa/', dotNetNewId: 'Knockout', displayName: 'Knockout.js', localizationIdStart: 300 },
|
||||||
'react-redux': { dotNetPackageId: dotNetPackages.builtIn, dir: '../../templates/ReactReduxSpa/', dotNetNewId: 'ReactRedux', displayName: 'React.js and Redux' },
|
'react-redux': { dotNetPackageId: dotNetPackages.builtIn, dir: '../../templates/ReactReduxSpa/', dotNetNewId: 'ReactRedux', displayName: 'React.js and Redux', localizationIdStart: 400 },
|
||||||
'react': { dotNetPackageId: dotNetPackages.builtIn, dir: '../../templates/ReactSpa/', dotNetNewId: 'React', displayName: 'React.js' },
|
'react': { dotNetPackageId: dotNetPackages.builtIn, dir: '../../templates/ReactSpa/', dotNetNewId: 'React', displayName: 'React.js', localizationIdStart: 500 },
|
||||||
'vue': { dotNetPackageId: dotNetPackages.extra, dir: '../../templates/VueSpa/', dotNetNewId: 'Vue', displayName: 'Vue.js' }
|
'vue': { dotNetPackageId: dotNetPackages.extra, dir: '../../templates/VueSpa/', dotNetNewId: 'Vue', displayName: 'Vue.js', localizationIdStart: 600 }
|
||||||
};
|
};
|
||||||
|
|
||||||
function isTextFile(filename: string): boolean {
|
function isTextFile(filename: string): boolean {
|
||||||
@@ -251,10 +253,13 @@ function buildDotNetNewNuGetPackage(packageId: string) {
|
|||||||
}
|
}
|
||||||
}, null, 2));
|
}, null, 2));
|
||||||
|
|
||||||
|
const localisedNameId = templateConfig.localizationIdStart + 0;
|
||||||
|
const localisedDescId = templateConfig.localizationIdStart + 1;
|
||||||
|
|
||||||
fs.writeFileSync(path.join(templateConfigDir, 'vs-2017.3.host.json'), JSON.stringify({
|
fs.writeFileSync(path.join(templateConfigDir, 'vs-2017.3.host.json'), JSON.stringify({
|
||||||
$schema: 'http://json.schemastore.org/vs-2017.3.host',
|
$schema: 'http://json.schemastore.org/vs-2017.3.host',
|
||||||
name: { text: templateConfig.displayName },
|
name: { text: templateConfig.displayName, package: localizationPackageGuid, id: localisedNameId.toString() },
|
||||||
description: { text: `ASP.NET Core application with MVC and ${templateConfig.displayName}` },
|
description: { text: `ASP.NET Core application with ${templateConfig.displayName}`, package: localizationPackageGuid, id: localisedDescId.toString() },
|
||||||
order: 301,
|
order: 301,
|
||||||
icon: 'icon.png',
|
icon: 'icon.png',
|
||||||
learnMoreLink: 'https://github.com/aspnet/JavaScriptServices',
|
learnMoreLink: 'https://github.com/aspnet/JavaScriptServices',
|
||||||
|
|||||||
Reference in New Issue
Block a user