Monotone-Parent: 659def76b8868bdc540986987d61b39410737054
Monotone-Revision: 6eed7e248c203a0103250e46033fc47b929ee536 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-02-03T16:12:22 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
f3e23ff651
commit
bb2373ebe6
|
@ -1,3 +1,9 @@
|
|||
2011-02-03 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* SoObjects/SOGo/WOResourceManager+SOGo.m: new category module
|
||||
defining methods useful to the vanilla and OpenChange frontends.
|
||||
(-localeForLanguageNamed:): method moved from SOGo.m.
|
||||
|
||||
2011-02-01 Ludovic Marcotte <lmarcotte@inverse.ca>
|
||||
|
||||
* SoObjects/SOGo/NSString+Utilities.h,m: Fixed
|
||||
|
|
|
@ -33,12 +33,10 @@
|
|||
|
||||
@interface SOGo : SoApplication
|
||||
{
|
||||
NSMutableDictionary *localeLUT;
|
||||
SOGoCache *cache;
|
||||
}
|
||||
|
||||
- (NSDictionary *) currentLocaleConsideringLanguages:(NSArray *)_langs;
|
||||
- (NSDictionary *) localeForLanguageNamed:(NSString *)_name;
|
||||
- (NSString *) davURLAsString;
|
||||
|
||||
@end
|
||||
|
|
83
Main/SOGo.m
83
Main/SOGo.m
|
@ -60,6 +60,7 @@
|
|||
#import <SOGo/SOGoSystemDefaults.h>
|
||||
#import <SOGo/SOGoWebAuthenticator.h>
|
||||
#import <SOGo/WORequest+SOGo.h>
|
||||
#import <SOGo/WOResourceManager+SOGo.h>
|
||||
#import <SOGo/NSObject+DAV.h>
|
||||
|
||||
#import "NSException+Stacktrace.h"
|
||||
|
@ -125,9 +126,6 @@ static BOOL debugLeaks;
|
|||
[$(@"SOGoContentObject") soClass];
|
||||
[$(@"SOGoFolder") soClass];
|
||||
|
||||
/* setup locale cache */
|
||||
localeLUT = [[NSMutableDictionary alloc] initWithCapacity:2];
|
||||
|
||||
/* load products */
|
||||
[[SOGoProductLoader productLoader] loadAllProducts];
|
||||
|
||||
|
@ -140,12 +138,6 @@ static BOOL debugLeaks;
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[localeLUT release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
#warning the following methods should be replaced with helpers in GCSSpecialQueries
|
||||
- (NSString *) _sqlScriptForTable: (NSString *) tableName
|
||||
withType: (NSString *) tableType
|
||||
|
@ -497,86 +489,17 @@ static BOOL debugLeaks;
|
|||
lname = [enumerator nextObject];
|
||||
while (lname && !locale)
|
||||
{
|
||||
locale = [self localeForLanguageNamed: lname];
|
||||
locale = [[self resourceManager] localeForLanguageNamed: lname];
|
||||
lname = [enumerator nextObject];
|
||||
}
|
||||
|
||||
if (!locale)
|
||||
locale = [self localeForLanguageNamed: @"English"];
|
||||
locale = [[self resourceManager] localeForLanguageNamed: @"English"];
|
||||
|
||||
/* no appropriate language, fallback to default */
|
||||
return locale;
|
||||
}
|
||||
|
||||
- (NSString *) pathToLocaleForLanguageNamed: (NSString *) _name
|
||||
{
|
||||
static Class MainProduct = Nil;
|
||||
NSString *lpath;
|
||||
|
||||
lpath = [[self resourceManager] pathForResourceNamed: @"Locale"
|
||||
inFramework: nil
|
||||
languages: [NSArray arrayWithObject:_name]];
|
||||
if (![lpath length])
|
||||
{
|
||||
if (!MainProduct)
|
||||
{
|
||||
MainProduct = $(@"MainUIProduct");
|
||||
if (!MainProduct)
|
||||
[self errorWithFormat: @"did not find MainUIProduct class!"];
|
||||
}
|
||||
|
||||
lpath = [(id) MainProduct pathToLocaleForLanguageNamed: _name];
|
||||
if (![lpath length])
|
||||
lpath = nil;
|
||||
}
|
||||
|
||||
return lpath;
|
||||
}
|
||||
|
||||
- (NSDictionary *) localeForLanguageNamed: (NSString *) _name
|
||||
{
|
||||
NSString *lpath;
|
||||
id data;
|
||||
NSDictionary *locale;
|
||||
|
||||
locale = nil;
|
||||
if ([_name length] > 0)
|
||||
{
|
||||
locale = [localeLUT objectForKey: _name];
|
||||
if (!locale)
|
||||
{
|
||||
lpath = [self pathToLocaleForLanguageNamed:_name];
|
||||
if (lpath)
|
||||
{
|
||||
data = [NSData dataWithContentsOfFile: lpath];
|
||||
if (data)
|
||||
{
|
||||
data = [[[NSString alloc] initWithData: data
|
||||
encoding: NSUTF8StringEncoding] autorelease];
|
||||
locale = [data propertyList];
|
||||
if (locale)
|
||||
[localeLUT setObject: locale forKey: _name];
|
||||
else
|
||||
[self logWithFormat:@"%s couldn't load locale with name:%@",
|
||||
__PRETTY_FUNCTION__,
|
||||
_name];
|
||||
}
|
||||
else
|
||||
[self logWithFormat:@"%s didn't find locale with name: %@",
|
||||
__PRETTY_FUNCTION__,
|
||||
_name];
|
||||
}
|
||||
else
|
||||
[self errorWithFormat:@"did not find locale for language: %@", _name];
|
||||
}
|
||||
}
|
||||
else
|
||||
[self errorWithFormat:@"%s: name parameter must not be nil!",
|
||||
__PRETTY_FUNCTION__];
|
||||
|
||||
return locale;
|
||||
}
|
||||
|
||||
- (NSURL *) _urlPreferringParticle: (NSString *) expected
|
||||
overThisOne: (NSString *) possible
|
||||
{
|
||||
|
|
|
@ -60,6 +60,7 @@ SOGo_HEADER_FILES = \
|
|||
DOMNode+SOGo.h \
|
||||
\
|
||||
WORequest+SOGo.h \
|
||||
WOResourceManager+SOGo.h \
|
||||
WOResponse+SOGo.h \
|
||||
WOContext+SOGo.h
|
||||
|
||||
|
@ -123,6 +124,7 @@ SOGo_OBJC_FILES = \
|
|||
DOMNode+SOGo.m \
|
||||
\
|
||||
WORequest+SOGo.m \
|
||||
WOResourceManager+SOGo.m \
|
||||
WOResponse+SOGo.m \
|
||||
WOContext+SOGo.m
|
||||
|
||||
|
|
|
@ -50,8 +50,7 @@
|
|||
#import "SOGoUserManager.h"
|
||||
#import "SOGoUserProfile.h"
|
||||
#import "SOGoUserSettings.h"
|
||||
|
||||
#import "../../Main/SOGo.h"
|
||||
#import "WOResourceManager+SOGo.h"
|
||||
|
||||
#import "SOGoUser.h"
|
||||
|
||||
|
@ -283,12 +282,14 @@
|
|||
NSString *format;
|
||||
SOGoUserDefaults *ud;
|
||||
NSDictionary *locale;
|
||||
WOResourceManager *resMgr;
|
||||
|
||||
dateFormatter = [SOGoDateFormatter new];
|
||||
[dateFormatter autorelease];
|
||||
|
||||
ud = [self userDefaults];
|
||||
locale = [[WOApplication application] localeForLanguageNamed: [ud language]];
|
||||
resMgr = [[WOApplication application] resourceManager];
|
||||
locale = [resMgr localeForLanguageNamed: [ud language]];
|
||||
[dateFormatter setLocale: locale];
|
||||
format = [ud shortDateFormat];
|
||||
if (format)
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/* WOResourceManager+SOGo.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2011 Inverse inc
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef WORESOURCEMANAGER_SOGO_H
|
||||
#define WORESOURCEMANAGER_SOGO_H
|
||||
|
||||
#import <NGObjWeb/WOResourceManager.h>
|
||||
|
||||
@interface WOResourceManager (SOGoExtensions)
|
||||
|
||||
- (NSDictionary *) localeForLanguageNamed: (NSString *) _name;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* WORESOURCEMANAGER_SOGO_H */
|
|
@ -0,0 +1,106 @@
|
|||
/* WOResourceManager+SOGo.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2011 Inverse inc
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#import <Foundation/NSData.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
|
||||
#import <NGExtensions/NSObject+Logs.h>
|
||||
|
||||
#import "WOResourceManager+SOGo.h"
|
||||
|
||||
@implementation WOResourceManager (SOGoExtensions)
|
||||
|
||||
- (NSString *) pathToLocaleForLanguageNamed: (NSString *) _name
|
||||
{
|
||||
static Class MainProduct = Nil;
|
||||
NSString *lpath;
|
||||
|
||||
lpath = [self pathForResourceNamed: @"Locale"
|
||||
inFramework: nil
|
||||
languages: [NSArray arrayWithObject:_name]];
|
||||
if (![lpath length])
|
||||
{
|
||||
if (!MainProduct)
|
||||
{
|
||||
MainProduct = NSClassFromString (@"MainUIProduct");
|
||||
if (!MainProduct)
|
||||
[self errorWithFormat: @"did not find MainUIProduct class!"];
|
||||
}
|
||||
|
||||
lpath = [(id) MainProduct performSelector: NSSelectorFromString (@"pathToLocaleForLanguageNamed:")
|
||||
withObject: _name];
|
||||
if (![lpath length])
|
||||
lpath = nil;
|
||||
}
|
||||
|
||||
return lpath;
|
||||
}
|
||||
|
||||
- (NSDictionary *) localeForLanguageNamed: (NSString *) _name
|
||||
{
|
||||
NSString *lpath;
|
||||
id data;
|
||||
NSDictionary *locale;
|
||||
static NSMutableDictionary *localeLUT = nil;
|
||||
|
||||
locale = nil;
|
||||
if ([_name length] > 0)
|
||||
{
|
||||
if (!localeLUT)
|
||||
localeLUT = [NSMutableDictionary new];
|
||||
|
||||
locale = [localeLUT objectForKey: _name];
|
||||
if (!locale)
|
||||
{
|
||||
lpath = [self pathToLocaleForLanguageNamed:_name];
|
||||
if (lpath)
|
||||
{
|
||||
data = [NSData dataWithContentsOfFile: lpath];
|
||||
if (data)
|
||||
{
|
||||
data = [[[NSString alloc] initWithData: data
|
||||
encoding: NSUTF8StringEncoding] autorelease];
|
||||
locale = [data propertyList];
|
||||
if (locale)
|
||||
[localeLUT setObject: locale forKey: _name];
|
||||
else
|
||||
[self logWithFormat:@"%s couldn't load locale with name:%@",
|
||||
__PRETTY_FUNCTION__,
|
||||
_name];
|
||||
}
|
||||
else
|
||||
[self logWithFormat:@"%s didn't find locale with name: %@",
|
||||
__PRETTY_FUNCTION__,
|
||||
_name];
|
||||
}
|
||||
else
|
||||
[self errorWithFormat:@"did not find locale for language: %@", _name];
|
||||
}
|
||||
}
|
||||
else
|
||||
[self errorWithFormat:@"%s: name parameter must not be nil!",
|
||||
__PRETTY_FUNCTION__];
|
||||
|
||||
return locale;
|
||||
}
|
||||
|
||||
@end
|
|
@ -47,17 +47,16 @@
|
|||
#import <NGMime/NGMimeType.h>
|
||||
|
||||
#import <SOGo/SOGoUserDefaults.h>
|
||||
#import <SoObjects/Mailer/SOGoDraftObject.h>
|
||||
#import <SoObjects/Mailer/SOGoMailFolder.h>
|
||||
#import <SoObjects/Mailer/SOGoMailAccount.h>
|
||||
#import <SoObjects/Mailer/SOGoMailAccounts.h>
|
||||
#import <SoObjects/SOGo/SOGoUser.h>
|
||||
#import <SoObjects/SOGo/NSArray+Utilities.h>
|
||||
#import <SoObjects/SOGo/NSDictionary+Utilities.h>
|
||||
#import <Mailer/SOGoDraftObject.h>
|
||||
#import <Mailer/SOGoMailFolder.h>
|
||||
#import <Mailer/SOGoMailAccount.h>
|
||||
#import <Mailer/SOGoMailAccounts.h>
|
||||
#import <SOGo/SOGoUser.h>
|
||||
#import <SOGo/NSArray+Utilities.h>
|
||||
#import <SOGo/NSDictionary+Utilities.h>
|
||||
#import <SOGo/WOResourceManager+SOGo.h>
|
||||
#import <SOGoUI/UIxComponent.h>
|
||||
|
||||
#import "../../Main/SOGo.h"
|
||||
|
||||
/*
|
||||
UIxMailEditor
|
||||
|
||||
|
@ -210,7 +209,7 @@ static NSArray *infoKeys = nil;
|
|||
NSDictionary *locale;
|
||||
|
||||
ud = [[context activeUser] userDefaults];
|
||||
locale = [[WOApplication application]
|
||||
locale = [[self resourceManager]
|
||||
localeForLanguageNamed: [ud language]];
|
||||
|
||||
// WARNING : NSLocaleCode is not defined in <Foundation/NSUserDefaults.h>
|
||||
|
|
|
@ -40,8 +40,8 @@
|
|||
#import <SOGo/SOGoDomainDefaults.h>
|
||||
#import <SOGo/SOGoSystemDefaults.h>
|
||||
#import <SOGo/SOGoUserFolder.h>
|
||||
#import <SOGo/WOResourceManager+SOGo.h>
|
||||
#import <Mailer/SOGoMailAccount.h>
|
||||
#import "../../Main/SOGo.h"
|
||||
|
||||
#import "UIxPreferences.h"
|
||||
|
||||
|
@ -77,7 +77,7 @@
|
|||
category = nil;
|
||||
|
||||
ASSIGN (locale,
|
||||
[[WOApplication application] localeForLanguageNamed: language]);
|
||||
[[self resourceManager] localeForLanguageNamed: language]);
|
||||
ASSIGN (daysOfWeek, [locale objectForKey: NSWeekDayNameArray]);
|
||||
|
||||
dd = [user domainDefaults];
|
||||
|
|
|
@ -35,8 +35,7 @@
|
|||
#import <SOGo/SOGoDateFormatter.h>
|
||||
#import <SOGo/SOGoUser.h>
|
||||
#import <SOGo/SOGoUserDefaults.h>
|
||||
|
||||
#import "../../Main/SOGo.h"
|
||||
#import <SOGo/WOResourceManager+SOGo.h>
|
||||
|
||||
#import "UIxCalDayTable.h"
|
||||
|
||||
|
@ -57,7 +56,7 @@
|
|||
ud = [user userDefaults];
|
||||
ASSIGN (timeFormat, [ud timeFormat]);
|
||||
language = [ud language];
|
||||
locale = [[WOApplication application] localeForLanguageNamed: language];
|
||||
locale = [[self resourceManager] localeForLanguageNamed: language];
|
||||
|
||||
daysToDisplay = nil;
|
||||
hoursToDisplay = nil;
|
||||
|
|
|
@ -30,10 +30,9 @@
|
|||
#import <SoObjects/SOGo/NSCalendarDate+SOGo.h>
|
||||
|
||||
#import <SOGoUI/SOGoAptFormatter.h>
|
||||
#import <SoObjects/SOGo/SOGoUser.h>
|
||||
#import <SoObjects/SOGo/SOGoUserDefaults.h>
|
||||
|
||||
#import "../../Main/SOGo.h"
|
||||
#import <SOGo/SOGoUser.h>
|
||||
#import <SOGo/SOGoUserDefaults.h>
|
||||
#import <SOGo/WOResourceManager+SOGo.h>
|
||||
|
||||
#import "UIxCalMonthView.h"
|
||||
|
||||
|
@ -52,7 +51,7 @@
|
|||
// dateFormatter = [[SOGoDateFormatter alloc]
|
||||
// initWithLocale: [self locale]];
|
||||
ud = [[context activeUser] userDefaults];
|
||||
locale = [[WOApplication application] localeForLanguageNamed: [ud language]];
|
||||
locale = [[self resourceManager] localeForLanguageNamed: [ud language]];
|
||||
dayNames = [locale objectForKey: NSWeekDayNameArray];
|
||||
[dayNames retain];
|
||||
monthNames = [locale objectForKey: NSMonthNameArray];
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
#import <SOGo/SOGoUserManager.h>
|
||||
#import <SOGo/SOGoPermissions.h>
|
||||
#import <SOGo/SOGoSystemDefaults.h>
|
||||
#import <SOGo/WOResourceManager+SOGo.h>
|
||||
|
||||
#import "../../Main/SOGo.h"
|
||||
|
||||
|
@ -1869,7 +1870,7 @@ RANGE(2);
|
|||
NSDictionary *locale;
|
||||
|
||||
ud = [[context activeUser] userDefaults];
|
||||
locale = [[WOApplication application]
|
||||
locale = [[self resourceManager]
|
||||
localeForLanguageNamed: [ud language]];
|
||||
date = [NSCalendarDate dateWithString: [self range2]
|
||||
calendarFormat: dateFormat
|
||||
|
|
Loading…
Reference in New Issue