Reputation: 25938
Approach
I have implemented localization using string file as given below:
Question
Is this possible to add new language file at runtime?
Upvotes: 1
Views: 603
Reputation: 3973
You can just create the proper bundle directories and strings files yourself and use the longer version of NSLocalizedString.
An approach is described here by 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
Upvotes: 1