Localize Migration

This commit is contained in:
Piotr Puszkiewicz 2016-12-16 19:45:43 -08:00 committed by Livar Cunha
parent e7487cab97
commit 5cfed1a787
7 changed files with 103 additions and 33 deletions

View file

@ -137,7 +137,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration
{
if (IsMigrated(migrationSettings, migrationRuleInputs))
{
MigrationTrace.Instance.WriteLine($"{nameof(ProjectMigrator)}: Skip migrating {migrationSettings.ProjectDirectory}, it is already migrated.");
MigrationTrace.Instance.WriteLine(String.Format(LocalizableStrings.SkipMigrationAlreadyMigrated, nameof(ProjectMigrator), migrationSettings.ProjectDirectory));
return new ProjectMigrationReport(migrationSettings.ProjectDirectory, projectName, skipped: true);
}
@ -175,7 +175,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration
var templateMSBuildProject = migrationSettings.MSBuildProjectTemplate;
if (templateMSBuildProject == null)
{
throw new Exception("Expected non-null MSBuildProjectTemplate in MigrationSettings");
throw new Exception(LocalizableStrings.NullMSBuildProjectTemplateError);
}
var propertyGroup = templateMSBuildProject.AddPropertyGroup();
@ -193,7 +193,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration
{
if (!projectContexts.Any())
{
MigrationErrorCodes.MIGRATE1013($"The project.json specifies no target frameworks in {projectDirectory}").Throw();
MigrationErrorCodes.MIGRATE1013(String.Format(LocalizableStrings.MIGRATE1013Arg, projectDirectory)).Throw();
}
var defaultProjectContext = projectContexts.First();
@ -202,7 +202,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration
if (diagnostics.Any())
{
MigrationErrorCodes.MIGRATE1011(
$"{projectDirectory}{Environment.NewLine}{string.Join(Environment.NewLine, diagnostics.Select(d => FormatDiagnosticMessage(d)))}")
String.Format("{0}{1}{2}", projectDirectory, Environment.NewLine, string.Join(Environment.NewLine, diagnostics.Select(d => FormatDiagnosticMessage(d)))))
.Throw();
}
@ -212,13 +212,13 @@ namespace Microsoft.DotNet.ProjectJsonMigration
if (!compilerName.Equals("csc", StringComparison.OrdinalIgnoreCase))
{
MigrationErrorCodes.MIGRATE20013(
$"Cannot migrate project {defaultProjectContext.ProjectFile.ProjectFilePath} using compiler {compilerName}").Throw();
String.Format(LocalizableStrings.CannotMigrateProjectWithCompilerError, defaultProjectContext.ProjectFile.ProjectFilePath, compilerName)).Throw();
}
}
private string FormatDiagnosticMessage(DiagnosticMessage d)
{
return $"{d.Message} (line: {d.StartLine}, file: {d.SourceFilePath})";
return String.Format(LocalizableStrings.DiagnosticMessageTemplate, d.Message, d.StartLine, d.SourceFilePath);
}
private void SetupOutputDirectory(string projectDirectory, string outputDirectory)