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里查找。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM