Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
Expand Down Expand Up @@ -290,7 +291,7 @@ private string GetFilePath()

fileName = Path.GetFileNameWithoutExtension(fileName);

CultureInfo culture = null;
CultureInfo culture;
if (_uiculture == null)
{
culture = CultureInfo.CurrentUICulture;
Expand All @@ -307,19 +308,33 @@ private string GetFilePath()
}
}

CultureInfo currentCulture = culture;
List<CultureInfo> cultureList = new List<CultureInfo> { culture };
if (_uiculture == null && culture.Name != "en-US")
{
// .NET 4.8 presents en-US as a parent of any current culture when accessed via the CurrentUICulture
// property.
//
// This feature is not present when GetCultureInfo is called, therefore this fallback change only
// applies when the UICulture parameter is not supplied.
cultureList.Add(CultureInfo.GetCultureInfo("en-US"));
}

string filePath;
string fullFileName = fileName + ".psd1";
while (currentCulture != null && !string.IsNullOrEmpty(currentCulture.Name))
foreach (CultureInfo cultureToTest in cultureList)
{
filePath = Path.Combine(dir, currentCulture.Name, fullFileName);

if (File.Exists(filePath))
CultureInfo currentCulture = cultureToTest;
while (currentCulture != null && !string.IsNullOrEmpty(currentCulture.Name))
{
return filePath;
}
filePath = Path.Combine(dir, currentCulture.Name, fullFileName);

currentCulture = currentCulture.Parent;
if (File.Exists(filePath))
{
return filePath;
}

currentCulture = currentCulture.Parent;
}
}

filePath = Path.Combine(dir, fullFileName);
Expand Down
181 changes: 0 additions & 181 deletions test/powershell/Language/Scripting/I18n.Tests.ps1

This file was deleted.

5 changes: 0 additions & 5 deletions test/powershell/Language/Scripting/I18n.Tests_fallback.psd1

This file was deleted.

Loading