Override a base localizable.strings file

后端 未结 2 1839
庸人自扰
庸人自扰 2021-02-11 03:15

Is there a way to have one base localizable.strings file for multiple targets within a project, and also have a second localizable.string file for each target that will override

2条回答
  •  庸人自扰
    2021-02-11 04:07

    For Swift 4 users that come across this issue...

    func localizedString(
        for key: String, tableName: String = "OverrideLocalizable", 
        bundle: Bundle = .main, comment: String = ""
    ) -> String {
        let defaultValue = NSLocalizedString(key, comment: comment)
        return NSLocalizedString(
            key, tableName: tableName, bundle: bundle, 
            value: defaultValue, comment: comment
        )
    }
    

提交回复
热议问题