IOS: set a default language in xcode for my app - ios

I started my xcode project and I have these settings:
In xcode 5 it add this "base" language, but I don't understand how it works.
I want to set as my default language english and not italian; for example if an user set its device in spanish or in french language it must see app in english and not in italian;
can you help me?
thanks

SOLVED!!!
you should set "base" in in plist file section:
Localization native development region
and set Storyboard only for "base"; for other language only in Localizable String
when you localize a file you should set base (for language default) and the other language you want to use.
In localizations (picture in my question) should be with base and all language you want to use

Related

How to set Base Localization & Development Language in Xcode 12(.5)?

I'm writing this question because a lot of information on Stackoverflow (and even Apple's developer website) about this topic is unfortunately partially outdated:
I want to support multiple languages in my Xcode 12.5/Swift 5/iOS 12.3+ app: German as the default language and English as a "fallback".
Currently the "Info" tab lists two "Localization" languages:
The "Localization" section of the File Inspector for both my Main.storyboard and LaunchScreen.storyboard file look like this (by default):
"Base" is checked and that's why the first screenshot shows 2 files for it.
The language in Info.plist is set to the following:
So far I haven't touched the actual localization settings yet and I've been using the same language for every label,... in XIB (which is probably saved in "Base").
According to Apple's old Localization Guide, "Base" is the default language that is used, as long as it's included in the user's language settings (so in my case: German). The "Developer Language" is the "fallback" language that is used if the user's language settings don't include the base language (in my case: English). This Q&A page also says:
If you adopt Base Localization, make sure that the value of
CFBundleDevelopmentRegion matches the language used by your content in
the Base.lproj folder.
... and in this guide enabling the base localization for "English - Development Language" for both storyboards adds 2 localized files to it, without actually adding another ("Base") localization to the list. As you can see on my first screenshot, "Base" and "Development" are separate list entries, which wasn't the case in earlier Xcode versions.
My first question is: Did I understand all of this correctly? It's a bit confusing that the quote sees "Base" and "Development Language" as the same thing, even though you can of course have a default language that isn't the "fallback" language.
The same Q&A I linked above also goes into detail about regional versions of a specific language:
If my app supports "German" (language code: "de") but the user's language settings only list e.g. Austrian German ("de_AT"), then the app is still going to set its own language to German. Let's say I want to use Swiss German (de_CH) as the default language but the user only picked Austrian German ("de_AT") in his settings, does this still work the same way? Should you rather set your app's default language to the regular non-regional language (German = "de") instead, even if the labels,... use e.g. Swiss German words?
How do I change the "Base" language to German (let's say, "de_CH") and also make it appear as that in the list, while using English ("en") as the "fallback"? I did find a similar question but unfortunately the steps described in the answer don't work the same way in Xcode 12.5. anymore.
What I wanted to achieve:
Support English but use German as the default language that is also used if the user's language settings don't include English or German.
How I achieved this in Xcode 12.5:
Add "German (de)" to the "Localizations" list via the little "+" button. In the new Choose files and reference language to create German localization pop-up every storyboard file should already be ticked by default. This adds .strings (German) localization files for all storyboards in the Project Navigator on the left:
In Main.storyboard's File Inspector tick the "English" box in the "Localization" section (this might take a while). This adds an additional Main.strings (English) file in the Project Navigator. Repeat this step for each storyboard, including the launch screen.
To change the "Development Language", which is the language the app uses by default and also if it doesn't support any of the languages the user set in their device's language settings, close Xcode, then open the project's .xcodeproj file with a text editor (I used BBEdit, which is free). There should be a list of files, including project.pbxproj. Open it and set developmentRegion (= development language) to the language code of the language that you added in step 1, so in my case "de". Do not use a different code (e.g. add "German (de)" but set it to "de_CH") because that's going to create an additional localization.
There are now two ways to finish this part of localization:
A. Leave it as is. Changes in storyboard aren't going to affect any of the .strings files. Advantage: The text can be edited directly (without using storyboard), which is useful if you aren't the person who's working on the translations. Disadvantage: You can't quickly see and test the changes to a translation in storyboard but have to run the app in the simulator or on an actual device.
B. Use the default language as "Base" language: Untick "German" for every storyboard and hit "Remove" in the pop-up, which removes the localizations in the list. This way changes to the storyboard affect the default language, which makes it easier to test changes.
I used version B:
Important:
These .strings files are only used for storyboards! If you also want to set localized text at runtime using NSLocalizedString (e.g. for an error dialog), then you have to add an additional Localizable.strings file (more details here):
File - New - File - Strings File - Call it Localizable.strings
Click "Localize" in its File Inspector and pick one of the languages you want to use in code.
Afterwards, also in the File Inspector, you can tick the other languages in the "Localization" section (including the development one).
Bonus infos:
You can change the app language of the simulator through the scheme:
Product - Scheme - Edit Scheme - Run (left side) - Options tab (right side) - App Language
You can also show a preview of the currently selected UIViewController and change its displayed language without starting a simulator:
Editor - Preview - In the new preview window on the right there's a button in the bottom right
Disclaimer: I found this solution by testing different things, as there's currently no tutorial for this (using the latest Xcode version). If this is not the "right" way to do localization, please post your own answer and I'll check it out.

Localization in Swift, Base, German, English, what's the correct way to do it?

I have a project which is nearly completed.
The language I used in Storyboard and in code is German. I use Base localization (which is German because the Strings in Storyboard and Code are German). The App is also localized in English.
Basically I want that every non-German user can use my App in English but I also want to use German language in Storyboard and code.
For that, I set the Base localization to English (I set the language to "EN" in project.pbxproj, and I set the language to "United States" in the Plist file).
What I want is working but I think this is not the correct way to do it because in my current configuration Xcode thinks that my Base is English (because I set it to English) but in fact it's German.
If I would set the Plist file and the project.pbxproj file back to DE users which are not German and not English would have to use my App in German. Or am I wrong?
What's the correct way to achieve that German users can use my App in German and all others should see the English version.
I think you should set the base language to English, add German for additional languages, so the APP for any users uses German on the phone will display German. Otherwise, the APP for all users who do not use German will display the base language, which is English. I hope this will help you.
Check this to set up the development language on XCode.

Default language not working in iOS app

I have such problem:
I have localized my app for two languages - English and Polish, with English being set as the Base one.
I set developmentRegion to "en" (also tried "English") in both info.plist and project.pbxproj files.
My translated texts are contained within localized Main.strings and Localizable.strings files.
So everything should be fine, yet when I set any language other than Polish or English the app does not fall back to the Base (English) one, instead stays on the last used, supported language. (i.e. Polish if I recently changed from Polish to lets say French).
Can anyone help me ?
Ok I see now. I thought that whatever unsupported language I would set in system settings, my app would always revert to English (Base).
That's not true.
When selected language is not supported then the app is taking the language that is the highest on "Preferred languages" list in system settings. Only if none of these preferred languages is supported, then the base one is selected.

Change localizations of base storyboard to german swift xcode

I have an App which is nearly done and I only need to add localizations to it. The problem is that I have written it completely in German (because I am from Germany) and I don't have changed the development language. That means xCode thinks that everything I have done is written in English and not in German:
I have tried to set the CFBundleDevelopmentRegion to German and also to set the Localization native development region (in target) to german but nothing worked.
So my basic question is: I have an app written in German and how can I add an English and maybe other language support?
I was fighting with this for a long time but finally I think I found a solution for Xcode 7.
In general If you're developing language is different than English you have to make 2 things. After you create a new project in Xcode 7 quit Xcode and go to the terminal.
Edit the file in your project folder with your favorite text editor:
vi <your_project_name>.xcodeproj/project.pbxproj
Search for the key: knownRegions.
You should find something similar to:
knownRegions = (
pl,
Base,
);
Put your development language code on the first position. In general position is not important but I prefer that my native language be first. In Your case put there de. By default the first language in new project is en.
Next you should look for developmentRegion (in the same file) and change its value to “Polish" or whatever language you are using. In your case "Germany". What I noticed this makes Xcode to notice that your Development Language changes from English (default) to your language. After those changes save and exit text editor. Start the Xcode and point your eyes to Project -> Info tab. You should see something similar to this with Your native language set as Development Language.
Now open Info.plist. Edit the CFBundleDevelopmentRegion key and set its value to pl or de in your case.
Thats all. Now Your Base.lproj can contain resources in your native language. If you want a new Language just add it as usual.
Let me know if it working for you. I don't know how this little trick change your current project with existing translations but this is good point if you're starting new project.

Xcode using wrong localization

I have two localizations in my project: Base (which is in English) and Swedish. When I set my phone to Swedish it works, and when I set it to English it works. But when I set it to another language, for example German, it uses the Swedish translations instead of Base. Any ideas why?
I found the answer. In the phones settings, you don't just set the current language, you set language priorities. So if you've had Swedish and switches to another language, Swedish will be second priority and English lower.
Go to your target and then to the Info tab. Under "Custom iOS Target Properties" you will find an entry with the name "Localization native development region". This entry determines which is the default language, the one displayed in case that there in no localization resource for the selected language. Make sure that the entry is set to "en".

Resources