Skip to content

Commit

Permalink
fix(preferences): Fix language list sorting on preferences page
Browse files Browse the repository at this point in the history
  • Loading branch information
QHivert committed Aug 4, 2023
1 parent 528d178 commit f5f74f7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 2 additions & 0 deletions SoObjects/SOGo/SOGoSystemDefaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ static const NSString *kDisableSharingCalendar = @"Calendar";
- (NSString *) pageTitle;
- (NSString *) helpURL;

NSComparisonResult languageSort(id el1, id el2, void *context);

- (NSArray *) supportedLanguages;
- (NSString *) loginSuffix;

Expand Down
10 changes: 10 additions & 0 deletions SoObjects/SOGo/SOGoSystemDefaults.m
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,16 @@ - (NSString *) helpURL
return [self stringForKey: @"SOGoHelpURL"];
}

NSComparisonResult languageSort(id el1, id el2, void *context)
{
NSString *t1, *t2;

t1 = [context labelForKey: el1];
t2 = [context labelForKey: el2];

return [t1 compare: t2 options: NSCaseInsensitiveSearch];
}

- (NSArray *) supportedLanguages
{
static NSArray *supportedLanguages = nil;
Expand Down
9 changes: 0 additions & 9 deletions UI/MainUI/SOGoRootPage.m
Original file line number Diff line number Diff line change
Expand Up @@ -659,15 +659,6 @@ - (NSString *) localizedLanguage
return [self labelForKey: [self language]];
}

NSComparisonResult languageSort(id el1, id el2, void *context)
{
NSString *t1, *t2;

t1 = [context labelForKey: el1];
t2 = [context labelForKey: el2];

return [t1 compare: t2 options: NSCaseInsensitiveSearch];
}

- (NSArray *) languages
{
Expand Down
3 changes: 2 additions & 1 deletion UI/PreferencesUI/UIxPreferences.m
Original file line number Diff line number Diff line change
Expand Up @@ -1129,12 +1129,13 @@ - (BOOL) shouldDisplayPasswordChange
userCanChangePassword];
}


//
// Used by wox template
//
- (NSArray *) languages
{
return [[SOGoSystemDefaults sharedSystemDefaults] supportedLanguages];
return [[[SOGoSystemDefaults sharedSystemDefaults] supportedLanguages] sortedArrayUsingFunction: languageSort context: self];
}

//
Expand Down

0 comments on commit f5f74f7

Please sign in to comment.