Skip to content

Commit

Permalink
Merge pull request #1155 from oxygen-dioxide/localizedsort
Browse files Browse the repository at this point in the history
Fix OpenUtau failed to search singers when the user runs OpenUtau for the first time
  • Loading branch information
stakira authored Jun 9, 2024
2 parents e2b36cf + a9153d7 commit ddeccba
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions OpenUtau.Core/Util/LocalizedSort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,17 @@ public int Compare(string x, string y) {
public static class LocalizedSort {
public static IEnumerable<T> LocalizedOrderBy<T>(this IEnumerable<T> source, Func<T, string> selector) {
var sortingOrder = Preferences.Default.SortingOrder;
if(sortingOrder == String.Empty) {
sortingOrder = Preferences.Default.Language;
CultureInfo culture;
if(sortingOrder == null) {
//Follow the display language
culture = CultureInfo.GetCultureInfo(Preferences.Default.Language);
} else if(sortingOrder == String.Empty){
//Don't translate
culture = CultureInfo.InvariantCulture;
} else {
culture = CultureInfo.GetCultureInfo(sortingOrder);
}
var comparer = new LocalizedComparer(CultureInfo.GetCultureInfo(sortingOrder));
var comparer = new LocalizedComparer(culture);
return source.OrderBy(selector, comparer);
}
}
Expand Down

0 comments on commit ddeccba

Please sign in to comment.