react-native-i18n/ios/RNI18n.m

22 lines
466 B
Mathematica
Raw Normal View History

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];
NSMutableArray *languages = [NSMutableArray array];
2017-03-29 23:46:08 +00:00
2017-04-06 00:18:08 +00:00
for (id language in preferredLanguages) {
[languages addObject:[language stringByReplacingOccurrencesOfString:@"_" withString:@"-"]];
2017-03-29 23:46:08 +00:00
}
2017-04-06 00:18:08 +00:00
return @{
@"language": [languages objectAtIndex:0],
@"languages": languages
};
2017-03-29 23:31:43 +00:00
}
@end