fix countrycode

phiz
stewen 2023-08-04 17:56:51 +08:00
parent a6bd02e789
commit 6749f2fc82
3 changed files with 6 additions and 13 deletions

View File

@ -19,16 +19,9 @@
[[FATClient sharedClient] registerSyncExtensionApi:self.name handler:^NSDictionary *(FATAppletInfo *appletInfo, id param) {
if([self.name isEqualToString:@"getLanguageCodeSync"]){
NSDictionary *resultDict = [NSDictionary dictionary];
if([PhizLanguageData sharedInstance].languageCode == nil){
NSString *languageCode = [[NSLocale preferredLanguages] firstObject];
NSString *shortCode = [[NSLocale componentsFromLocaleIdentifier:languageCode] objectForKey:NSLocaleLanguageCode];
NSString *countryCode = [NSString stringWithFormat:@"%@", [[NSLocale currentLocale] objectForKey:NSLocaleCountryCode]];
resultDict = @{@"languageCode":shortCode,@"countryCode":countryCode};
}else{
NSString* shortCode = [PhizLanguageData sharedInstance].languageCode;
NSString* countryCode = [PhizLanguageData sharedInstance].countryCode;
resultDict = @{@"languageCode":shortCode,@"countryCode":countryCode};
}
NSString* shortCode = [PhizLanguageData sharedInstance].languageCode;
NSString* countryCode = [PhizLanguageData sharedInstance].countryCode;
resultDict = @{@"languageCode":shortCode,@"countryCode":countryCode};
return resultDict;
}
return @{};

View File

@ -14,8 +14,8 @@
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [[self alloc] init];
//sharedInstance.languageCode = @"en"; // Set default language code
//sharedInstance.countryCode = @"US";
sharedInstance.languageCode = @"en"; // Set default language code
sharedInstance.countryCode = @"US";
});
return sharedInstance;
}

View File

@ -143,7 +143,7 @@ static MopPlugin *_instance;
}
}
else if ([@"updateLanguage" isEqualToString:call.method]) {
NSLog(@"updateLanguage");
NSLog(@"updateLanguage,");
NSString *cCode = call.arguments[@"countryCode"];
NSString *cLang = call.arguments[@"languageCode"];
[PhizLanguageData sharedInstance].countryCode = cCode;