Skip to content

Commit b6aad56

Browse files
Merge pull request #1464 from sillsdev/DariLang
Work around Windows CultureInfo change for Dari (prs) (#1464)
2 parents 27d8f20 + 843126a commit b6aad56

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,12 @@ jobs:
7171
timeout-minutes: 5
7272

7373
- name: Start Windows Audio Service
74-
run: net start audiosrv
7574
shell: powershell
75+
run: |
76+
$svc = Get-Service -Name "audiosrv"
77+
if ($svc.Status -ne "Running") {
78+
net start audiosrv
79+
}
7680
7781
# there are cases where this will fail and we want to know about it
7882
# so we don't use continue-on-error, but we still want to publish the results

SIL.WritingSystems.Tests/IetfLanguageTagTests.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,8 @@ public void IsScriptImplied_ReturnsExpectedResults(string tag, bool expectedResu
920920
}
921921

922922
#region GetLocalizedLanguageName
923+
const string kIetfLanguageCodeWhichWindowsDoesntKnowAbout = "tlh"; // Happens to be Klingon
924+
923925
[TestCase("en", "en", ExpectedResult = "English")]
924926
[TestCase("en-Latn-US", "en", ExpectedResult = "English")]
925927
[TestCase("en-x-etic", "en-GB", ExpectedResult = "English")]
@@ -932,8 +934,10 @@ public void IsScriptImplied_ReturnsExpectedResults(string tag, bool expectedResu
932934
[TestCase("zh-CN", "en", ExpectedResult = "Chinese (Simplified)")]
933935
[TestCase("pbu", "pbu", ExpectedResult = "پښتو")]
934936
[TestCase("pbu", "tpi", ExpectedResult = "پښتو")]
937+
[TestCase("pbu", kIetfLanguageCodeWhichWindowsDoesntKnowAbout, ExpectedResult = "پښتو")]
935938
[TestCase("prs", "en", ExpectedResult = "Dari")]
936939
[TestCase("tpi", "tpi", ExpectedResult = "Tok Pisin")]
940+
[TestCase("tpi", kIetfLanguageCodeWhichWindowsDoesntKnowAbout, ExpectedResult = "Tok Pisin")]
937941
[TestCase("es", "tpi", ExpectedResult = "español")]
938942
[TestCase("es", "fr", "español", ExpectedResult = "espagnol")]
939943
[TestCase("es", "de", "español", ExpectedResult = "Spanisch")]
@@ -953,6 +957,7 @@ public void IsScriptImplied_ReturnsExpectedResults(string tag, bool expectedResu
953957
// version does not actually appear on that Wikipedia page.
954958
[TestCase("prs", "prs", /*"درى",*/ ExpectedResult = "دری")]
955959
[TestCase("prs", "fr", /*"درى",*/ ExpectedResult = "دری")]
960+
[TestCase("prs", kIetfLanguageCodeWhichWindowsDoesntKnowAbout, /*"درى",*/ ExpectedResult = "دری")]
956961
public string GetLocalizedLanguageName_Valid_GetsNameInTargetLanguageOrNativeAsFallback(
957962
string tag, string uiTag, string acceptableFallback = null)
958963
{

SIL.WritingSystems/IetfLanguageTag.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,15 @@ public static string GetLocalizedLanguageName(string languageTag, string uiLangu
13131313
return "Chinese (Simplified)";
13141314
}
13151315

1316+
// Starting some time around Sept 2025, Windows started returning the "fa" culture
1317+
// for CultureInfo.GetCultureInfo("prs"). We actually want to return Dari in that case.
1318+
if (generalCode == "prs")
1319+
{
1320+
if (uiLanguageCode == "en")
1321+
return "Dari";
1322+
return "دری";
1323+
}
1324+
13161325
if (UseICUForLanguageNames)
13171326
{
13181327
var name = GetLocalizedLanguageNameFromIcu(generalCode, uiLanguageCode);
@@ -1404,6 +1413,12 @@ public static string GetNativeLanguageNameWithEnglishSubtitle(string code)
14041413
{
14051414
// englishNameSuffix is always an empty string if we don't need it.
14061415
string englishNameSuffix = Empty;
1416+
1417+
// Starting some time around Sept 2025, Windows started returning the "fa" culture
1418+
// for CultureInfo.GetCultureInfo("prs"). We actually want to return Dari in that case.
1419+
if (generalCode == "prs")
1420+
return "دری (Dari)";
1421+
14071422
var ci = CultureInfo.GetCultureInfo(generalCode); // this may throw or produce worthless empty object
14081423
if (NeedEnglishSuffixForLanguageName(ci))
14091424
englishNameSuffix = $" ({GetManuallyOverriddenEnglishNameIfNeeded(code, ()=>ci.EnglishName)})";

0 commit comments

Comments
 (0)