mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-07-10 10:55:08 +00:00
Monotone-Parent: 659def76b8868bdc540986987d61b39410737054
Monotone-Revision: 6eed7e248c203a0103250e46033fc47b929ee536 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-02-03T16:12:22 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -46,7 +46,7 @@ SOGo_HEADER_FILES = \
|
||||
NSURL+DAV.h \
|
||||
\
|
||||
SOGoAuthenticator.h \
|
||||
SOGoSession.h \
|
||||
SOGoSession.h \
|
||||
SOGoCASSession.h \
|
||||
SOGoDAVAuthenticator.h \
|
||||
SOGoProxyAuthenticator.h \
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user