6
votes

I followed various tutorials on "How To Localize an iOS(iPhone) App". All of them were suggesting to perform following steps,

  1. Select your project from Project Navigator
  2. Click the checkbox for “Use Base Internationalization”
  3. Select your storyboard to Localizable Strings

But my iOS application xcode 7.2 project does not include any storyboard, so I am not able to enable “Use Base Internationalization” in my iOS application.

Please help me out how to enable “Use Base Internationalization” without storyboard selection and what should I do to perform various alert messages to be localized using "Localizable.strings" file.

2

2 Answers

11
votes

Go to project->New Files->Resource-> String File-> Save it as Localizable.string

now

  1. Now again go to project setting... then choose project instead of target in setting... Where you have only two options... Go in info section where you find localization... add your language here for localization.

  2. created file is already in base Internationalization mode... now go to file and in side bar of right side check localize button... click on it and chooose language which you added in your project.

  3. now this file add a dropdown in it.. click on arrow... which will show you localized file.string now first one is base english... which is default and second one localized string file...
  4. copy all text which you hardcode in both file like this

Base File-> "Enter a keyword to search" = "Enter a keyword to search"; Localize file -> "Enter a keyword to search" = "Localized String";

now to use this localized string you can fetch strings like this

label.text = NSLocalizedString("your String",nil);

Note:- string file should have name "Localizable"... if you not save it with this name... this will not work.. and you have to provide path every time you use localized string

8
votes

Thanks to Divyanshu Sharma.
Here is steps for Xcode 8 (Swift 3).

  1. File > New > File... ( ⌘N )
  2. Scroll to "Resource" section and choose "Strings File", press Next
  3. Save it as "Localizable.string" in to your project
  4. In Project Navigator select your new file "Localizable.string" (usually already selected after creating new file)
  5. Go to View > Utilities > Show File Inspector (⌥⌘1)
  6. Locate Localization section and select "Localize..."
  7. Choose base language (I chose English), then click Localize
  8. Open to Project Info settings and in
  9. Press (+) to add new language in Localizations section
  10. Select "Localizable.string" and press Finish in newly opened localizable resource selection window

Now you should have default localizations without Storyboards.