The best approach for localizing resources in a pod (public or private is indifferent) is to add the .strings
localization files to the pod bundle.
The main app is very picky when comes to pick up the localization files from the pod frameworks, here the steps you must follow:
1 - Create the Localizable.strings and all the other *.strings
files you need for your localization and put them in a folder, something like this:
Some constraints to respect:
- The folders name must be
XX.lproj
, where XX is your EXACT language name, note: en
!= en-GB
!= en-US
- All the
lproj
folder need to be at the same level
- Every
lproj
folder need to have the same number of .strings
files and with the same names
2 - Configure your .podspec
file so the pod can pick up the localization correctly and copy them in the .framework
.
Example:
s.resource = 'your_path/Localizations/**/*', '... possibly other resources'
after doing pod install
the result in your Development Pods folder should be something like this:
One important thing to check is that created framework is that all the .lproj
folder need to be on the root folder, otherwise are not picked up correctly by the main app.
3 - In your pod's code instead than the usual NSLocalizedString
you must use NSLocalizedStringFromTableInBundle
:
NSLocalizedStringFromTableInBundle(@"My string", nil, [NSBundle bundleForClass:[MCLoginContext class]], @"String context")
The entire process is very delicate and annoying, but that's should be all.