Monotone-Parent: f4861ebaae0a55ed464809d54f5ecd4f0bef9913

Monotone-Revision: d23a6bb43fc70fa7f45420eb293780b9dcfbd02c

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2010-04-09T18:45:14
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2010-04-09 18:45:14 +00:00
parent 7a072049ab
commit 0fc3588ff3
121 changed files with 912 additions and 2557 deletions
+4
View File
@@ -28,6 +28,7 @@
#import <DOM/DOMProtocols.h>
@class NSString;
@class WOContext;
@interface NSObject (SOGoObjectUtilities)
@@ -36,6 +37,9 @@
- (NSArray *) domNode: (id <DOMNode>) node
getChildNodesByType: (DOMNodeType) type;
- (NSString *) labelForKey: (NSString *) key
inContext: (WOContext *) context;
@end
#endif /* NSOBJECT+UTILITIES_H */
+68
View File
@@ -21,8 +21,16 @@
*/
#import <Foundation/NSArray.h>
#import <Foundation/NSBundle.h>
#import <Foundation/NSString.h>
#import <NGObjWeb/WOContext+SoObjects.h>
#import <NGObjWeb/WORequest.h>
#import "NSDictionary+Utilities.h"
#import "SOGoUser.h"
#import "SOGoUserDefaults.h"
#import "NSObject+Utilities.h"
@implementation NSObject (SOGoObjectUtilities)
@@ -53,4 +61,64 @@
return nodes;
}
- (NSArray *) _languagesForLabelsInContext: (WOContext *) context
{
NSMutableArray *languages;
NSArray *browserLanguages;
NSString *language;
SOGoUser *user;
#warning the purpose of this method needs to be reviewed
languages = [NSMutableArray array];
user = [context activeUser];
if ([user isKindOfClass: [SOGoUser class]])
{
language = [[user userDefaults] language];
[languages addObject: language];
}
else
{
browserLanguages = [[context request] browserLanguages];
[languages addObjectsFromArray: browserLanguages];
}
return languages;
}
- (NSString *) labelForKey: (NSString *) key
inContext: (WOContext *) context
{
NSString *language, *label;
NSArray *paths;
NSEnumerator *languages;
NSBundle *bundle;
NSDictionary *strings;
label = nil;
bundle = [NSBundle bundleForClass: [self class]];
if (!bundle)
bundle = [NSBundle mainBundle];
languages = [[self _languagesForLabelsInContext: context] objectEnumerator];
while (!label && (language = [languages nextObject]))
{
paths = [bundle pathsForResourcesOfType: @"strings"
inDirectory: [NSString stringWithFormat: @"%@.lproj",
language]
forLocalization: language];
if ([paths count] > 0)
{
strings = [NSDictionary
dictionaryFromStringsFile: [paths objectAtIndex: 0]];
label = [strings objectForKey: key];
}
}
if (!label)
label = key;
return label;
}
@end
+3 -1
View File
@@ -58,6 +58,7 @@
#import "NSArray+Utilities.h"
#import "NSArray+DAV.h"
#import "NSObject+DAV.h"
#import "NSObject+Utilities.h"
#import "NSString+Utilities.h"
#import "NSString+DAV.h"
@@ -271,7 +272,8 @@ static NSArray *childRecordFields = nil;
{
displayName = [NSMutableString new];
if ([primaryDN isEqualToString: [container defaultFolderName]])
[displayName appendString: [self labelForKey: primaryDN]];
[displayName appendString: [self labelForKey: primaryDN
inContext: context]];
else
[displayName appendString: primaryDN];
-2
View File
@@ -90,8 +90,6 @@
- (NSURL *) soURLToBaseContainerForCurrentUser;
- (NSString *) davURLAsString;
- (NSString *) labelForKey: (NSString *) key;
/* ownership */
- (void) setOwner: (NSString *) newOwner;
-59
View File
@@ -1013,65 +1013,6 @@
return nil;
}
- (NSArray *) _languagesForLabels
{
NSMutableArray *languages;
NSArray *browserLanguages;
NSString *language;
SOGoUser *user;
#warning the purpose of this method needs to be reviewed
languages = [NSMutableArray array];
user = [context activeUser];
if ([user isKindOfClass: [SOGoUser class]])
{
language = [[user userDefaults] language];
[languages addObject: language];
}
else
{
browserLanguages = [[context request] browserLanguages];
[languages addObjectsFromArray: browserLanguages];
}
return languages;
}
- (NSString *) labelForKey: (NSString *) key
{
NSString *language, *label;
NSArray *paths;
NSEnumerator *languages;
NSBundle *bundle;
NSDictionary *strings;
label = nil;
bundle = [NSBundle bundleForClass: [self class]];
if (!bundle)
bundle = [NSBundle mainBundle];
languages = [[self _languagesForLabels] objectEnumerator];
while (!label && (language = [languages nextObject]))
{
paths = [bundle pathsForResourcesOfType: @"strings"
inDirectory: [NSString stringWithFormat: @"%@.lproj",
language]
forLocalization: language];
if ([paths count] > 0)
{
strings = [NSDictionary
dictionaryFromStringsFile: [paths objectAtIndex: 0]];
label = [strings objectForKey: key];
}
}
if (!label)
label = key;
return label;
}
/* description */
- (void) appendAttributesToDescription: (NSMutableString *) _ms