Reputation: 1066
I have an app that is designed with an English user interface and additionally got a German UI translation. When running, the correct user interface language is chosen. Base Internationalization is used, Xcode 8.2.1, Swift 3.
Then I cloned the app into a new one, mainly stripping off parts and renaming the app. This was quite a PITA (sorry) with the main problem being CocoaPods not recognised anymore (error on import
) etc. After some fiddling it works again, but the UI is always in German(!), regardless of the iOS Settings. Even if iPhone language is English, with no other preferred languages, and region is United States, the app UI shows up in German.
Strangely, the strings used in the app (via NSLocalizedString()
) are correctly chosen in English.
Bundle.main.preferredLocalizations.first
also returns en
.
Addendum:
The system dialogs presented by the app are in English.
The key CFBundleDevelopmentRegion
is set to en
in Info.plist
.
The UI texts in Base.lproj/Main.storyboard
are in English.
Same behaviour on simulator and real devices.
I suspect that the English (Base) UI has become kind of unavailable during the process. However, in Interface Builder the English version is shown as "Main Storyboard > Main Storyboard (Base)" with a sibling file "Main.strings (German)" containing the translation.
Addendum 2: In Project → Info → Localizations, I can see "English — Development Language: 2 Files Localized" but "German: 5 Files Localized". Maybe that's the reason why some resources are not available in English at runtime. But I cannot determine which files are meant by the entries.
If I "Export for Localization", I get an xliff
file with these 5(!) headers (XY
being the project name):
<file original="XY/Base.lproj/LaunchScreen.storyboard" source-language="en" datatype="plaintext" target-language="de">
<file original="XY/Base.lproj/Main.storyboard" source-language="en" datatype="plaintext" target-language="de">
<file original="XY/Info.plist" source-language="en" datatype="plaintext" target-language="de">
<file original="XY/Localizable.strings" source-language="en" datatype="plaintext" target-language="de">
<file original="XY/Main.strings" source-language="en" datatype="plaintext" target-language="de">
Any hints?
Upvotes: 3
Views: 2045
Reputation: 666
You may have to edit your scheme. Next to your Build / Run and Stop Buttons, click on your Application and click Edit Scheme.
In the window that pops up, make sure you're on the Run Tab.
Now in the Run Tab, there should be 4 other Tabs in there (Info, Arguments, Options, and Diagnostics) - make sure you're on the Options Tab!
In the Options Tab, scroll down and you should see Application Language. In my case Application Language was set for Spanish which made it so that no matter what, my app would build localizing with the Spanish language. Changing Application Language to System Language made it so that the builds work as expected, working with whatever language my device is using at the time.
Hope this helps someone!
Upvotes: 3
Reputation: 2640
Try setting CFBundleAllowMixedLocalizations
to yes
in your Info.plist
Upvotes: 4