[英]How to programmatically get the localized string as it displayed in iOS Settings App?
[英]How to get localized description string of file size in iOS?
以下是我的代碼:
- (NSString *)fileSizeDescriptionForFileAtPath:(NSString *)filePath {
NSError* error;
NSDictionary *fileDictionary = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath
error: &error];
NSNumber *size = [fileDictionary objectForKey:NSFileSize];
NSString *desc = [NSByteCountFormatter stringFromByteCount:size.longLongValue
countStyle:NSByteCountFormatterCountStyleFile];
return desc;
}
這段代碼是否可以正確格式化任何本地化的文件大小?
我在NSByteCountFormatter
文檔中沒有找到有關格式化字符串已本地化的參考。
感謝您的任何建議。
因此,我嘗試了使用幾種語言環境的上述代碼,並且結果看起來完全本地化了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.