I have an Application with 2 targets. String resources in the app are scattered across the code and storyboard file. Now I need totally distinct set of strings for both the targets (Although in English language though for both targets). I was able to create 2 different versions of Localized.strings per string following this link - Alternative strings for different targets of same App - use NSLocalizedString?
But I could not find any such similar approach for segregating the Mainstoryboard.strings file per target. Should i make 2 copies of the MAinstoryboard.strings file and assign for each target. I haven't tried this this but something tells me that this might not be the best approach.
Surprisingly nothing on this on Apple tutorials. Any suggestions ?
A code snippet for adding a fake language that could be the solution:
language = Bundle.main.preferredLocalizations[0]
if target == SOME_TARGET {
if language == "en" {
language = "fr" // fake language
} else if language == "ar" {
language = "rs" // another fake language
} else {
// default app language
language = "whatever" // default fake language
}
UserDefaults.standard.set([language], forKey: "AppleLanguages")
UserDefaults.standard.synchronize()
} else {
// do nothing
}
Another proposed solution. Is to have two storyboard localisation files for each language. and replace them manually using the OS X finder when you switch between targets. But, I guess that wont help for the strings on the storyboard itself.
I did make a Github project for Localization problems.
Using my iOS components, you will be able to put localizedString directly in your Storyboard file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With