Merge pull request #5618 from jonsequitur/remove-incorrect-localizations

Remove incorrect localizations
This commit is contained in:
Piotr Puszkiewicz 2017-02-16 11:05:36 -08:00 committed by GitHub
commit d3d6bdebd1
11 changed files with 49 additions and 73 deletions

View file

@ -48,6 +48,7 @@ namespace Microsoft.DotNet.Cli.Utils
}; };
public static readonly string MSBUILD_EXE_PATH = "MSBUILD_EXE_PATH"; public static readonly string MSBUILD_EXE_PATH = "MSBUILD_EXE_PATH";
public static readonly string MSBuildExtensionsPath = "MSBuildExtensionsPath";
public static readonly string ProjectArgumentName = "<PROJECT>"; public static readonly string ProjectArgumentName = "<PROJECT>";
public static readonly string SolutionArgumentName = "<SLN_FILE>"; public static readonly string SolutionArgumentName = "<SLN_FILE>";

View file

@ -385,11 +385,11 @@ namespace Microsoft.DotNet.Cli.CommandLine
if (cmd != this && cmd.Arguments.Any()) if (cmd != this && cmd.Arguments.Any())
{ {
var args = string.Join(" ", cmd.Arguments.Select(arg => arg.Name)); var args = string.Join(" ", cmd.Arguments.Select(arg => arg.Name));
headerBuilder.Insert(usagePrefixLength, string.Format(LocalizableStrings.UsageItemWithArgs, cmd.Name, args)); headerBuilder.Insert(usagePrefixLength, string.Format(" {0} {1}", cmd.Name, args));
} }
else else
{ {
headerBuilder.Insert(usagePrefixLength, string.Format(LocalizableStrings.UsageItemWithoutArgs, cmd.Name)); headerBuilder.Insert(usagePrefixLength, string.Format(" {0}", cmd.Name));
} }
} }
@ -405,7 +405,7 @@ namespace Microsoft.DotNet.Cli.CommandLine
if (target != null) if (target != null)
{ {
headerBuilder.AppendFormat(LocalizableStrings.CommandItem, commandName); headerBuilder.AppendFormat(" {0}", commandName);
} }
else else
{ {
@ -444,11 +444,10 @@ namespace Microsoft.DotNet.Cli.CommandLine
{ {
if (cmd.Arguments.Any()) if (cmd.Arguments.Any())
{ {
var outputFormat = LocalizableStrings.UsageArgumentItem;
foreach (var arg in cmd.Arguments) foreach (var arg in cmd.Arguments)
{ {
argumentsBuilder.AppendFormat( argumentsBuilder.AppendFormat(
outputFormat, " {0}{1}",
arg.Name.PadRight(maxArgLen + 2), arg.Name.PadRight(maxArgLen + 2),
arg.Description); arg.Description);
argumentsBuilder.AppendLine(); argumentsBuilder.AppendLine();
@ -463,7 +462,7 @@ namespace Microsoft.DotNet.Cli.CommandLine
optionsBuilder.AppendLine(); optionsBuilder.AppendLine();
optionsBuilder.AppendLine(LocalizableStrings.UsageOptionsHeader); optionsBuilder.AppendLine(LocalizableStrings.UsageOptionsHeader);
var maxOptLen = MaxOptionTemplateLength(target.Options); var maxOptLen = MaxOptionTemplateLength(target.Options);
var outputFormat = string.Format(LocalizableStrings.UsageOptionsItem, maxOptLen + 2); var outputFormat = string.Format(" {{0, -{0}}}{{1}}", maxOptLen + 2);
foreach (var opt in target.Options) foreach (var opt in target.Options)
{ {
optionsBuilder.AppendFormat(outputFormat, opt.Template, opt.Description); optionsBuilder.AppendFormat(outputFormat, opt.Template, opt.Description);
@ -478,7 +477,7 @@ namespace Microsoft.DotNet.Cli.CommandLine
commandsBuilder.AppendLine(); commandsBuilder.AppendLine();
commandsBuilder.AppendLine(LocalizableStrings.UsageCommandsHeader); commandsBuilder.AppendLine(LocalizableStrings.UsageCommandsHeader);
var maxCmdLen = MaxCommandLength(target.Commands); var maxCmdLen = MaxCommandLength(target.Commands);
var outputFormat = string.Format(LocalizableStrings.UsageCommandsItem, maxCmdLen + 2); var outputFormat = string.Format(" {{0, -{0}}}{{1}}", maxCmdLen + 2);
foreach (var cmd in target.Commands.OrderBy(c => c.Name)) foreach (var cmd in target.Commands.OrderBy(c => c.Name))
{ {
commandsBuilder.AppendFormat(outputFormat, cmd.Name, cmd.Description); commandsBuilder.AppendFormat(outputFormat, cmd.Name, cmd.Description);
@ -508,7 +507,7 @@ namespace Microsoft.DotNet.Cli.CommandLine
{ {
argumentSeparatorBuilder.AppendLine(); argumentSeparatorBuilder.AppendLine();
argumentSeparatorBuilder.AppendLine(LocalizableStrings.UsageCommandsAdditionalArgsHeader); argumentSeparatorBuilder.AppendLine(LocalizableStrings.UsageCommandsAdditionalArgsHeader);
argumentSeparatorBuilder.AppendLine(String.Format(LocalizableStrings.UsageCommandsAdditionalArgsItem, target.ArgumentSeparatorHelpText)); argumentSeparatorBuilder.AppendLine(String.Format(" {0}", target.ArgumentSeparatorHelpText));
argumentSeparatorBuilder.AppendLine(); argumentSeparatorBuilder.AppendLine();
} }
} }
@ -535,7 +534,7 @@ namespace Microsoft.DotNet.Cli.CommandLine
public string GetFullNameAndVersion() public string GetFullNameAndVersion()
{ {
return ShortVersionGetter == null ? FullName : string.Format(LocalizableStrings.ShortVersionTemplate, FullName, ShortVersionGetter()); return ShortVersionGetter == null ? FullName : string.Format("{0} {1}", FullName, ShortVersionGetter());
} }
public void ShowRootCommandFullNameAndVersion() public void ShowRootCommandFullNameAndVersion()

View file

@ -20,28 +20,18 @@ namespace Microsoft.DotNet.Cli.CommandLine
public const string UsageHeader = "Usage:"; public const string UsageHeader = "Usage:";
public const string UsageItemWithoutArgs = " {0}";
public const string UsageItemWithArgs = " {0} {1}";
public const string UsageArgumentsToken = " [arguments]"; public const string UsageArgumentsToken = " [arguments]";
public const string UsageArgumentsHeader = "Arguments:"; public const string UsageArgumentsHeader = "Arguments:";
public const string UsageArgumentItem = " {0}{1}";
public const string UsageOptionsToken = " [options]"; public const string UsageOptionsToken = " [options]";
public const string UsageOptionsHeader = "Options:"; public const string UsageOptionsHeader = "Options:";
public const string UsageOptionsItem = " {{0, -{0}}}{{1}}";
public const string UsageCommandToken = " [command]"; public const string UsageCommandToken = " [command]";
public const string UsageCommandsHeader = "Commands:"; public const string UsageCommandsHeader = "Commands:";
public const string UsageCommandsItem = " {{0, -{0}}}{{1}}";
public const string UsageCommandsDetailHelp = "Use \"{0} [command] --help\" for more information about a command."; public const string UsageCommandsDetailHelp = "Use \"{0} [command] --help\" for more information about a command.";
public const string UsageCommandArgs = " [args]"; public const string UsageCommandArgs = " [args]";
@ -50,12 +40,6 @@ namespace Microsoft.DotNet.Cli.CommandLine
public const string UsageCommandsAdditionalArgsHeader = "Additional Arguments:"; public const string UsageCommandsAdditionalArgsHeader = "Additional Arguments:";
public const string UsageCommandsAdditionalArgsItem = " {0}";
public const string CommandItem = " {0}";
public const string ShortVersionTemplate = "{0} {1}";
public const string InvalidTemplateError = "Invalid template pattern '{0}'"; public const string InvalidTemplateError = "Invalid template pattern '{0}'";
public const string MSBuildAdditionalArgsHelpText = "Any extra options that should be passed to MSBuild. See 'dotnet msbuild -h' for available options."; public const string MSBuildAdditionalArgsHelpText = "Any extra options that should be passed to MSBuild. See 'dotnet msbuild -h' for available options.";

View file

@ -46,8 +46,8 @@ namespace Microsoft.DotNet.Tools.Add.PackageReference
command._versionOption = command.Option( command._versionOption = command.Option(
$"-v|--version <{LocalizableStrings.CmdVersion}>", $"-v|--version <{LocalizableStrings.CmdVersion}>",
LocalizableStrings.CmdVersionDescription, description: LocalizableStrings.CmdVersionDescription,
CommandOptionType.SingleValue); optionType: CommandOptionType.SingleValue);
command._frameworkOption = command.Option( command._frameworkOption = command.Option(
$"-f|--framework <{LocalizableStrings.CmdFramework}>", $"-f|--framework <{LocalizableStrings.CmdFramework}>",

View file

@ -1,9 +0,0 @@
namespace Microsoft.DotNet.Tools.RestoreProjectJson
{
internal class LocalizableStrings
{
public const string AddMinimal = "minimal";
public const string AddRestore = "restore";
}
}

View file

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Microsoft.DotNet.Tools;
namespace Microsoft.DotNet.Tools.RestoreProjectJson namespace Microsoft.DotNet.Tools.RestoreProjectJson
{ {
@ -13,9 +12,9 @@ namespace Microsoft.DotNet.Tools.RestoreProjectJson
if (!args.Any(s => s.Equals("--verbosity", StringComparison.OrdinalIgnoreCase) || s.Equals("-v", StringComparison.OrdinalIgnoreCase))) if (!args.Any(s => s.Equals("--verbosity", StringComparison.OrdinalIgnoreCase) || s.Equals("-v", StringComparison.OrdinalIgnoreCase)))
{ {
prefixArgs.Add("--verbosity"); prefixArgs.Add("--verbosity");
prefixArgs.Add(LocalizableStrings.AddMinimal); prefixArgs.Add("minimal");
} }
prefixArgs.Add(LocalizableStrings.AddRestore); prefixArgs.Add("restore");
var nugetApp = new NuGetForwardingApp(Enumerable.Concat(prefixArgs, args)); var nugetApp = new NuGetForwardingApp(Enumerable.Concat(prefixArgs, args));

View file

@ -16,15 +16,7 @@
public const string RunCommandException = "The build failed. Please fix the build errors and run again."; public const string RunCommandException = "The build failed. Please fix the build errors and run again.";
public const string RunCommandMSBuildExtensionsPath = "MSBuildExtensionsPath"; public const string RunCommandExceptionUnableToRun = "Unable to run your project\nPlease ensure you have a runnable project type and ensure '{0}' supports this project.\nThe current {1} is '{2}'";
public const string RunCommandConfiguration = "Configuration";
public const string RunCommandTargetFramework = "TargetFramework";
public const string RunCommandProjectInstance = "RunCommand";
public const string RunCommandOutputType = "OutputType";
public const string RunCommandExceptionUnableToRun1 = "Unable to run your project."; public const string RunCommandExceptionUnableToRun1 = "Unable to run your project.";
@ -32,10 +24,6 @@
public const string RunCommandExceptionUnableToRun3 = "The current OutputType is "; public const string RunCommandExceptionUnableToRun3 = "The current OutputType is ";
public const string RunCommandRunArguments = "RunArguments";
public const string RunCommandRunWorkingDirectory = "RunWorkingDirectory";
public const string RunCommandInvalidOperationException1 = "Couldn't find a project to run. Ensure a project exists in "; public const string RunCommandInvalidOperationException1 = "Couldn't find a project to run. Ensure a project exists in ";
public const string RunCommandInvalidOperationException2 = "Or pass the path to the project using --project"; public const string RunCommandInvalidOperationException2 = "Or pass the path to the project using --project";

View file

@ -67,36 +67,38 @@ namespace Microsoft.DotNet.Tools.Run
private ICommand GetRunCommand() private ICommand GetRunCommand()
{ {
Dictionary<string, string> globalProperties = new Dictionary<string, string>() var globalProperties = new Dictionary<string, string>
{ {
{ LocalizableStrings.RunCommandMSBuildExtensionsPath, AppContext.BaseDirectory } { Constants.MSBuildExtensionsPath, AppContext.BaseDirectory }
}; };
if (!string.IsNullOrWhiteSpace(Configuration)) if (!string.IsNullOrWhiteSpace(Configuration))
{ {
globalProperties.Add(LocalizableStrings.RunCommandConfiguration, Configuration); globalProperties.Add("Configuration", Configuration);
} }
if (!string.IsNullOrWhiteSpace(Framework)) if (!string.IsNullOrWhiteSpace(Framework))
{ {
globalProperties.Add(LocalizableStrings.RunCommandTargetFramework, Framework); globalProperties.Add("TargetFramework", Framework);
} }
ProjectInstance projectInstance = new ProjectInstance(Project, globalProperties, null); ProjectInstance projectInstance = new ProjectInstance(Project, globalProperties, null);
string runProgram = projectInstance.GetPropertyValue(LocalizableStrings.RunCommandProjectInstance); string runProgram = projectInstance.GetPropertyValue("RunCommand");
if (string.IsNullOrEmpty(runProgram)) if (string.IsNullOrEmpty(runProgram))
{ {
string outputType = projectInstance.GetPropertyValue(LocalizableStrings.RunCommandOutputType); string outputType = projectInstance.GetPropertyValue("OutputType");
throw new GracefulException(string.Join(Environment.NewLine, throw new GracefulException(
LocalizableStrings.RunCommandExceptionUnableToRun1, string.Format(
LocalizableStrings.RunCommandExceptionUnableToRun2, LocalizableStrings.RunCommandExceptionUnableToRun,
$"{LocalizableStrings.RunCommandExceptionUnableToRun3}'{outputType}'.")); "dotnet run",
"OutputType",
outputType));
} }
string runArguments = projectInstance.GetPropertyValue(LocalizableStrings.RunCommandRunArguments); string runArguments = projectInstance.GetPropertyValue("RunArguments");
string runWorkingDirectory = projectInstance.GetPropertyValue(LocalizableStrings.RunCommandRunWorkingDirectory); string runWorkingDirectory = projectInstance.GetPropertyValue("RunWorkingDirectory");
string fullArguments = runArguments; string fullArguments = runArguments;
if (_args.Any()) if (_args.Any())
@ -119,16 +121,15 @@ namespace Microsoft.DotNet.Tools.Run
if (projectFiles.Length == 0) if (projectFiles.Length == 0)
{ {
var project = "--project";
throw new InvalidOperationException( throw new InvalidOperationException(
$"{LocalizableStrings.RunCommandInvalidOperationException1} {directory}." + Environment.NewLine + $"Couldn't find a project to run. Ensure a project exists in {directory}, or pass the path to the project using {project}");
LocalizableStrings.RunCommandInvalidOperationException2)
.DisplayAsError();
} }
else if (projectFiles.Length > 1) else if (projectFiles.Length > 1)
{ {
throw new InvalidOperationException( throw new InvalidOperationException(
$"{LocalizableStrings.RunCommandInvalidOperationException3}'{directory}'{LocalizableStrings.RunCommandInvalidOperationException4}") $"Specify which project file to use because {directory} contains more than one project file.");
.DisplayAsError();
} }
Project = projectFiles[0]; Project = projectFiles[0];

View file

@ -12,7 +12,7 @@ namespace Microsoft.DotNet.Tools.Sln
public const string AppHelpText = "Projects to add or to remove from the solution."; public const string AppHelpText = "Projects to add or to remove from the solution.";
public const string AddAppFullName = ".NET Add project(s) to a solution file Command"; public const string AddAppFullName = ".NET Add project(s) to a solution file Command";
public const string AddSubcommandHelpText = "Add a specified project(s) to the solution."; public const string AddSubcommandHelpText = "Add one or more specified projects to the solution.";
public const string RemoveAppFullName = ".NET Remove project(s) from a solution file Command"; public const string RemoveAppFullName = ".NET Remove project(s) from a solution file Command";
public const string RemoveSubcommandHelpText = "Remove the specified project(s) from the solution. The project is not impacted."; public const string RemoveSubcommandHelpText = "Remove the specified project(s) from the solution. The project is not impacted.";

View file

@ -8,7 +8,7 @@
public const string CmdArgProject = "PROJECT"; public const string CmdArgProject = "PROJECT";
public const string CmdArgDescription = "The project to test, defaults to the current directory."; public const string CmdArgDescription = "The project to test. Defaults to the current directory.";
public const string CmdSettingsFile = "SETTINGS_FILE"; public const string CmdSettingsFile = "SETTINGS_FILE";

View file

@ -9,6 +9,7 @@ using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using Xunit; using Xunit;
using Xunit.Abstractions;
namespace Microsoft.DotNet.Cli.Sln.Add.Tests namespace Microsoft.DotNet.Cli.Sln.Add.Tests
{ {
@ -25,8 +26,14 @@ Options:
-h|--help Show help information -h|--help Show help information
Additional Arguments: Additional Arguments:
Add a specified project(s) to the solution. Add one or more specified projects to the solution.
"; ";
private ITestOutputHelper _output;
public GivenDotnetSlnAdd(ITestOutputHelper output)
{
_output = output;
}
private const string ExpectedSlnFileAfterAddingLibProj = @" private const string ExpectedSlnFileAfterAddingLibProj = @"
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
@ -269,6 +276,12 @@ EndGlobal
.ExecuteWithCapturedOutput(@"sln App.sln add"); .ExecuteWithCapturedOutput(@"sln App.sln add");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be("You must specify at least one project to add."); cmd.StdErr.Should().Be("You must specify at least one project to add.");
_output.WriteLine("[STD OUT]");
_output.WriteLine(cmd.StdOut);
_output.WriteLine("[HelpText]");
_output.WriteLine(HelpText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
} }