ios - 动态添加新的语言字符串文件以在 iOS 中进行本地化

标签 ios xcode localization internationalization mainbundle

方法 我已经使用字符串文件实现了本地化,如下所示: enter image description here enter image description here

问题

是否可以在运行时添加新的语言文件?

最佳答案

您可以自己创建适当的包目录和字符串文件,并使用较长版本的 NSLocalizedString。

approach is described here亚历杭德罗·马丁内斯:

// The two important new parameters are `tableName` and `bundle`. 
// By default when using NSLocalizedString the system uses the App 
// main bundle and the Localizable table, *table* meaning the name 
// of the strings file. So to hook into the localization system we 
// just need to convert the object structure that we have in memory 
// to the proper file hierarchy that is expected on disk.
NSLocalizedString(_ key: String, tableName: String? = default, 
  bundle: Bundle = default, value: String = default, comment: String)
  -> String

关于ios - 动态添加新的语言字符串文件以在 iOS 中进行本地化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50810193/

相关文章:

ios - 如何使用 ScrollView 和 pageController 显示图像和信息

ios - build设置中缺少 Xcode 12 beta 有效架构

c# - 为什么 MenuItems 不能与 DynamicResource 一起使用?

java - 如何在java中本地化基于xml的文件?

ios - 为什么在下面的UITableViewCell的方法实现中我们使用静态实例?

ios - Xcode:应用程序构建但不会运行并且无法在方案中选择可执行文件

ios - 使用 NSURLSession 下载后,将图像设置为对象

ios - 我的 xcode 工具中没有显示 iAdBannerView

ios - 无法将 Controller 链接到自定义类

c# - 如何管理在 C#/WPF 中看起来相似的本地化字符串?