Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions ChatSDKCore/Classes/Categories/NSDate+Additions.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ @implementation NSDate (Additions)
-(NSString *) threadTimeAgo {
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:self.timeFormat];

[formatter setLocale:BChatSDK.config.locale];
NSString * time = [formatter stringFromDate:self];

NSDateComponents *otherDay = [[NSCalendar currentCalendar] components:NSCalendarUnitDay fromDate:self];
Expand Down Expand Up @@ -45,6 +45,7 @@ -(NSString *) messageTimeAt {
// if (self.daysAgo < 1) {
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:self.timeFormat];
[formatter setLocale:BChatSDK.config.locale];
return [formatter stringFromDate:self];
// }
// else {
Expand All @@ -60,6 +61,7 @@ -(NSString *) dateAgo {

NSString * day = @"";
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setLocale:BChatSDK.config.locale];

if (self.isToday) {
day = [NSBundle t: bToday];
Expand Down Expand Up @@ -100,7 +102,7 @@ -(BOOL) isPreviousDay: (NSDate *) date {
-(NSString *) timeAgoWithFormatString: (NSString *) formatString {
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:self.timeFormat];

[formatter setLocale:BChatSDK.config.locale];
NSString * time = [formatter stringFromDate:self];
NSString * day = [self dateAgo];
return [NSString stringWithFormat:[NSBundle t:formatString], day, time];
Expand Down
3 changes: 3 additions & 0 deletions ChatSDKCore/Classes/Session/BConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ typedef enum {
@property (nonatomic, readwrite) NSString * inviteByEmailBody;
@property (nonatomic, readwrite) NSString * inviteBySMSBody;

// Message locale
@property (nonatomic, readwrite) NSLocale * locale;

// Message fonts
@property (nonatomic, readwrite) UIFont * messageTextFont;

Expand Down
3 changes: 3 additions & 0 deletions ChatSDKCore/Classes/Session/BConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ @implementation BConfiguration
@synthesize enableCompatibilityWithV4;

@synthesize messageDeletionEnabled;
@synthesize locale;

-(instancetype) init {
if((self = [super init])) {
Expand All @@ -112,6 +113,8 @@ -(instancetype) init {

[self setDefaultUserNamePrefix:@"ChatSDK"];

locale = NSLocale.currentLocale;

showEmptyChats = YES;
allowUsersToCreatePublicChats = NO;

Expand Down
4 changes: 2 additions & 2 deletions ChatSDKCore/Classes/UI/NSBundle+Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@
#define bNoNewUsersFoundForThisSearch @"bNoNewUsersFoundForThisSearch"
#define bLastSeen_at_ @"bLastSeen_at_"
#define b_at_ @"b_at_"
#define bToday @"Today"
#define bYesterday @"Yesterday"
#define bToday @"bToday"
#define bYesterday @"bYesterday"
#define bYouLeftTheGroup @"bYouLeftTheGroup"
#define bYouJoinedTheGroup @"bYouJoinedTheGroup"
#define bRejoinGroup @"bRejoinGroup"
Expand Down
4 changes: 2 additions & 2 deletions ChatSDKCore/Classes/UI/NSBundle+Core.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ + (NSString *)localizationFileForLang:(NSString *)lang {
+ (NSString *)bestLocalizationFileForLang:(NSString *)lang {
NSString * exact = [self localizationFileForLang:lang];
if (exact) return exact;
lang = [[lang componentsSeparatedByString:@"-"] firstObject];
lang = [[lang componentsSeparatedByString:@"_"] firstObject];
NSString * general = [self localizationFileForLang:lang];
if (general) return general;
return bLocalizableFile;
}

+ (NSString *)t:(NSString *)string {
NSString * lang = [[NSLocale preferredLanguages] objectAtIndex:0];
NSString * lang = [BChatSDK.config.locale localeIdentifier];
NSString * localizableFile = [self bestLocalizationFileForLang:lang];
if (!localizableFile) return string;

Expand Down
4 changes: 4 additions & 0 deletions ChatSDKCore/Classes/Utilities/BFileCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ + (BOOL)isFileCached:(NSString *)cacheName {
}

+ (RXPromise *)cacheFileFromURL:(NSURL *)url withFileName:(NSString *)fileName andCacheName:(NSString *)cacheName {
if (!fileName || !fileName.length) {
fileName = BCoreUtilities.getUUID;
}

RXPromise * promise = [RXPromise new];
if (!url) {
[promise rejectWithReason: @"URL must not be nil"];
Expand Down