Skip to content

Commit

Permalink
Update the version error message to LocalizableStrings
Browse files Browse the repository at this point in the history
  • Loading branch information
JL03-Yue committed Nov 7, 2023
1 parent 774234d commit 34bd038
Show file tree
Hide file tree
Showing 15 changed files with 353 additions and 9 deletions.
15 changes: 15 additions & 0 deletions src/Cli/dotnet/NugetPackageDownloader/LocalizableStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,19 @@
<data name="FailedToMapSourceUnderPackageSourceMapping" xml:space="preserve">
<value>Package Source Mapping is enabled, but no source mapped under the specified package ID: {0}. See the documentation for Package Source Mapping at https://aka.ms/nuget-package-source-mapping for more details.</value>
</data>
<data name="PackageVersionDescriptionDefault" xml:space="preserve">
<value>A version of {0} of package {1}</value>
</data>
<data name="PackageVersionDescriptionForExactVersionMatch" xml:space="preserve">
<value>Version {0} of package {1}</value>
</data>
<data name="PackageVersionDescriptionForVersionWithLowerAndUpperBounds" xml:space="preserve">
<value>A version between {0} and {1} of package {2}</value>
</data>
<data name="PackageVersionDescriptionForVersionWithLowerBound" xml:space="preserve">
<value>A version higher than {0} of package {1}</value>
</data>
<data name="PackageVersionDescriptionForVersionWithUpperBound" xml:space="preserve">
<value>A version less than {0} of package {1}</value>
</data>
</root>
22 changes: 13 additions & 9 deletions src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -463,25 +463,29 @@ private string GenerateVersionRangeErrorDescription(string packageIdentifier, Ve
{
return $"{packageIdentifier}";
}
else if(versionRange.HasLowerAndUpperBounds && versionRange.MinVersion == versionRange.MaxVersion)
else if (versionRange.HasLowerAndUpperBounds && versionRange.MinVersion == versionRange.MaxVersion)
{
return $"Version {versionRange.MinVersion} of package {packageIdentifier}";
return string.Format(LocalizableStrings.PackageVersionDescriptionForExactVersionMatch,
versionRange.MinVersion, packageIdentifier);
}
else if(versionRange.HasLowerAndUpperBounds)
else if (versionRange.HasLowerAndUpperBounds)
{
return $"A version between {versionRange.MinVersion} and {versionRange.MaxVersion} of package {packageIdentifier}";
return string.Format(LocalizableStrings.PackageVersionDescriptionForVersionWithLowerAndUpperBounds,
versionRange.MinVersion, versionRange.MaxVersion, packageIdentifier);
}
else if(versionRange.HasLowerBound)
else if (versionRange.HasLowerBound)
{
return $"A version higher than {versionRange.MinVersion} of package {packageIdentifier}";
return string.Format(LocalizableStrings.PackageVersionDescriptionForVersionWithLowerBound,
versionRange.MinVersion, packageIdentifier);
}
else if(versionRange.HasUpperBound)
else if (versionRange.HasUpperBound)
{
return $"A version less than {versionRange.MaxVersion} of package {packageIdentifier}";
return string.Format(LocalizableStrings.PackageVersionDescriptionForVersionWithUpperBound,
versionRange.MaxVersion, packageIdentifier);
}

// Default message if the format doesn't match any of the expected cases
return $"A version of {versionRange} of package {packageIdentifier}";
return string.Format(LocalizableStrings.PackageVersionDescriptionDefault, versionRange, packageIdentifier);
}

private async Task<(PackageSource, IPackageSearchMetadata)> GetLatestVersionInternalAsync(
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 34bd038

Please sign in to comment.