SDK内本地化处理 localizedStringForKey:value:table:

参考:

1,https://developer.apple.com/documentation/foundation/nsbundle/1417694-localizedstringforkey

2,MJRefresh

原理:
1,找到本地化字符串表(string table)对应的 bundle,例如,en.lproj

2,调用系统提供的在string table中值的方法

[targetBundle localizedStringForKey:key value:value table:nil];

value和table一般都是nil。

value的作用是找不到key后的提示。

如果value为nil,找不到key提示为@"" 空字符串。

value可以这样设置下

value = [NSString stringWithFormat:@"%@ 对应的本地化字符串没有在%@ 中找到",key,targetBundle];

The receiver’s string table to search. If tableName is nil or is an empty string, the method attempts to use the table in Localizable.strings.

tableName传入nil,会在bundle的Localizable.strings里查找。

猜你喜欢

转载自www.cnblogs.com/huaida/p/12801159.html