diff --git a/src/dotnet/commands/dotnet-new3/AppExtensions.cs b/src/dotnet/commands/dotnet-new3/AppExtensions.cs index 01db5122d..e69e15678 100644 --- a/src/dotnet/commands/dotnet-new3/AppExtensions.cs +++ b/src/dotnet/commands/dotnet-new3/AppExtensions.cs @@ -13,7 +13,7 @@ namespace Microsoft.DotNet.Tools.New3 { public static CommandOption Help(this CommandLineApplication app) { - return app.Option("-h|--help", "Displays help for this command.", CommandOptionType.NoValue); + return app.Option("-h|--help", LocalizableStrings.DisplaysHelp, CommandOptionType.NoValue); } public static IReadOnlyDictionary> ParseExtraArgs(this CommandLineApplication app, IList extraArgFileNames) @@ -36,8 +36,11 @@ namespace Microsoft.DotNet.Tools.New3 { if(property.Value.Type == JTokenType.String) { - IList values = new List(); - values.Add(property.Value.ToString()); + IList values = new List + { + property.Value.ToString() + }; + // adding 2 dashes to the file-based params // won't work right if there's a param that should have 1 dash // @@ -75,7 +78,7 @@ namespace Microsoft.DotNet.Tools.New3 if (!key.StartsWith("-", StringComparison.Ordinal)) { - throw new Exception("Parameter names must start with -- or -"); + throw new Exception(LocalizableStrings.ParameterNamePrefixError); } // Check the next value. If it doesn't start with a '-' then it's a value for the current param. @@ -95,8 +98,7 @@ namespace Microsoft.DotNet.Tools.New3 } } - IList valueList; - if (!parameters.TryGetValue(key, out valueList)) + if (!parameters.TryGetValue(key, out var valueList)) { valueList = new List(); parameters.Add(key, valueList); diff --git a/src/dotnet/commands/dotnet-new3/ExtendedCommandParser.cs b/src/dotnet/commands/dotnet-new3/ExtendedCommandParser.cs index e4f1799a5..684d41bee 100644 --- a/src/dotnet/commands/dotnet-new3/ExtendedCommandParser.cs +++ b/src/dotnet/commands/dotnet-new3/ExtendedCommandParser.cs @@ -90,7 +90,7 @@ namespace Microsoft.DotNet.Tools.New3 { if (IsParameterNameTaken(parameter)) { - throw new Exception($"Parameter name {parameter} cannot be used for multiple purposes"); + throw new Exception(string.Format(LocalizableStrings.ParameterReuseError, parameter)); } _defaultCommandOptions.Add(parameter); @@ -117,7 +117,7 @@ namespace Microsoft.DotNet.Tools.New3 { if (IsParameterNameTaken(parameters[i])) { - throw new Exception($"Parameter name {parameters[i]} cannot be used for multiple purposes"); + throw new Exception(string.Format(LocalizableStrings.ParameterReuseError, parameters[i])); } _hiddenCommandCanonicalMapping.Add(parameters[i], canonical); @@ -193,8 +193,7 @@ namespace Microsoft.DotNet.Tools.New3 foreach (KeyValuePair> param in allParameters) { - string canonicalName; - if (_hiddenCommandCanonicalMapping.TryGetValue(param.Key, out canonicalName)) + if (_hiddenCommandCanonicalMapping.TryGetValue(param.Key, out string canonicalName)) { CommandOptionType optionType = _hiddenCommandOptions[canonicalName]; @@ -206,14 +205,14 @@ namespace Microsoft.DotNet.Tools.New3 { if (param.Value.Count != 1) { - throw new Exception($"Multiple values specified for single value parameter: {canonicalName}"); + throw new Exception(string.Format(LocalizableStrings.MultipleValuesSpecifiedForSingleValuedParameter, canonicalName)); } } else // NoValue { if (param.Value.Count != 1 || param.Value[0] != null) { - throw new Exception($"Value specified for valueless parameter: {canonicalName}"); + throw new Exception(string.Format(LocalizableStrings.ValueSpecifiedForValuelessParameter, canonicalName)); } } @@ -224,13 +223,13 @@ namespace Microsoft.DotNet.Tools.New3 if (_parsedTemplateParams.ContainsKey(canonicalName)) { // error, the same param was specified twice - throw new Exception($"Parameter [{canonicalName}] was specified multiple times, including with the flag [{param.Key}]"); + throw new Exception(string.Format(LocalizableStrings.ParameterSpecifiedMultipleTimes, canonicalName, param.Key)); } else { if ((param.Value[0] == null) && (_templateParamDataTypeMapping[canonicalName] != "bool")) { - throw new Exception($"Parameter [{param.Key}] ({canonicalName}) must be given a value"); + throw new Exception(string.Format(LocalizableStrings.ParameterMissingValue, param.Key, canonicalName)); } // TODO: allow for multi-valued params @@ -258,8 +257,7 @@ namespace Microsoft.DotNet.Tools.New3 continue; } - string flagFullText; - if (parameterNameMap == null || !parameterNameMap.TryGetValue(parameter.Name, out flagFullText)) + if (parameterNameMap == null || !parameterNameMap.TryGetValue(parameter.Name, out string flagFullText)) { flagFullText = parameter.Name; } @@ -328,7 +326,7 @@ namespace Microsoft.DotNet.Tools.New3 if (invalidParams.Count > 0) { string unusableDisplayList = string.Join(", ", invalidParams); - throw new Exception($"Template is malformed. The following parameter names are invalid: {unusableDisplayList}"); + throw new Exception(string.Format(LocalizableStrings.TemplateMalformedDueToBadParameters, unusableDisplayList)); } } @@ -336,7 +334,7 @@ namespace Microsoft.DotNet.Tools.New3 { if (_templateParamCanonicalMapping.TryGetValue(variant, out string existingCanonical)) { - throw new Exception($"Option variant {variant} for canonical {canonical} was already defined for canonical {existingCanonical}"); + throw new Exception(string.Format(LocalizableStrings.OptionVariantAlreadyDefined, variant, canonical, existingCanonical)); } _templateParamCanonicalMapping[variant] = canonical; @@ -370,9 +368,7 @@ namespace Microsoft.DotNet.Tools.New3 { string variant = variantToCanonical.Key; string canonical = variantToCanonical.Value; - - IList variantList; - if (!_canonicalToVariantsTemplateParamMap.TryGetValue(canonical, out variantList)) + if (!_canonicalToVariantsTemplateParamMap.TryGetValue(canonical, out var variantList)) { variantList = new List(); _canonicalToVariantsTemplateParamMap.Add(canonical, variantList); diff --git a/src/dotnet/commands/dotnet-new3/LocalizableStrings.cs b/src/dotnet/commands/dotnet-new3/LocalizableStrings.cs new file mode 100644 index 000000000..8cf9fb73f --- /dev/null +++ b/src/dotnet/commands/dotnet-new3/LocalizableStrings.cs @@ -0,0 +1,115 @@ +using System; + +namespace Microsoft.DotNet.Tools.New3 +{ + internal class LocalizableStrings + { + public const string DisplaysHelp = "Displays help for this command."; + + public const string ParameterNamePrefixError = "Parameter names must start with -- or -"; + + public const string ParameterReuseError = "Parameter name {0} cannot be used for multiple purposes"; + + public const string MultipleValuesSpecifiedForSingleValuedParameter = "Multiple values specified for single value parameter: {0}"; + + public const string ValueSpecifiedForValuelessParameter = "Value specified for valueless parameter: {0}"; + + public const string ParameterSpecifiedMultipleTimes = "Parameter [{0}] was specified multiple times, including with the flag [{1}]"; + + public const string ParameterMissingValue = "Parameter [{0}] ({1}) must be given a value"; + + public const string TemplateMalformedDueToBadParameters = "Template is malformed. The following parameter names are invalid: {0}"; + + public const string OptionVariantAlreadyDefined = "Option variant {0} for canonical {1} was already defined for canonical {2}"; + + public const string ListsTemplates = "List templates containing the specified name."; + + public const string NameOfOutput = "The name for the output being created. If no name is specified, the name of the current directory is used."; + + public const string CreateDirectoryHelp = "Indicates whether to create a directory for the generated content."; + + public const string CreateAliasHelp = "Creates an alias for the specified template."; + + public const string ExtraArgsFileHelp = "Specifies a file containing additional parameters."; + + public const string LocaleHelp = "The locale to use"; + + public const string QuietModeHelp = "Doesn't output any status information."; + + public const string InstallHelp = "Installs a source or a template pack."; + + public const string UpdateHelp = "Update matching templates."; + + public const string CommandDescription = "Template Instantiation Commands for .NET Core CLI."; + + public const string TemplateArgumentHelp = "The template to instantiate."; + + public const string BadLocaleError = "Invalid format for input locale: [{0}]. Example valid formats: [en] [en-US]"; + + public const string AliasCreated = "Alias creation successful"; + + public const string AliasAlreadyExists = "Specified alias {0} already exists. Please specify a different alias."; + + public const string CreateSuccessful = "The template {0} created successfully."; + + public const string CreateFailed = "Template {0} could not be created. Error returned was: {1}"; + + public const string InstallSuccessful = "{0} was installed successfully."; + + public const string InstallFailed = "{0} could not be installed. Error returned was: {1}."; + + public const string MissingRequiredParameter = "Mandatory parameter {0} missing for template {1}."; + + public const string GettingReady = "Getting ready..."; + + public const string InvalidInputSwitch = "Invalid input switch:"; + + public const string CheckingForUpdates = "Checking for updates for {0}..."; + + public const string UpdateAvailable = "An update for {0} is available..."; + + public const string NoUpdates = "No updates were found."; + + public const string InstallingUpdates = "Installing updates..."; + + public const string BadPackageSpec = "Package [{0}] is not a valid package specification"; + + public const string Templates = "Templates"; + + public const string ShortName = "Short Name"; + + public const string Alias = "Alias"; + + public const string CurrentConfiguration = "Current configuration:"; + + public const string NoItems = "(No Items)"; + + public const string MountPoints = "Mount Points"; + + public const string MountPointFactories = "Mount Point Factories"; + + public const string Generators = "Generators"; + + public const string Id = "Id"; + + public const string Parent = "Parent"; + + public const string Assembly = "Assembly"; + + public const string Type = "Type"; + + public const string Factory = "Factory"; + + public const string Author = "Author: {0}"; + + public const string Description = "Description: {0}"; + + public const string Options = "Options:"; + + public const string ConfiguredValue = "Configured Value: {0}"; + + public const string DefaultValue = "Default: {0}"; + + public const string NoParameters = " (No Parameters)"; + } +} diff --git a/src/dotnet/commands/dotnet-new3/Program.cs b/src/dotnet/commands/dotnet-new3/Program.cs index daea87610..d59086fc0 100644 --- a/src/dotnet/commands/dotnet-new3/Program.cs +++ b/src/dotnet/commands/dotnet-new3/Program.cs @@ -28,9 +28,9 @@ namespace Microsoft.DotNet.Tools.New3 private static void SetupInternalCommands(ExtendedCommandParser appExt) { // visible - appExt.InternalOption("-l|--list", "--list", "List templates containing the specified name.", CommandOptionType.NoValue); - appExt.InternalOption("-n|--name", "--name", "The name for the output being created. If no name is specified, the name of the current directory is used.", CommandOptionType.SingleValue); - appExt.InternalOption("-h|--help", "--help", "Display help for the indicated template's parameters.", CommandOptionType.NoValue); + appExt.InternalOption("-l|--list", "--list", LocalizableStrings.ListsTemplates, CommandOptionType.NoValue); + appExt.InternalOption("-n|--name", "--name", LocalizableStrings.NameOfOutput, CommandOptionType.SingleValue); + appExt.InternalOption("-h|--help", "--help", LocalizableStrings.DisplaysHelp, CommandOptionType.NoValue); // hidden appExt.HiddenInternalOption("-d|--dir", "--dir", CommandOptionType.NoValue); @@ -48,14 +48,14 @@ namespace Microsoft.DotNet.Tools.New3 // Preserve these for now - they've got the help text, in case we want it back. // (they'll need to get converted to extended option calls) // - //CommandOption dirOption = app.Option("-d|--dir", "Indicates whether to create a directory for the generated content.", CommandOptionType.NoValue); - //CommandOption aliasOption = app.Option("-a|--alias", "Creates an alias for the specified template.", CommandOptionType.SingleValue); - //CommandOption parametersFilesOption = app.Option("-x|--extra-args", "Specifies a file containing additional parameters.", CommandOptionType.MultipleValue); - //CommandOption localeOption = app.Option("--locale", "The locale to use", CommandOptionType.SingleValue); - //CommandOption quietOption = app.Option("--quiet", "Doesn't output any status information.", CommandOptionType.NoValue); - //CommandOption installOption = app.Option("-i|--install", "Installs a source or a template pack.", CommandOptionType.MultipleValue); + //CommandOption dirOption = app.Option("-d|--dir", LocalizableStrings.CreateDirectoryHelp, CommandOptionType.NoValue); + //CommandOption aliasOption = app.Option("-a|--alias", LocalizableStrings.CreateAliasHelp, CommandOptionType.SingleValue); + //CommandOption parametersFilesOption = app.Option("-x|--extra-args", LocalizableString.ExtraArgsFileHelp, CommandOptionType.MultipleValue); + //CommandOption localeOption = app.Option("--locale", LocalizableStrings.LocaleHelp, CommandOptionType.SingleValue); + //CommandOption quietOption = app.Option("--quiet", LocalizableStrings.QuietModeHelp, CommandOptionType.NoValue); + //CommandOption installOption = app.Option("-i|--install", LocalizableStrings.InstallHelp, CommandOptionType.MultipleValue); - //CommandOption update = app.Option("--update", "Update matching templates.", CommandOptionType.NoValue); + //CommandOption update = app.Option("--update", LocalizableStrings.UpdateHelp, CommandOptionType.NoValue); } public static int Run(string[] args) @@ -66,11 +66,11 @@ namespace Microsoft.DotNet.Tools.New3 ExtendedCommandParser app = new ExtendedCommandParser() { - Name = "dotnet new3", - FullName = "Template Instantiation Commands for .NET Core CLI." + Name = "dotnet new", + FullName = LocalizableStrings.CommandDescription }; SetupInternalCommands(app); - CommandArgument templateNames = app.Argument("template", "The template to instantiate."); + CommandArgument templateNames = app.Argument("template", LocalizableStrings.TemplateArgumentHelp); app.OnExecute(async () => { @@ -90,7 +90,7 @@ namespace Microsoft.DotNet.Tools.New3 string newLocale = app.InternalParamValue("--locale"); if (!ValidateLocaleFormat(newLocale)) { - EngineEnvironmentSettings.Host.LogMessage(string.Format("Invalid format for input locale: [{0}]. Example valid formats: [en] [en-US]", newLocale)); + EngineEnvironmentSettings.Host.LogMessage(string.Format(LocalizableStrings.BadLocaleError, newLocale)); return -1; } @@ -115,7 +115,7 @@ namespace Microsoft.DotNet.Tools.New3 return resultCode; } - return await CreateTemplate(app, templateNames.Value); + return await CreateTemplateAsync(app, templateNames.Value); }); int result; @@ -159,7 +159,7 @@ namespace Microsoft.DotNet.Tools.New3 return result; } - private static async Task CreateTemplate(ExtendedCommandParser app, string templateName) + private static async Task CreateTemplateAsync(ExtendedCommandParser app, string templateName) { string nameValue = app.InternalParamValue("--name"); string fallbackName = new DirectoryInfo(Directory.GetCurrentDirectory()).Name; @@ -176,32 +176,29 @@ namespace Microsoft.DotNet.Tools.New3 { case CreationResultStatus.AliasSucceeded: // TODO: get this localized - in the mean time just list the templates, showing the alias - //EngineEnvironmentSettings.Host.LogMessage("Alias creation successful"); + //EngineEnvironmentSettings.Host.LogMessage(LocalizableStrings.AliasCreated); ListTemplates(templateName); break; case CreationResultStatus.AliasFailed: - EngineEnvironmentSettings.Host.LogMessage(string.Format("Specified alias {0} already exists. Please specify a different alias.", aliasName)); + EngineEnvironmentSettings.Host.LogMessage(string.Format(LocalizableStrings.AliasAlreadyExists, aliasName)); ListTemplates(templateName); break; case CreationResultStatus.CreateSucceeded: - EngineEnvironmentSettings.Host.LogMessage(string.Format("The template {0} created successfully. Please run \"dotnet restore\" to get started!", resultTemplateName)); + EngineEnvironmentSettings.Host.LogMessage(string.Format(LocalizableStrings.CreateSuccessful, resultTemplateName)); break; case CreationResultStatus.CreateFailed: - EngineEnvironmentSettings.Host.LogMessage(string.Format("Template {0} could not be created. Error returned was: {1}", resultTemplateName, instantiateResult.Message)); + case CreationResultStatus.TemplateNotFound: + EngineEnvironmentSettings.Host.LogMessage(string.Format(LocalizableStrings.CreateFailed, resultTemplateName, instantiateResult.Message)); ListTemplates(templateName); break; case CreationResultStatus.InstallSucceeded: - EngineEnvironmentSettings.Host.LogMessage(string.Format("The template {0} installed successfully. You can use \"dotnet new {0}\" to get started with the new template.", resultTemplateName)); + EngineEnvironmentSettings.Host.LogMessage(string.Format(LocalizableStrings.InstallSuccessful, resultTemplateName)); break; case CreationResultStatus.InstallFailed: - EngineEnvironmentSettings.Host.LogMessage(string.Format("Template {0} could not be created. Error returned was: {1}.", resultTemplateName, instantiateResult.Message)); + EngineEnvironmentSettings.Host.LogMessage(string.Format(LocalizableStrings.InstallFailed, resultTemplateName, instantiateResult.Message)); break; case CreationResultStatus.MissingMandatoryParam: - EngineEnvironmentSettings.Host.LogMessage(string.Format("Mandatory parameter {0} missing for template {1}.", instantiateResult.Message, resultTemplateName)); - break; - case CreationResultStatus.TemplateNotFound: - EngineEnvironmentSettings.Host.LogMessage(string.Format("Template {0} could not be created. Error returned was: {1}.", resultTemplateName, instantiateResult.Message)); - ListTemplates(templateName); + EngineEnvironmentSettings.Host.LogMessage(string.Format(LocalizableStrings.MissingRequiredParameter, instantiateResult.Message, resultTemplateName)); break; default: break; @@ -233,7 +230,7 @@ namespace Microsoft.DotNet.Tools.New3 { if (!app.InternalParamHasValue("--quiet")) { - Reporter.Output.WriteLine("Getting things ready for first use..."); + Reporter.Output.WriteLine(LocalizableStrings.GettingReady); } ConfigureEnvironment(); @@ -279,7 +276,7 @@ namespace Microsoft.DotNet.Tools.New3 if (app.RemainingParameters.Any(x => !x.Key.StartsWith("--debug:"))) { - EngineEnvironmentSettings.Host.LogMessage("Invalid input switch:"); + EngineEnvironmentSettings.Host.LogMessage(LocalizableStrings.InvalidInputSwitch); foreach (string flag in app.RemainingParameters.Keys) { EngineEnvironmentSettings.Host.LogMessage($"\t{flag}"); @@ -357,7 +354,7 @@ namespace Microsoft.DotNet.Tools.New3 // { // if (!quiet) // { - // Reporter.Output.WriteLine($"Checking for updates for {src.Alias}..."); + // Reporter.Output.WriteLine(string.Format(LocalizableStrings.CheckingForUpdates, src.Alias)); // } // bool updatesReady; @@ -375,7 +372,7 @@ namespace Microsoft.DotNet.Tools.New3 // { // if (!quiet) // { - // Reporter.Output.WriteLine($"An update for {src.Alias} is available..."); + // Reporter.Output.WriteLine(string.Format(LocalizableStrings.UpdateAvailable, src.Alias)); // } // string packageId = src.ParentSource != null @@ -390,7 +387,7 @@ namespace Microsoft.DotNet.Tools.New3 // { // if (!quiet) // { - // Reporter.Output.WriteLine("No updates were found."); + // Reporter.Output.WriteLine(LocalizableStrings.NoUpdates); // } // return 0; @@ -398,7 +395,7 @@ namespace Microsoft.DotNet.Tools.New3 // if (!quiet) // { - // Reporter.Output.WriteLine("Installing updates..."); + // Reporter.Output.WriteLine(LocalizableString.InstallingUpdates); // } // List installCommands = new List(); @@ -416,8 +413,8 @@ namespace Microsoft.DotNet.Tools.New3 // installCommands.Add("--quiet"); // uninstallCommands.Add("--quiet"); - // Command.CreateDotNet("new3", uninstallCommands).ForwardStdOut().ForwardStdErr().Execute(); - // Command.CreateDotNet("new3", installCommands).ForwardStdOut().ForwardStdErr().Execute(); + // Command.CreateDotNet("new", uninstallCommands).ForwardStdOut().ForwardStdErr().Execute(); + // Command.CreateDotNet("new", installCommands).ForwardStdOut().ForwardStdErr().Execute(); // Broker.ComponentRegistry.ForceReinitialize(); // if (!quiet) @@ -430,24 +427,24 @@ namespace Microsoft.DotNet.Tools.New3 private static void ConfigureEnvironment() { - string userNuGetConfig = $@" - - - - -"; - Paths.User.NuGetConfig.WriteAllText(userNuGetConfig); + string[] packageList; - string[] packageList = Paths.Global.DefaultInstallPackageList.ReadAllText().Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); - if (packageList.Length > 0) + if (Paths.Global.DefaultInstallPackageList.FileExists()) { - InstallPackages(packageList, true); + packageList = Paths.Global.DefaultInstallPackageList.ReadAllText().Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); + if (packageList.Length > 0) + { + InstallPackages(packageList, true); + } } - packageList = Paths.Global.DefaultInstallTemplateList.ReadAllText().Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); - if (packageList.Length > 0) + if (Paths.Global.DefaultInstallTemplateList.FileExists()) { - InstallPackages(packageList, true); + packageList = Paths.Global.DefaultInstallTemplateList.ReadAllText().Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); + if (packageList.Length > 0) + { + InstallPackages(packageList, true); + } } } @@ -478,7 +475,7 @@ namespace Microsoft.DotNet.Tools.New3 } catch { - EngineEnvironmentSettings.Host.OnNonCriticalError("InvalidPackageSpecification", string.Format($"Package [{pkg}] is not a valid package specification"), null, 0); + EngineEnvironmentSettings.Host.OnNonCriticalError("InvalidPackageSpecification", string.Format(LocalizableStrings.BadPackageSpec, pkg), null, 0); } } @@ -494,36 +491,36 @@ namespace Microsoft.DotNet.Tools.New3 { IEnumerable results = TemplateCreator.List(templateNames); HelpFormatter formatter = new HelpFormatter(results, 6, '-', false); - formatter.DefineColumn(delegate (ITemplateInfo t) { return t.Name; }, "Templates"); - formatter.DefineColumn(delegate (ITemplateInfo t) { return $"[{t.ShortName}]"; }, "Short Name"); - formatter.DefineColumn(delegate (ITemplateInfo t) { return AliasRegistry.GetAliasForTemplate(t) ?? ""; }, "Alias"); + formatter.DefineColumn(delegate (ITemplateInfo t) { return t.Name; }, LocalizableStrings.Templates); + formatter.DefineColumn(delegate (ITemplateInfo t) { return $"[{t.ShortName}]"; }, LocalizableStrings.ShortName); + formatter.DefineColumn(delegate (ITemplateInfo t) { return AliasRegistry.GetAliasForTemplate(t) ?? ""; }, LocalizableStrings.Alias); Reporter.Output.WriteLine(formatter.Layout()); } private static void ShowConfig() { - Reporter.Output.WriteLine("dotnet new3 current configuration:"); + Reporter.Output.WriteLine(LocalizableStrings.CurrentConfiguration); Reporter.Output.WriteLine(" "); - TableFormatter.Print(SettingsLoader.MountPoints, "(No Items)", " ", '-', new Dictionary> + TableFormatter.Print(SettingsLoader.MountPoints, LocalizableStrings.NoItems, " ", '-', new Dictionary> { - {"Mount Points", x => x.Place}, - {"Id", x => x.MountPointId}, - {"Parent", x => x.ParentMountPointId}, - {"Factory", x => x.MountPointFactoryId} + {LocalizableStrings.MountPoints, x => x.Place}, + {LocalizableStrings.Id, x => x.MountPointId}, + {LocalizableStrings.Parent, x => x.ParentMountPointId}, + {LocalizableStrings.Factory, x => x.MountPointFactoryId} }); - TableFormatter.Print(SettingsLoader.Components.OfType(), "(No Items)", " ", '-', new Dictionary> + TableFormatter.Print(SettingsLoader.Components.OfType(), LocalizableStrings.NoItems, " ", '-', new Dictionary> { - {"Mount Point Factories", x => x.Id}, - {"Type", x => x.GetType().FullName}, - {"Assembly", x => x.GetType().GetTypeInfo().Assembly.FullName} + {LocalizableStrings.MountPointFactories, x => x.Id}, + {LocalizableStrings.Type, x => x.GetType().FullName}, + {LocalizableStrings.Assembly, x => x.GetType().GetTypeInfo().Assembly.FullName} }); - TableFormatter.Print(SettingsLoader.Components.OfType(), "(No Items)", " ", '-', new Dictionary> + TableFormatter.Print(SettingsLoader.Components.OfType(), LocalizableStrings.NoItems, " ", '-', new Dictionary> { - {"Generators", x => x.Id}, - {"Type", x => x.GetType().FullName}, - {"Assembly", x => x.GetType().GetTypeInfo().Assembly.FullName} + {LocalizableStrings.Generators, x => x.Id}, + {LocalizableStrings.Type, x => x.GetType().FullName}, + {LocalizableStrings.Assembly, x => x.GetType().GetTypeInfo().Assembly.FullName} }); } @@ -560,12 +557,12 @@ namespace Microsoft.DotNet.Tools.New3 Reporter.Output.WriteLine(templateInfo.Name); if (!string.IsNullOrWhiteSpace(templateInfo.Author)) { - Reporter.Output.WriteLine($"Author: {templateInfo.Author}"); + Reporter.Output.WriteLine(string.Format(LocalizableStrings.Author, templateInfo.Author)); } if (!string.IsNullOrWhiteSpace(templateInfo.Description)) { - Reporter.Output.WriteLine($"Description: {templateInfo.Description}"); + Reporter.Output.WriteLine(string.Format(LocalizableStrings.Description, templateInfo.Description)); } ITemplate template = SettingsLoader.LoadTemplate(templateInfo); @@ -584,14 +581,15 @@ namespace Microsoft.DotNet.Tools.New3 { HelpFormatter formatter = new HelpFormatter(filteredParams, 2, null, true); - formatter.DefineColumn(delegate (ITemplateParameter param) - { - // the key is guaranteed to exist - IList variants = app.CanonicalToVariantsTemplateParamMap[param.Name]; - string options = string.Join("|", variants.Reverse()); - return " " + options; - }, - "Options:" + formatter.DefineColumn( + param => + { + // the key is guaranteed to exist + IList variants = app.CanonicalToVariantsTemplateParamMap[param.Name]; + string options = string.Join("|", variants.Reverse()); + return " " + options; + }, + LocalizableStrings.Options ); formatter.DefineColumn(delegate (ITemplateParameter param) @@ -617,13 +615,13 @@ namespace Microsoft.DotNet.Tools.New3 && !string.IsNullOrEmpty(param.DefaultValue) && !string.Equals(param.DefaultValue, resolvedValue)) { - displayValue.AppendLine("Configured Value: " + resolvedValue); + displayValue.AppendLine(string.Format(LocalizableStrings.ConfiguredValue, resolvedValue)); } } if (!string.IsNullOrEmpty(param.DefaultValue)) { - displayValue.AppendLine("Default: " + param.DefaultValue); + displayValue.AppendLine(string.Format(LocalizableStrings.DefaultValue, param.DefaultValue)); } return displayValue.ToString(); @@ -635,7 +633,7 @@ namespace Microsoft.DotNet.Tools.New3 } else { - Reporter.Output.WriteLine(" (No Parameters)"); + Reporter.Output.WriteLine(LocalizableStrings.NoParameters); } } }