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>
@ -1512,11 +1513,46 @@ static NSArray *reminderValues = nil;
- (NSString *) categoryColor
{
SOGoDomainDefaults *dd;
NSDictionary *defaultCalendarCategoriesColors;
NSString *categoryColor;
if (!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];