From e79494c43c271a7073182e791c0df7a976741646 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Mon, 28 Jan 2019 10:04:55 -0500 Subject: [PATCH] Reflect active locale in HTML lang attribute Fixes #4660 --- NEWS | 1 + UI/SOGoUI/UIxComponent.h | 3 ++- UI/SOGoUI/UIxComponent.m | 21 ++++++++++++++++----- UI/Scheduler/UIxCalMainView.m | 14 -------------- UI/Templates/UIxPageFrame.wox | 2 +- 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/NEWS b/NEWS index 65a52a38b..586fbb9c7 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,7 @@ Bug fixes - [web] fixed display of Bcc header (#4642) - [web] fixed refresh of drafts folder when saving a draft - [web] fixed CAS session timeout handling during XHR requests (#4468) + - [web] reflect active locale in HTML lang attribute (#4660) - [core] ignore transparent events in time conflict validation (#4539) - [core] fixed yearly recurrence calculator when starting from previous year diff --git a/UI/SOGoUI/UIxComponent.h b/UI/SOGoUI/UIxComponent.h index a21e70e6b..ffa33cf16 100644 --- a/UI/SOGoUI/UIxComponent.h +++ b/UI/SOGoUI/UIxComponent.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2007-2016 Inverse inc. + Copyright (C) 2007-2019 Inverse inc. This file is part of SOGo @@ -108,6 +108,7 @@ /* locale */ - (NSDictionary *)locale; +- (NSString *) localeCode; /* cached resource filenames */ - (WOResourceManager *) pageResourceManager; diff --git a/UI/SOGoUI/UIxComponent.m b/UI/SOGoUI/UIxComponent.m index c959b4e3b..d21a63845 100644 --- a/UI/SOGoUI/UIxComponent.m +++ b/UI/SOGoUI/UIxComponent.m @@ -1,5 +1,5 @@ /* - Copyright (C) 2007-2016 Inverse inc. + Copyright (C) 2007-2019 Inverse inc. This file is part of SOGo @@ -141,8 +141,6 @@ static SoProduct *commonProduct = nil; - (id) init { - NSString *language; - if ((self = [super init])) { _selectedDate = nil; @@ -150,10 +148,9 @@ static SoProduct *commonProduct = nil; ASSIGN (userDefaults, [[context activeUser] userDefaults]); if (!userDefaults) ASSIGN (userDefaults, [SOGoSystemDefaults sharedSystemDefaults]); - language = [userDefaults language]; ASSIGN (languages, [context resourceLookupLanguages]); ASSIGN (locale, - [[self resourceManager] localeForLanguageNamed: language]); + [[self resourceManager] localeForLanguageNamed: [languages objectAtIndex: 0]]); } return self; @@ -639,6 +636,20 @@ static SoProduct *commonProduct = nil; return [context valueForKey: @"locale"]; } +- (NSString *) localeCode +{ + // WARNING : NSLocaleCode is not defined in + // Region subtag must be separated by a dash + NSMutableString *s = [NSMutableString stringWithString: [locale objectForKey: @"NSLocaleCode"]]; + + [s replaceOccurrencesOfString: @"_" + withString: @"-" + options: 0 + range: NSMakeRange(0, [s length])]; + + return s; +} + - (WOResourceManager *) pageResourceManager { WOResourceManager *rm; diff --git a/UI/Scheduler/UIxCalMainView.m b/UI/Scheduler/UIxCalMainView.m index 8924278ff..41eb1715f 100644 --- a/UI/Scheduler/UIxCalMainView.m +++ b/UI/Scheduler/UIxCalMainView.m @@ -79,20 +79,6 @@ } } -- (NSString *) localeCode -{ - // WARNING : NSLocaleCode is not defined in - // Region subtag must be separated by a dash - NSMutableString *s = [NSMutableString stringWithString: [locale objectForKey: @"NSLocaleCode"]]; - - [s replaceOccurrencesOfString: @"_" - withString: @"-" - options: 0 - range: NSMakeRange(0, [s length])]; - - return s; -} - - (NSArray *) monthMenuItems { static NSMutableArray *monthMenuItems = nil; diff --git a/UI/Templates/UIxPageFrame.wox b/UI/Templates/UIxPageFrame.wox index 489a02f92..8ef0a53f7 100644 --- a/UI/Templates/UIxPageFrame.wox +++ b/UI/Templates/UIxPageFrame.wox @@ -11,7 +11,7 @@ - + <var:string value="title"/>