Fix localization of calendar categories

Fixes #3295
This commit is contained in:
Francis Lachapelle 2015-09-15 15:59:31 -04:00
parent 063f878199
commit b910501afa
3 changed files with 52 additions and 17 deletions

1
NEWS
View file

@ -18,6 +18,7 @@ Bug fixes
- Avoid conflicting message on saving a draft mail (Zentyal)
- Less conflicting messages in Outlook while moving messages between folders (Zentyal)
- Start/end shifting by 1 hour due to timezone change on last Sunday of October 2015 (#3344)
- Fixed localization of calendar categories with empty profile (#3295)
2.3.1 (2015-07-23)
------------------

View file

@ -87,8 +87,6 @@
$label5 = ("Later", "#993399");
};
SOGoCalendarCategories = ("Customer", "Calls", "Favorites", "Meeting", "Ideas", "Miscellaneous", "Birthday", "Anniversary", "Vacation", "Travel", "Projects", "Suppliers", "Gifts", "Clients", "Issues", "Business", "Holidays", "Personal", "Status", "Competition", "Follow up", "Public Holiday");
SOGoCalendarCategoriesColors = { "Customer" = "#F0F0F0"; "Calls" = "#F0F0F0"; "Favorites" = "#F0F0F0"; "Meeting" = "#F0F0F0"; "Ideas" = "#F0F0F0"; "Miscellaneous" = "#F0F0F0"; "Birthday" = "#F0F0F0"; "Anniversary" = "#F0F0F0"; "Vacation" = "#F0F0F0"; "Travel" = "#F0F0F0"; "Projects" = "#F0F0F0"; "Suppliers" = "#F0F0F0"; "Gifts" = "#F0F0F0"; "Clients" = "#F0F0F0"; "Issues" = "#F0F0F0"; "Business" = "#F0F0F0"; "Holidays" = "#F0F0F0"; "Personal" = "#F0F0F0"; "Status" = "#F0F0F0"; "Competition" = "#F0F0F0"; "Follow up" = "#F0F0F0"; "Public Holiday" = "#F0F0F0"; };
SOGoSubscriptionFolderFormat = "%{FolderName} (%{UserName} <%{Email}>)";

View file

@ -26,6 +26,7 @@
#import <Foundation/NSUserDefaults.h> /* for locale strings */
#import <Foundation/NSValue.h>
#import <NGObjWeb/SoObjects.h>
#import <NGObjWeb/WOContext.h>
#import <NGObjWeb/WORequest.h>
@ -643,7 +644,7 @@ static NSArray *reminderValues = nil;
SOGoUserSettings *us;
NSMutableDictionary *moduleSettings;
id whiteList;
us = [user userSettings];
moduleSettings = [us objectForKey: @"Calendar"];
whiteList = [moduleSettings objectForKey: @"PreventInvitationsWhitelist"];
@ -652,7 +653,7 @@ static NSArray *reminderValues = nil;
{
whiteList = [whiteList jsonRepresentation];
}
return whiteList;
}
@ -661,13 +662,13 @@ static NSArray *reminderValues = nil;
NSMutableDictionary *moduleSettings;
SOGoUserSettings *us;
id o;
us = [user userSettings];
moduleSettings = [us objectForKey: @"Calendar"];
if (!(o = [whiteListString objectFromJSONString]))
o = [NSDictionary dictionary];
[moduleSettings setObject: o forKey: @"PreventInvitationsWhitelist"];
[us synchronize];
}
@ -752,35 +753,35 @@ static NSArray *reminderValues = nil;
/* We want all the SourceIDS */
NSMutableArray *folders, *availableAddressBooksID, *availableAddressBooksName;
SOGoParentFolder *contactFolders;
int i, count;
BOOL collectedAlreadyExist;
contactFolders = [[[context activeUser] homeFolderInContext: context]
lookupName: @"Contacts"
inContext: context
acquire: NO];
folders = [NSMutableArray arrayWithArray: [contactFolders subFolders]];
count = [folders count]-1;
// Inside this loop we remove all the public or shared addressbooks
for (; count >= 0; count--)
{
if (![[folders objectAtIndex: count] isKindOfClass: [SOGoContactGCSFolder class]])
[folders removeObjectAtIndex: count];
}
// Parse the objects in order to have only the displayName of the addressbooks to be displayed on the preferences interface
availableAddressBooksID = [NSMutableArray arrayWithCapacity: [folders count]];
availableAddressBooksName = [NSMutableArray arrayWithCapacity: [folders count]];
count = [folders count]-1;
collectedAlreadyExist = NO;
for (i = 0; i <= count ; i++)
{
[availableAddressBooksID addObject:[[folders objectAtIndex:i] realNameInContainer]];
[availableAddressBooksName addObject:[[folders objectAtIndex:i] displayName]];
if ([[availableAddressBooksID objectAtIndex:i] isEqualToString: @"collected"])
collectedAlreadyExist = YES;
}
@ -795,7 +796,7 @@ static NSArray *reminderValues = nil;
[availableAddressBooksID addObject: @"collected"];
[addressBooksIDWithDisplayName setObject: [self labelForKey: @"Collected Address Book"] forKey: @"collected"];
}
return availableAddressBooksID;
}
@ -832,7 +833,7 @@ static NSArray *reminderValues = nil;
value = @"every_minute";
else if (interval == 60)
value = @"once_per_hour";
else if (interval == 2 || interval == 5 || interval == 10
else if (interval == 2 || interval == 5 || interval == 10
|| interval == 20 || interval == 30)
value = [NSString stringWithFormat: @"every_%d_minutes", interval];
else
@ -1250,7 +1251,7 @@ static NSArray *reminderValues = nil;
- (NSString *) forwardConstraints
{
SOGoDomainDefaults *dd;
dd = [[context activeUser] domainDefaults];
return [NSString stringWithFormat: @"%d", [dd forwardConstraints]];
@ -1512,11 +1513,46 @@ static NSArray *reminderValues = nil;
- (NSString *) categoryColor
{
SOGoDomainDefaults *dd;
NSDictionary *defaultCalendarCategoriesColors;
NSString *categoryColor;
if (!calendarCategoriesColors)
ASSIGN (calendarCategoriesColors, [userDefaults calendarCategoriesColors]);
{
NSArray *defaultCalendarCategories, *localizedCalendarCategories;
NSMutableDictionary *localizedCalendarCategoriesColors;
NSString *localizedCategory, *defaultCategory;
NSUInteger count, max;
defaultCalendarCategories = [userDefaults calendarCategories];
if (defaultCalendarCategories)
{
// User has custom calendar categories
ASSIGN (calendarCategoriesColors, [userDefaults calendarCategoriesColors]);
}
else
{
// Build categories colors dictionary with localized keys
defaultCalendarCategories = [[[self pageResourceManager] stringForKey: @"calendar_category_labels"
inTableNamed: nil
withDefaultValue: nil
languages: [NSArray arrayWithObject: @"English"]]
componentsSeparatedByString: @","];
defaultCalendarCategoriesColors = [userDefaults calendarCategoriesColors];
max = [defaultCalendarCategories count];
localizedCalendarCategories = [self _languageCalendarCategories];
localizedCalendarCategoriesColors = [NSMutableDictionary dictionaryWithCapacity: max];
for (count = 0; count < max; count++)
{
localizedCategory = [localizedCalendarCategories objectAtIndex: count];
defaultCategory = [defaultCalendarCategories objectAtIndex: count];
[localizedCalendarCategoriesColors setObject: [defaultCalendarCategoriesColors objectForKey: defaultCategory]
forKey: localizedCategory];
}
ASSIGN (calendarCategoriesColors, localizedCalendarCategoriesColors);
}
}
categoryColor = [calendarCategoriesColors objectForKey: category];