Non-english Localizations Won't Load in Framework

We have a Framework that we sell to clients. We have a separate bundle that we ship with the Framework. That bundle contains localizations for multiple languages.


This is how we use localized strings:

NSLocalizedStringFromTableInBundle(keyString, nil, myBundle, nil);


Right before I access the localized string I print this for debugging purposes (it is definitely finding the bundle):

Bundle: NSBundle </Users/spentak/Library/Developer/CoreSimulator/Devices/367938EC-DDB6-4C32-938D-15C2D9F53560/data/Containers/Bundle/Application/A3F649DC-5FA9-414E-BE8C-7A6D66A8A857/Triangle_objc.app/AppNotice.bundle> (not yet loaded)


When the language is set to English, the localizations load. But when I switch it to "es" this is the log that prints when I turn on localization debugging:


Localizable string "app_dialog_button_decline" not found in strings table "Localizable" of bundle CFBundle 0x7fac41d50270 </Users/spentak/Library/Developer/CoreSimulator/Devices/367938EC-DDB6-4C32-938D-15C2D9F53560/data/Containers/Bundle/Application/1EF26DBB-430B-4614-A847-90CC657C63AF/Triangle_objc.app/AppNotice.bundle> (not loaded)


So the question is, why is my English localization working, but not my other languages? (The key in localizable.strings is definitely correct)


This is what my bundle looks like when imported in a project that uses the Framework:

http://i.imgur.com/EdcLeFA.png



If I test these localizations OUTSIDE of the framework - meaning in a regular project they all work. Just appears that the framework is having issues loading localized resources.


Tried this on Xcode 7 and Xcode 7.1 Beta 3


The Base SDK of the framework is Latest iOS (iOS 9.1)


Thoughts?

Replies

Is the host app localised in Spanish?

Generally the system tries to avoid displaying different parts of the app in different language, so a framework’s localisation for a particular language will only be used if the host app is running in that language.

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

I have a similar problem. I have a work around, but I don't like it.


I have a cross platform (iOS, watchOS and macOS) app. So I created a framework in Xcode and put the share files, the source code that works in all platform, into the framework.

Then I translated them. The app works fine. The only issue is that the translated string resources in the framework are never used by the app.

If I copy the content of the string resources out of the framework and insert them in to the app's string resources, it works. But I don't think it is a good idea to do things in that way.

Any idea on how to making the app use the string resources in the framework directly?

Is this on purpose or it is a bug that I should file to Apple?

Xcode 9.1 (9B55), macOS High Sierra 10.13.1 (17B48) Swift 4.0.2


A sample project can be found here. https://www.dropbox.com/s/c6bdp28rmk9rxii/Framework%20Translation%20Issue.zip?dl=0

The OS tries hard to avoid mixed localisations. If you have a framework localised for languages A, B, C, D and E and an app localised for B and E, the app will run in language B or E and that means that the framework’s strings for A, C and D will never be used. So the question here is, what languages is your app localised for?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"