Reflect active locale in HTML lang attribute

Fixes #4660
pull/249/head
Francis Lachapelle 2019-01-28 10:04:55 -05:00
parent 35650227cf
commit e79494c43c
5 changed files with 20 additions and 21 deletions

1
NEWS
View File

@ -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

View File

@ -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;

View File

@ -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 <Foundation/NSUserDefaults.h>
// 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;

View File

@ -79,20 +79,6 @@
}
}
- (NSString *) localeCode
{
// WARNING : NSLocaleCode is not defined in <Foundation/NSUserDefaults.h>
// 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;

View File

@ -11,7 +11,7 @@
<var:string var:value="doctype" const:escapeHTML="NO" />
<var:if condition="hideFrame" const:negate="YES">
<html const:xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" const:lang="en">
<html const:xmlns="http://www.w3.org/1999/xhtml" var:lang="localeCode">
<head>
<title var:sg-default="title"><var:string value="title"/></title>
<meta name="hideFrame" var:content="hideFrame" />