ios – Localized .strings file in a bundle return en.lrproj, even when operating in non-English language. Utilizing the identical file immediately with out bundle works


I am presently engaged on an iOS challenge in Xcode the place I’ve created a useful resource bundle containing a translated .strings file (let’s name it myTexts.strings). This bundle is then reused in a number of targets (as I plan so as to add a number of translation information, to raised separate particular app areas).

When I attempt to entry a localized string with the next line of code:

NSLocalizedString(key, tableName: "myTexts", bundle: bundle, remark: remark)

The string isn’t discovered. Moreover, once I try and listing the obtainable .strings information with the next code:

bundle.paths(forResourcesOfType: "strings", inDirectory: nil)

It solely returns the file in en.proj, regardless that the app is operating in Czech language (i.e., I count on to see cs.proj).

Nonetheless, once I take away the bundle, embrace the .strings file immediately in all targets, and run the app on a tool set to Czech, it really works completely positive — the bundle.paths(forResourcesOfType: "strings", inDirectory: nil) perform appropriately lists cs.proj, and the czech string is appropriately regarded up.

I’ve checked the construction of my bundle and ensured that it accommodates the cs.lproj listing. The constructed app additionally has the *.lrpoj for all of the languages. I am additionally assured that I am initializing my bundle object appropriately, utilizing the trail to the useful resource bundle:

let bundlePath = Bundle.essential.path(forResource: "TheBundleName", ofType: "bundle")
let bundle = Bundle(path: bundlePath!)

Regardless of all this, I am nonetheless encountering the issue. I am curious to know why that is occurring and what I can do to make it work with the bundle. Any insights or recommendations could be drastically appreciated. Thanks!