添加guard 蒙层

This commit is contained in:
2025-11-27 15:34:33 +08:00
parent 2435d760e8
commit 2760a070a3
8 changed files with 270 additions and 11 deletions

View File

@@ -47,6 +47,8 @@ extern NSString * const KBLocalizationDidChangeNotification;
/// 基于一组“偏好语言”计算最佳支持语言。
- (NSString *)bestSupportedLanguageForPreferred:(NSArray<NSString *> *)preferred;
- (void)reloadFromSharedStorageIfNeeded;
@end
/// 便捷宏:与 NSLocalizedString 类似,但遵循 KBLocalizationManager 当前语言

View File

@@ -177,4 +177,14 @@ static inline NSMutableDictionary *KBLocBaseKCQuery(void) {
return lang;
}
- (void)reloadFromSharedStorageIfNeeded {
NSString *saved = [[self class] kc_read];
if (saved.length == 0) return;
if ([saved isEqualToString:self.currentLanguageCode]) return;
[self applyLanguage:saved];
[[NSNotificationCenter defaultCenter] postNotificationName:KBLocalizationDidChangeNotification
object:nil];
}
@end