When an Xcode project of iOS app is newly created, in the project (not target) setting we can see that it has Use Base internationalization
enabled by default, and there are 2 files localized for the Development Language
which is English
by default (one for Main.storyboard
and one for LaunchScreen.storyboard
, both of which reside in the Base.lproj
directory). See below the screenshot:
(For simplicity, I will only mention Main.storyboard
from now on.)
And in the localization section of Main.storyboard
's right-side panel, we can see that the Base
localization is checked by default and there is also an English
localization which is unchecked by default. See below the screenshot:
And in the target's Info.plist
, there is a key named Localization native development region
(i.e. CFBundleDevelopmentRegion
), and its default value is en
. See below the screen shot:
If I understand it correctly, with these default settings, developer can just write English in the Base
localization of Main.storyboard
and leave the English
localization as unchecked. If the app needs to adapt to some other language, developer can add a localization in the project localization setting, and select Main.storyboard
in the popped up dialog. See below the screenshot:
Take Chinese (Simplified)
as an example, this will result in a newly created directory zh-Hans.lproj
with a Main.strings
file inside it. (For simplicity, I will refer to it as Chinese
instead of Chinese (Simplified)
.) Developer just needs to translate the English strings inside this file into Chinese (the newly created Main.strings
in the zh-Hans.lproj
directory by default has all the English texts duplicated from the Main.storyboard
in Base.lproj
). With these settings, the Language
field in the description of this app on AppStore will list English (from the Base
localization, because English is the development language
) and Chinese (from the Chinese
localization). On end-user's device, if the system language is English/Chinese (or English/Chinese is among the preferred language), the app will use the corresponding language resource (for English, use the Base
localization; for Chinese, use the Chinese
localization). For all other language preference, English will act as the fallback language because CFBundleDevelopmentRegion
is en
, so Base
localization is used.
So my first question will be, is the above understanding correct? To summarize, with the development language
being English, we don't need to enable English
localization for storyboard files. Just use the Base
localization and directly write English in the storyboard files. We only need to add localization for languages other than English. (Actually it seems troublesome if we enable the English
localization. If English
localization is enabled, then we need to maintain both the texts in Base.lproj/Main.storyboard
and en.lproj/Main.strings
.)
If the above understanding is correct, my second question will be, how to achieve internationalization in a reverse way? That is to say, if I would like to use Chinese
as the development language
and write Chinese in the Base
localization, and only add localization for languages other than Chinese
, is it possible and how to do that in Xcode? I can't find a way to change the development language
in the project setting in order to claim that the Base
localization in the project is Chinese
rather than English
.
Select your project file in Project Navigator, and select your project in the project and targets list. Open Info tab, and click “+” button under Localizations section. Then choose a language you want to support from the dropdown list shown. XCode opens a dialog showing resources to be added for the new language.
There is also a concept called a “Base” localization. Xcode will by default add a directory called “/Base. lproj” to your project. The purpose of this directory is to hold the default layouts of your views (i.e. storyboards/XIBs) in your “development language”.
Using Base Internationalization. Base internationalization separates user-facing strings from .storyboard and .xib files. It relieves localizers of the need to modify .storyboard and .xib files in Interface Builder.
Your understanding is mostly correct. One small clarification: if the user is running in some third language, like Russian, it is not necessarily true that the app will run in English. Instead, the app will run in the first language it supports that the user prefers. As of iOS 8 and later, users can have a list of preferred languages, such as "Russian, French, Chinese, English". In the case of this hypothetical user, the app would actually run in Chinese, since it is earlier in the list than English.
To answer your question regarding changing the development language, this isn't straightforward to do but can be done. Specifically:
Info.plist
(as you observed), change the development region to the language that you want to be your base language. Note that the property is a bit misnamed, because its value should be a language code (with an optional country code), rather than a region or country code.projectname.xcodeproj/project.pbxproj
and search for developmentRegion
. You should see a line like developmentRegion = English;
. Change this to reference the same language you put in your Info.plist
file.Here's an example of the result for me using fr
as the Base language:
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