// // KMOCLanguage.m // PDF Reader Pro // // Created by kdanmobile on 2025/3/3. // #import "KMOCLanguage.h" @implementation KMOCLanguage + (KMOCLanguage *)defaults { static KMOCLanguage *__settings = nil; if (!__settings) { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ __settings = [[KMOCLanguage alloc] init]; }); } return __settings; } - (instancetype)init { self = [super init]; if (self) { } return self; } - (NSString *)localizedString:(NSString *)key desc:(NSString *)desc { if (!key) { return @""; } NSInteger languageType = [[NSUserDefaults standardUserDefaults] integerForKey:@"settingsLanguageTypeKey"]; if (languageType == 0) { return NSLocalizedString(key, desc); } else { NSString *bundlePath = nil; if (languageType == 2) { bundlePath = [[NSBundle mainBundle] pathForResource:@"zh-Hans" ofType:@"lproj"]; } else if (languageType == 3) { bundlePath = [[NSBundle mainBundle] pathForResource:@"zh-Hant" ofType:@"lproj"]; } else if (languageType == 4) { bundlePath = [[NSBundle mainBundle] pathForResource:@"nl" ofType:@"lproj"]; } else if (languageType == 5) { bundlePath = [[NSBundle mainBundle] pathForResource:@"fr" ofType:@"lproj"]; } else if (languageType == 6) { bundlePath = [[NSBundle mainBundle] pathForResource:@"es" ofType:@"lproj"]; } else if (languageType == 7) { bundlePath = [[NSBundle mainBundle] pathForResource:@"de" ofType:@"lproj"]; } else if (languageType == 8) { bundlePath = [[NSBundle mainBundle] pathForResource:@"ru" ofType:@"lproj"]; } else if (languageType == 9) { bundlePath = [[NSBundle mainBundle] pathForResource:@"it" ofType:@"lproj"]; } else if (languageType == 10) { bundlePath = [[NSBundle mainBundle] pathForResource:@"ja" ofType:@"lproj"]; } else if (languageType == 11) { bundlePath = [[NSBundle mainBundle] pathForResource:@"pl" ofType:@"lproj"]; } else if (languageType == 12) { bundlePath = [[NSBundle mainBundle] pathForResource:@"pt" ofType:@"lproj"]; } else if (languageType == 13) { bundlePath = [[NSBundle mainBundle] pathForResource:@"ar" ofType:@"lproj"]; } else { bundlePath = [[NSBundle mainBundle] pathForResource:@"en" ofType:@"lproj"]; } NSBundle *bundle = [NSBundle bundleWithPath:bundlePath]; return NSLocalizedStringFromTableInBundle(key, @"Localizable", bundle, desc); } } @end