如何获取本地化的 CFBundleDisplayName
[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]
此 API 返回 plist 中的捆绑包显示名称。
但是我的应用程序已本地化并且具有不同的显示名称。
所以我需要在 InfoPlist.strings
中获取本地化的显示名称,该名称应随设备语言设置而变化。
[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]
this API returns Bundle Display Name in plist.
However my app is localized and has different display name.
so i need to get localized display name in InfoPlist.strings
that should vary with device language setting.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您尝试过
-[NSBundle localizedInfoDictionary]
吗?Have you tried
-[NSBundle localizedInfoDictionary]
?对于 Swift 试试这个:
如果你还没有设置显示名称,也可以试试这个
有用的技巧:
Try this for Swift:
Also try this, if you have not set Display Name
Useful trick:
我建议使用
kCFBundleNameKey
:I suggest to use
kCFBundleNameKey
:使用此方法优于其他访问方法,因为它会在键可用时返回键的本地化值。
Use of this method is preferred over other access methods because it returns the localized value of a key when one is available.
这在 Swift 5 中工作得很好:
This works fine in Swift 5: