Skip to content

Commit

Permalink
Merge pull request #8269 from dotnet/merge/release/8.0.3xx-to-release…
Browse files Browse the repository at this point in the history
…/8.0.4xx

[automated] Merge branch 'release/8.0.3xx' => 'release/8.0.4xx'
  • Loading branch information
Forgind authored Aug 8, 2024
2 parents acec844 + fc472f2 commit 3e4419f
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,14 @@ internal Task ValidateAsync(ValidationScope scope, CancellationToken cancellatio
{
string filename = locFile.Name;
string localeStr = filename.Substring(LocalizationFilePrefix.Length, filename.Length - LocalizationFilePrefix.Length - LocalizationFileExtension.Length);
CultureInfo? locale = null;

CultureInfo? locale = CultureInfo.GetCultures(CultureTypes.AllCultures).FirstOrDefault(c => c.Name.Equals(localeStr, StringComparison.OrdinalIgnoreCase));
if (locale == null)
try
{
// PERF: Avoid calling CultureInfo.GetCultures and searching the results as it heavily allocates on each invocation.
locale = CultureInfo.GetCultureInfo(localeStr);
}
catch (CultureNotFoundException)
{
Logger.LogWarning(LocalizableStrings.LocalizationModelDeserializer_Error_UnknownLocale, localeStr);
}
Expand Down

0 comments on commit 3e4419f

Please sign in to comment.