Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit e8f7ddd

Browse files
author
William Lee
authored
Localization for tools work so far (#8251)
1 parent 2cfc65a commit e8f7ddd

File tree

60 files changed

+2848
-83
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2848
-83
lines changed

src/dotnet/CommonLocalizableStrings.resx

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,4 +520,68 @@
520520
<data name="NoRestoreDescription" xml:space="preserve">
521521
<value>Does not do an implicit restore when executing the command.</value>
522522
</data>
523+
<data name="CannotBeNullOrWhitespace" xml:space="preserve">
524+
<value>Cannot be null or whitespace.</value>
525+
</data>
526+
<data name="ContainInvalidCharacters" xml:space="preserve">
527+
<value>Contains one or more invalid characters: {0}</value>
528+
</data>
529+
<data name="NuGetConfigurationFileDoesNotExist" xml:space="preserve">
530+
<value>NuGet configuration file {0} does not exist.</value>
531+
</data>
532+
<data name="ToolSettingInvalidRunner" xml:space="preserve">
533+
<value>The tool's settings file has non "dotnet" as runner.</value>
534+
</data>
535+
<data name="ToolSettingMoreThanOneCommand" xml:space="preserve">
536+
<value>The tool's settings file has more than one command defined.</value>
537+
</data>
538+
<data name="ToolSettingsContainError" xml:space="preserve">
539+
<value>The tool's settings file contains error.
540+
{0}</value>
541+
</data>
542+
<data name="ToolSettingsInvalidXml" xml:space="preserve">
543+
<value>The tool's settings file is invalid xml.
544+
{0}</value>
545+
</data>
546+
<data name="EnvironmentPathLinuxManualInstruction" xml:space="preserve">
547+
<value>Cannot find the tools executable path. Please ensure {0} is added to your PATH.
548+
If you are using bash. You can do this by running the following command:
549+
550+
cat &lt;&lt; EOF &gt;&gt; ~/.bash_profile
551+
# Add .NET Core SDK tools
552+
export PATH="$PATH:{1}"
553+
EOF</value>
554+
</data>
555+
<data name="EnvironmentPathLinuxNeedLogout" xml:space="preserve">
556+
<value>Since you just installed the .NET Core SDK, you will need to logout or restart your session before running the tool you installed.</value>
557+
</data>
558+
<data name="EnvironmentPathOSXManualInstruction" xml:space="preserve">
559+
<value>Cannot find the tools executable path. Please ensure {0} is added to your PATH.
560+
If you are using bash, You can do this by running the following command:
561+
562+
cat &lt;&lt; EOF &gt;&gt; ~/.bash_profile
563+
# Add .NET Core SDK tools
564+
export PATH="$PATH:{1}"
565+
EOF</value>
566+
</data>
567+
<data name="EnvironmentPathOSXNeedReopen" xml:space="preserve">
568+
<value>Since you just installed the .NET Core SDK, you will need to reopen terminal before running the tool you installed.</value>
569+
</data>
570+
<data name="EnvironmentPathWindowsManualInstruction" xml:space="preserve">
571+
<value>Cannot find the tools executable path. Please ensure {0} is added to your PATH.
572+
You can do this by running the following command:
573+
574+
setx PATH "%PATH%;{1}"</value>
575+
</data>
576+
<data name="EnvironmentPathWindowsNeedReopen" xml:space="preserve">
577+
<value>Since you just installed the .NET Core SDK, you will need to reopen the Command Prompt window before running the tool you installed.</value>
578+
</data>
579+
<data name="FailInstallToolPermission" xml:space="preserve">
580+
<value>Failed to change permission:
581+
Error: {0}
582+
Output: {1}</value>
583+
</data>
584+
<data name="FailInstallToolSameName" xml:space="preserve">
585+
<value>Failed to install tool {0}. A command with the same name already exists.</value>
586+
</data>
523587
</root>

src/dotnet/ShellShim/LinuxEnvironmentPath.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Linq;
66
using Microsoft.DotNet.Cli.Utils;
77
using Microsoft.DotNet.Configurer;
8+
using Microsoft.DotNet.Tools;
89
using Microsoft.Extensions.EnvironmentAbstractions;
910

1011
namespace Microsoft.DotNet.ShellShim
@@ -67,18 +68,15 @@ public void PrintAddPathInstructionIfPathDoesNotExist()
6768
if (_fileSystem.Exists(_profiledDotnetCliToolsPath))
6869
{
6970
_reporter.WriteLine(
70-
"Since you just installed the .NET Core SDK, you will need to logout or restart your session before running the tool you installed.");
71+
CommonLocalizableStrings.EnvironmentPathLinuxNeedLogout);
7172
}
7273
else
7374
{
7475
// similar to https://code.visualstudio.com/docs/setup/mac
7576
_reporter.WriteLine(
76-
$"Cannot find the tools executable path. Please ensure {_packageExecutablePath.Path} is added to your PATH.{Environment.NewLine}" +
77-
$"If you are using bash. You can do this by running the following command:{Environment.NewLine}{Environment.NewLine}" +
78-
$"cat << EOF >> ~/.bash_profile{Environment.NewLine}" +
79-
$"# Add .NET Core SDK tools{Environment.NewLine}" +
80-
$"export PATH=\"$PATH:{_packageExecutablePath.Path}\"{Environment.NewLine}" +
81-
$"EOF");
77+
string.Format(
78+
CommonLocalizableStrings.EnvironmentPathLinuxManualInstruction,
79+
_packageExecutablePath.Path, _packageExecutablePath.Path));
8280
}
8381
}
8482
}

src/dotnet/ShellShim/OsxEnvironmentPath.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Linq;
66
using Microsoft.DotNet.Cli.Utils;
77
using Microsoft.DotNet.Configurer;
8+
using Microsoft.DotNet.Tools;
89
using Microsoft.Extensions.EnvironmentAbstractions;
910

1011
namespace Microsoft.DotNet.ShellShim
@@ -67,18 +68,15 @@ public void PrintAddPathInstructionIfPathDoesNotExist()
6768
if (_fileSystem.Exists(PathDDotnetCliToolsPath))
6869
{
6970
_reporter.WriteLine(
70-
"Since you just installed the .NET Core SDK, you will need to reopen terminal before running the tool you installed.");
71+
CommonLocalizableStrings.EnvironmentPathOSXNeedReopen);
7172
}
7273
else
7374
{
7475
// similar to https://code.visualstudio.com/docs/setup/mac
7576
_reporter.WriteLine(
76-
$"Cannot find the tools executable path. Please ensure {_packageExecutablePath.Path} is added to your PATH.{Environment.NewLine}" +
77-
$"If you are using bash, You can do this by running the following command:{Environment.NewLine}{Environment.NewLine}" +
78-
$"cat << EOF >> ~/.bash_profile{Environment.NewLine}" +
79-
$"# Add .NET Core SDK tools{Environment.NewLine}" +
80-
$"export PATH=\"$PATH:{_packageExecutablePath.Path}\"{Environment.NewLine}" +
81-
$"EOF");
77+
string.Format(
78+
CommonLocalizableStrings.EnvironmentPathOSXManualInstruction,
79+
_packageExecutablePath.Path, _packageExecutablePath.Path));
8280
}
8381
}
8482
}

src/dotnet/ShellShim/ShellShimMaker.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Runtime.InteropServices;
77
using System.Text;
88
using Microsoft.DotNet.Cli.Utils;
9+
using Microsoft.DotNet.Tools;
910
using Microsoft.Extensions.EnvironmentAbstractions;
1011

1112
namespace Microsoft.DotNet.ShellShim
@@ -47,7 +48,8 @@ public void EnsureCommandNameUniqueness(string shellCommandName)
4748
if (File.Exists(Path.Combine(_pathToPlaceShim, shellCommandName)))
4849
{
4950
throw new GracefulException(
50-
$"Failed to install tool {shellCommandName}. A command with the same name already exists.");
51+
string.Format(CommonLocalizableStrings.FailInstallToolSameName,
52+
shellCommandName));
5153
}
5254
}
5355

@@ -80,9 +82,8 @@ private static void SetUserExecutionPermissionToShimFile(FilePath scriptPath)
8082
if (result.ExitCode != 0)
8183
{
8284
throw new GracefulException(
83-
"Failed to change permission:" +
84-
$"{Environment.NewLine}Error: " + result.StdErr +
85-
$"{Environment.NewLine}Output: " + result.StdOut);
85+
string.Format(CommonLocalizableStrings.FailInstallToolPermission, result.StdErr,
86+
result.StdOut));
8687
}
8788
}
8889
}

src/dotnet/ShellShim/WindowsEnvironmentPath.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.Linq;
66
using Microsoft.DotNet.Cli.Utils;
7+
using Microsoft.DotNet.Tools;
78
using Microsoft.Extensions.EnvironmentAbstractions;
89

910
namespace Microsoft.DotNet.ShellShim
@@ -63,14 +64,14 @@ public void PrintAddPathInstructionIfPathDoesNotExist()
6364
.Contains(_packageExecutablePath))
6465
{
6566
_reporter.WriteLine(
66-
"Since you just installed the .NET Core SDK, you will need to reopen the Command Prompt window before running the tool you installed.");
67+
CommonLocalizableStrings.EnvironmentPathWindowsNeedReopen);
6768
}
6869
else
6970
{
7071
_reporter.WriteLine(
71-
$"Cannot find the tools executable path. Please ensure {_packageExecutablePath} is added to your PATH.{Environment.NewLine}" +
72-
$"You can do this by running the following command:{Environment.NewLine}{Environment.NewLine}" +
73-
$"setx PATH \"%PATH%;{_packageExecutablePath}\"{Environment.NewLine}");
72+
string.Format(
73+
CommonLocalizableStrings.EnvironmentPathWindowsManualInstruction,
74+
_packageExecutablePath, _packageExecutablePath));
7475
}
7576
}
7677
}

src/dotnet/ToolPackage/ToolConfiguration.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System;
55
using System.IO;
6+
using Microsoft.DotNet.Tools;
67

78
namespace Microsoft.DotNet.ToolPackage
89
{
@@ -14,14 +15,14 @@ public ToolConfiguration(
1415
{
1516
if (string.IsNullOrWhiteSpace(commandName))
1617
{
17-
throw new ArgumentNullException(nameof(commandName), "Cannot be null or whitespace");
18+
throw new ArgumentNullException(nameof(commandName), CommonLocalizableStrings.CannotBeNullOrWhitespace);
1819
}
1920

2021
EnsureNoInvalidFilenameCharacters(commandName, nameof(toolAssemblyEntryPoint));
2122

2223
if (string.IsNullOrWhiteSpace(toolAssemblyEntryPoint))
2324
{
24-
throw new ArgumentNullException(nameof(toolAssemblyEntryPoint), "Cannot be null or whitespace");
25+
throw new ArgumentNullException(nameof(toolAssemblyEntryPoint), CommonLocalizableStrings.CannotBeNullOrWhitespace);
2526
}
2627

2728
CommandName = commandName;
@@ -35,7 +36,8 @@ private void EnsureNoInvalidFilenameCharacters(string commandName, string nameOf
3536
{
3637
throw new ArgumentException(
3738
paramName: nameof(nameOfParam),
38-
message: "Contains one or more invalid characters: " + new string(invalidCharactors));
39+
message: string.Format(CommonLocalizableStrings.ContainInvalidCharacters,
40+
new string(invalidCharactors)));
3941
}
4042
}
4143

src/dotnet/ToolPackage/ToolConfigurationDeserializer.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Xml;
77
using System.Xml.Serialization;
88
using Microsoft.DotNet.ToolPackage.ToolConfigurationDeserialization;
9+
using Microsoft.DotNet.Tools;
910

1011
namespace Microsoft.DotNet.ToolPackage
1112
{
@@ -28,21 +29,20 @@ public static ToolConfiguration Deserialize(string pathToXml)
2829
catch (InvalidOperationException e) when (e.InnerException is XmlException)
2930
{
3031
throw new ToolConfigurationException(
31-
$"The tool's settings file is invalid xml. {Environment.NewLine}" +
32-
e.InnerException.Message);
32+
string.Format(CommonLocalizableStrings.ToolSettingsInvalidXml, e.InnerException.Message));
3333
}
3434
}
3535

3636
if (dotNetCliTool.Commands.Length != 1)
3737
{
3838
throw new ToolConfigurationException(
39-
"The tool's settings file has more than one command defined.");
39+
CommonLocalizableStrings.ToolSettingMoreThanOneCommand);
4040
}
4141

4242
if (dotNetCliTool.Commands[0].Runner != "dotnet")
4343
{
4444
throw new ToolConfigurationException(
45-
"The tool's settings file has non \"dotnet\" as runner.");
45+
CommonLocalizableStrings.ToolSettingInvalidRunner);
4646
}
4747

4848
var commandName = dotNetCliTool.Commands[0].Name;
@@ -54,7 +54,9 @@ public static ToolConfiguration Deserialize(string pathToXml)
5454
}
5555
catch (ArgumentException e)
5656
{
57-
throw new ToolConfigurationException($"The tool's settings file contains error {Environment.NewLine}" + e.Message);
57+
throw new ToolConfigurationException(
58+
string.Format(CommonLocalizableStrings.ToolSettingsContainError,
59+
e.Message));
5860
}
5961
}
6062
}

src/dotnet/ToolPackage/ToolPackageObtainer.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.IO;
44
using System.Linq;
55
using System.Xml.Linq;
6+
using Microsoft.DotNet.Tools;
67
using Microsoft.Extensions.EnvironmentAbstractions;
78

89
namespace Microsoft.DotNet.ToolPackage
@@ -47,7 +48,9 @@ public ToolConfigurationAndExecutableDirectory ObtainAndReturnExecutablePath(
4748
{
4849
if (!File.Exists(nugetconfig.Value.Value))
4950
{
50-
throw new PackageObtainException($"NuGet configuration file {Path.GetFullPath(nugetconfig.Value.Value)} does not exist.");
51+
throw new PackageObtainException(
52+
string.Format(CommonLocalizableStrings.NuGetConfigurationFileDoesNotExist,
53+
Path.GetFullPath(nugetconfig.Value.Value)));
5154
}
5255
}
5356

src/dotnet/commands/dotnet-help/HelpUsageText.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ internal static class HelpUsageText
2828
msbuild {LocalizableStrings.MsBuildDefinition}
2929
vstest {LocalizableStrings.VsTestDefinition}
3030
store {LocalizableStrings.StoreDefinition}
31+
install {LocalizableStrings.InstallDefinition}
3132
help {LocalizableStrings.HelpDefinition}
3233
3334
{LocalizableStrings.CommonOptions}:

src/dotnet/commands/dotnet-help/LocalizableStrings.resx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,4 +267,7 @@
267267
<data name="AdditionalDeps" xml:space="preserve">
268268
<value>Path to additional deps.json file.</value>
269269
</data>
270-
</root>
270+
<data name="InstallDefinition" xml:space="preserve">
271+
<value>Add item to development environment.</value>
272+
</data>
273+
</root>

0 commit comments

Comments
 (0)