0

我需要将我的默认(备用)语言从 English 设置为 non-english 。例如,我已经支持 3 种语言,比如 en,fr,gr 。现在如果用户选择中文,那么用户应该显示为 fr 语言。请帮我 。我试过这段代码

self.strLanguage = [[NSLocale preferredLanguages] objectAtIndex:0];
NSLog(@"strLanguage : %@",self.strLanguage);

NSMutableArray *arraySupportedLanguages = [[NSMutableArray alloc] initWithObjects:@"en",@"fr",@"gr", nil];



NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF contains[cd] %@", self.strLanguage];
    arraySupportedLanguages = [[arraySupportedLanguages filteredArrayUsingPredicate:predicate]mutableCopy];

NSLog(@"arraySupportedLanguages : %@",arraySupportedLanguages);

if (arraySupportedLanguages.count == 0) {
                [[NSUserDefaults standardUserDefaults] setObject:@"nl" forKey:@"AppleLanguages"];
        [[NSUserDefaults standardUserDefaults]synchronize];
    }
4

0 回答 0