1

方法 我已经使用字符串文件实现了本地化,如下所示: 在此处输入图像描述 在此处输入图像描述

问题

这可以在运行时添加新的语言文件吗?

4

1 回答 1

1

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

Alejandro Martinez在这里描述了一种方法:

// 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
于 2018-06-12T09:28:11.050 回答