Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When is Base.lproj used?

Tags:

xcode

ios

swift

I am trying to understand Base.lproj but I am not still understanding it. If I create a new simple project with a view controller and Swift+Storyboard in XCode 6 beta 4 I get a Base.lproj folder out of the box containing the storyboard file.

I then add a simpel NSLocalizedString(...) in my view controller for testing purposes. This requires a Localizable.strings file. When I create one should I add it in the Base.lproj or should I add it in a specific language folder?

If I change the Localization native development region key in Info.plist to de for german and I no Localizable.strings file for de in the de.lproj folder it seems to fallback on Base.lproj if Localizable.strings file is found there. However, if I add a Localizable.strings file in the de.lproj folder but don't add the property (key + value) the app fails during runtime. It seems like Base.lproj isn't searched.

I don't understand which language Base is and when it is used? Is it only for Storyboard files?

like image 326
LuckyLuke Avatar asked Jul 28 '14 14:07

LuckyLuke


1 Answers

I was under the impression that base.lproj is used in cases where the current language/ localisation file does not have a property key. For instance if I do have Main_Title = "Title Text"; in base.lproj and absent in en.lproj while the current language is English, I assumed iOS will find it in base.lproj but that is not the case.

Your initial conclusion is correct:

  1. Base is only used when you did not support that language in localizable.strings
  2. The specific language localizable.strings folder is used when device/ app is using that language
  3. If you do not provide support for a specific file/ string key in a language and you have a folder for that language, it will throw run-time warning

In case of storyboard files and xibs if you only have base.lproj folder which contains your views, notwithstanding how many languages you support, it will not fail (this is what I am doing as well).

like image 166
ShayanK Avatar answered Nov 17 '22 03:11

ShayanK