In previous iOS versions, it was possible to access the localization of system resources on device by using the Bundle class.
For example, translating Done
into German was possible using the following code:
let bundle = Bundle(url: Bundle(for: UINavigationController.self).url(forResource: "de", withExtension: "lproj")!)!
print(" \(bundle.bundleURL)")
for file in try! FileManager.default.contentsOfDirectory(at: bundle.bundleURL, includingPropertiesForKeys: []) {
print(" \(file.lastPathComponent)")
}
let done = bundle.localizedString(forKey: "Done", value: "_fallback_", table: "Localizable")
print("Done in German: \(done)")
It was printing the following, just like expected:
file:///Applications/Xcode-14.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/de.lproj/
Localizable.strings
Localizable.stringsdict
UITableViewLocalizedSectionIndex.plist
Done in German: Fertig
Note that this technique is still working on the simulators (for example iPhone 14 Pro running iOS 16.4) but is not working on actual devices.
When running this same code on an iPhone 11 running iOS 16.5.1 I get the following output:
file:///System/Library/PrivateFrameworks/UIKitCore.framework/de.lproj/
UITableViewLocalizedSectionIndex.plist
Done in German: _fallback_
We can see that the translation fails because the Localizable.strings
and Localizable.stringsdict
have disappeared.
What happened to those files in recent iOS releases? Can we still access them somehow?