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) { [[FATClient sharedClient] registerSyncExtensionApi:self.name handler:^NSDictionary *(FATAppletInfo *appletInfo, id param) {
if([self.name isEqualToString:@"getLanguageCodeSync"]){ if([self.name isEqualToString:@"getLanguageCodeSync"]){
NSDictionary *resultDict = [NSDictionary dictionary]; 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* shortCode = [PhizLanguageData sharedInstance].languageCode;
NSString* countryCode = [PhizLanguageData sharedInstance].countryCode; NSString* countryCode = [PhizLanguageData sharedInstance].countryCode;
resultDict = @{@"languageCode":shortCode,@"countryCode":countryCode}; resultDict = @{@"languageCode":shortCode,@"countryCode":countryCode};
}
return resultDict; return resultDict;
} }
return @{}; return @{};

View File

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

View File

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