添加guard 蒙层
This commit is contained in:
@@ -47,6 +47,8 @@ extern NSString * const KBLocalizationDidChangeNotification;
|
||||
/// 基于一组“偏好语言”计算最佳支持语言。
|
||||
- (NSString *)bestSupportedLanguageForPreferred:(NSArray<NSString *> *)preferred;
|
||||
|
||||
- (void)reloadFromSharedStorageIfNeeded;
|
||||
|
||||
@end
|
||||
|
||||
/// 便捷宏:与 NSLocalizedString 类似,但遵循 KBLocalizationManager 当前语言
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user