XSTool.m 1012 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //
  2. // XSTool.m
  3. // XenonSDK
  4. //
  5. // Created by fq on 2020/12/10.
  6. // Copyright © 2020 SAGESSE. All rights reserved.
  7. //
  8. #import "XSTool.h"
  9. @implementation XSTool
  10. +(NSString *)getCurrentSystemLauguage {
  11. NSString *str = @"";
  12. NSUserDefaults* defs = [NSUserDefaults standardUserDefaults];
  13. NSArray* languages = [defs objectForKey:@"AppleLanguages"];
  14. NSString* preferredLang = [languages objectAtIndex:0];
  15. if ([preferredLang hasPrefix:@"en"]) {
  16. str = @"us"; //英文
  17. }
  18. if ([preferredLang containsString:@"zh-HK"] || [preferredLang containsString:@"zh-Hant-HK"]) {
  19. str = @"hk"; //香港繁体中文
  20. }
  21. if ([preferredLang containsString:@"zh-TW"] || [preferredLang containsString:@"zh-Hant-TW"]) {
  22. str = @"tw"; //台湾繁体中文
  23. }
  24. if ([preferredLang containsString:@"zh-Hans"] || [preferredLang containsString:@"zh-Hans-CN"]) {
  25. str = @"zh"; //简体中文
  26. }
  27. return str;
  28. }
  29. @end