Is there a way to invalidate NSBundle localization cache, withour restarting application? [iOS]

后端 未结 2 732
悲哀的现实
悲哀的现实 2021-01-03 04:43

Let\'s assume that we can change in runtime Localizable.strings, that is placed in NSBundle At the current moment, even if we change it\'s contents, NSLocalizedString

2条回答
  •  既然无缘
    2021-01-03 04:55

    You can use the uncache solution.

    use Localizable.nocache.strings in your lproj folders.

    e.g. example.bundle/Resources/de.lproj/Localizable.nocache.strings

    loading localized strings after getting url via FileManager.

    func localizedString(key: String) -> String {
       let bundle = Bundle(url: bundleUrl)
       return bundle.localizedString(forKey: key, value: nil, table: "Localizable.nocache")
    }
    

提交回复
热议问题