react-native-i18n/ios/RNI18n.m

31 lines
703 B
Mathematica
Raw Normal View History

2017-04-07 11:26:49 +00:00
#import <UIKit/UIKit.h>
2017-03-29 23:31:43 +00:00
#import "RNI18n.h"
@implementation RNI18n
RCT_EXPORT_MODULE();
2017-04-06 00:18:08 +00:00
- (NSDictionary *)constantsToExport {
NSArray *preferredLanguages = [NSLocale preferredLanguages];
2017-03-29 23:46:08 +00:00
2017-04-07 11:26:49 +00:00
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9) {
return @{
@"language": [preferredLanguages objectAtIndex:0],
@"languages": preferredLanguages
};
}
NSMutableArray *forcedLanguageTags = [NSMutableArray array];
for (id l in preferredLanguages) {
[forcedLanguageTags addObject:[l stringByReplacingOccurrencesOfString:@"_" withString:@"-"]];
2017-03-29 23:46:08 +00:00
}
2017-04-06 00:18:08 +00:00
return @{
2017-04-07 11:26:49 +00:00
@"language": [forcedLanguageTags objectAtIndex:0],
@"languages": forcedLanguageTags
2017-04-06 00:18:08 +00:00
};
2017-03-29 23:31:43 +00:00
}
@end