Skip to content

Commit

Permalink
fix the error where audio packages doesn't download in some language …
Browse files Browse the repository at this point in the history
…environment #1103
  • Loading branch information
Scighost committed Sep 25, 2024
1 parent 55babc3 commit 736c26f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
21 changes: 21 additions & 0 deletions src/Starward.Core/LanguageUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,25 @@ public static string FilterLanguage(string? lang)
}


public static string FilterAudioLanguage(string? lang)
{
// zh-cn,zh-tw,en-us,de-de,es-es,fr-fr,id-id,it-it,ja-jp,ko-kr,pt-pt,ru-ru,th-th,tr-tr,vi-vn
var low = lang?.ToLower() ?? "";
if (low.Length < 2)
{
low = "..";
}
return low switch
{
_ => low[..2] switch
{
"zh" => "zh-cn",
"ja" => "ja-jp",
"ko" => "ko-kr",
_ => "en-us",
}
};
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private async Task<List<InstallGameItem>> GetAudioPkgVersionsAsync(string prefix
string lang = await GetAudioLanguageAsync();
if (string.IsNullOrWhiteSpace(lang))
{
lang = LanguageUtil.FilterLanguage(CultureInfo.CurrentUICulture.Name);
lang = LanguageUtil.FilterAudioLanguage(CultureInfo.CurrentUICulture.Name);
await SetAudioLanguageAsync(lang);
}
List<InstallGameItem> list = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Starward/Services/Download/InstallGameService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ protected async Task<List<GamePackageFile>> GetAudioPackageFilesFromGameResource
string lang = await GetAudioLanguageAsync();
if (string.IsNullOrWhiteSpace(lang))
{
lang = LanguageUtil.FilterLanguage(CultureInfo.CurrentUICulture.Name);
lang = LanguageUtil.FilterAudioLanguage(CultureInfo.CurrentUICulture.Name);
await SetAudioLanguageAsync(lang);
}
List<GamePackageFile> list = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Starward/Services/Download/ZZZInstallGameService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private async Task<List<InstallGameItem>> GetAudioPkgVersionsAsync(string prefix
string lang = await GetAudioLanguageAsync();
if (string.IsNullOrWhiteSpace(lang))
{
lang = LanguageUtil.FilterLanguage(CultureInfo.CurrentUICulture.Name);
lang = LanguageUtil.FilterAudioLanguage(CultureInfo.CurrentUICulture.Name);
await SetAudioLanguageAsync(lang);
}
List<InstallGameItem> list = [];
Expand Down

0 comments on commit 736c26f

Please sign in to comment.