Skip to content

Commit 955c28e

Browse files
author
Edward Smith
committed
Merge from Apple-Shared-Source.
1 parent 5348d91 commit 955c28e

File tree

6 files changed

+79
-62
lines changed

6 files changed

+79
-62
lines changed

Branch-SDK-Tests/Branch-SDK-Tests/BNCError.Test.m

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
1+
/**
2+
@file BNCError.Test.m
3+
@package Branch-SDK
4+
@brief Branch error tests.
15
2-
3-
//--------------------------------------------------------------------------------------------------
4-
//
5-
// BNCError.Test.m
6-
// BranchTests
7-
//
8-
// Error Tests
9-
// Edward Smith, August 2017
10-
//
11-
// -©- Copyright © 2017 Branch, all rights reserved. -©-
12-
//
13-
//--------------------------------------------------------------------------------------------------
14-
6+
@author Edward Smith
7+
@date August 2017
8+
@copyright Copyright © 2017 Branch. All rights reserved.
9+
*/
1510

1611
#import "BNCTestCase.h"
1712
#import "BNCError.h"
1813
#import "BNCLocalization.h"
1914

20-
2115
@interface BNCErrorTest : BNCTestCase
2216
@end
2317

24-
2518
@implementation BNCErrorTest
2619

2720
- (void) testErrorBasic {

Branch-SDK-Tests/Branch-SDK-Tests/BNCLocalization.Test.m

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
1+
/**
2+
@file BNCLocalization.Test.m
3+
@package Branch-SDK
4+
@brief Branch string localization tests.
15
2-
3-
//--------------------------------------------------------------------------------------------------
4-
//
5-
// BNCLocalization.Test.m
6-
// BranchTests
7-
//
8-
// Localization Tests
9-
// Edward Smith, July 2017
10-
//
11-
// -©- Copyright © 2017 Branch, all rights reserved. -©-
12-
//
13-
//--------------------------------------------------------------------------------------------------
14-
6+
@author Edward Smith
7+
@date July 2017
8+
@copyright Copyright © 2017 Branch. All rights reserved.
9+
*/
1510

1611
#import "BNCTestCase.h"
1712
#import "BNCLocalization.h"
1813

19-
2014
@interface BNCLocalizationTest : BNCTestCase
2115
@end
2216

23-
2417
@implementation BNCLocalizationTest
2518

2619
- (void) testLocalizationBasic {
@@ -37,10 +30,13 @@ - (void) testLocalizationBasic {
3730
string = BNCLocalizedString(truth);
3831
XCTAssertEqualObjects(string, truth);
3932

33+
#pragma clang diagnostic push
34+
#pragma clang diagnostic ignored "-Wall"
4035
// Nil input should return empty string output.
4136
truth = @"";
4237
string = BNCLocalizedString(nil);
4338
XCTAssertEqualObjects(string, truth);
39+
#pragma clang diagnostic pop
4440

4541
// Test formatted language strings.
4642
truth = @"Test formatted language strings.";
@@ -52,9 +48,12 @@ - (void) testLocalizationBasic {
5248
string = BNCLocalizedFormattedString(@"Test formatted %@ strings float %1.2f.", @"language", 1.0);
5349
XCTAssertEqualObjects(string, truth);
5450

51+
#pragma clang diagnostic push
52+
#pragma clang diagnostic ignored "-Wall"
5553
truth = @"";
5654
string = BNCLocalizedFormattedString(nil, 1.0);
5755
XCTAssertEqualObjects(string, truth);
56+
#pragma clang diagnostic pop
5857
}
5958

6059
- (void) testLocalizationRussian {

Branch-SDK/Branch-SDK/BNCError.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
//
2-
// BNCError.h
3-
// Branch-SDK
4-
//
5-
// Created by Qinwei Gong on 11/17/14.
6-
// Copyright (c) 2014 Branch Metrics. All rights reserved.
7-
//
1+
/**
2+
@file BNCError.h
3+
@package Branch-SDK
4+
@brief Branch errors.
5+
6+
@author Qinwei Gong
7+
@date November 2014
8+
@copyright Copyright © 2014 Branch. All rights reserved.
9+
*/
810

911
#if __has_feature(modules)
1012
@import Foundation;
@@ -40,4 +42,5 @@ typedef NS_ENUM(NSInteger, BNCErrorCode) {
4042
+ (NSError*_Nonnull) branchErrorWithCode:(BNCErrorCode)errorCode localizedMessage:(NSString*_Nullable)message;
4143
@end
4244

43-
void BNCForceNSErrorCategoryToLoad(void) __attribute__((constructor));
45+
void BNCForceNSErrorCategoryToLoad(void)
46+
__attribute__((constructor));

Branch-SDK/Branch-SDK/BNCError.m

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
//
2-
// BNCError.m
3-
// Branch-SDK
4-
//
5-
// Created by Qinwei Gong on 11/17/14.
6-
// Copyright (c) 2014 Branch Metrics. All rights reserved.
7-
//
1+
/**
2+
@file BNCError.m
3+
@package Branch-SDK
4+
@brief Branch errors.
5+
6+
@author Qinwei Gong
7+
@date November 2014
8+
@copyright Copyright © 2014 Branch. All rights reserved.
9+
*/
810

911
#import "BNCError.h"
1012
#import "BNCLocalization.h"
Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,50 @@
1-
//
2-
// BNCLocalization.h
3-
// Branch-SDK
4-
//
5-
// Created by Parth Kalavadia on 7/10/17.
6-
// Copyright © 2017 Branch Metrics. All rights reserved.
7-
//
1+
/**
2+
@file BNCLocalization.h
3+
@package Branch-SDK
4+
@brief Branch string localizations.
5+
6+
@author Parth Kalavadia
7+
@date July 2017
8+
@copyright Copyright © 2017 Branch. All rights reserved.
9+
*/
10+
11+
/**
12+
@discusion
13+
14+
# BNCLocalization
15+
16+
Since the Branch SDK can be shipped as a static library, it can't use the standard Apple
17+
string localization mechanism.
18+
19+
Use this class to localize the few user-facing string resources the Branch SDK has.
20+
*/
821

922
#if __has_feature(modules)
1023
@import Foundation;
1124
#else
1225
#import <Foundation/Foundation.h>
1326
#endif
1427

28+
NS_ASSUME_NONNULL_BEGIN
29+
1530
@interface BNCLocalization : NSObject
1631

1732
+ (instancetype) shared;
1833
+ (NSString*) applicationLanguage;
1934
+ (NSDictionary<NSString*, NSDictionary*>*) languageDictionaries;
2035
- (NSString*) localizeString:(NSString*)string;
2136

37+
/// Set to an empty string or nil to reset the current language.
2238
@property (copy, atomic) NSString* currentLanguage;
2339
@property (strong, atomic, readonly) NSDictionary *currentLanguageDictionary;
2440
@end
2541

2642
#pragma mark Convenience Functions
2743

28-
static inline NSString* /**_Nonnull*/ BNCLocalizedString(NSString*const string) {
44+
static inline NSString* BNCLocalizedString(NSString*const string) {
2945
return [[BNCLocalization shared] localizeString:string];
3046
}
3147

32-
extern NSString* /**_Nonnull*/ BNCLocalizedFormattedString(NSString*const format, ...) NS_FORMAT_FUNCTION(1,2);
48+
extern NSString* BNCLocalizedFormattedString(NSString*const format, ...) NS_FORMAT_FUNCTION(1,2);
49+
50+
NS_ASSUME_NONNULL_END

Branch-SDK/Branch-SDK/BNCLocalization.m

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
//
2-
// BNCLocalization.m
3-
// Branch-SDK
4-
//
5-
// Created by Parth Kalavadia on 7/10/17.
6-
// Copyright © 2017 Branch Metrics. All rights reserved.
7-
//
1+
/**
2+
@file BNCLocalization.m
3+
@package Branch-SDK
4+
@brief Branch string localizations.
5+
6+
@author Parth Kalavadia
7+
@date July 2017
8+
@copyright Copyright © 2017 Branch. All rights reserved.
9+
*/
810

911
#import "BNCLocalization.h"
1012
#import "BNCLog.h"
@@ -58,7 +60,7 @@ - (NSString*_Nonnull) currentLanguage {
5860
}
5961
}
6062

61-
- (void) setCurrentLanguage:(NSString*_Null_unspecified)language {
63+
- (void) setCurrentLanguage:(NSString*)language {
6264
@synchronized (self) {
6365

6466
if (!language.length) {

0 commit comments

Comments
 (0)