How to make an iOS application localized without a storyboard?

I followed various tutorials on "How to localize an iOS application (iPhone) . " All of them suggested the following steps:

  • Select a project from Project Navigator
  • Check the box next to "Use basic internationalization."
  • Select a storyboard for localized strings.

But my xcode 7.2 app project for iOS does not contain a storyboard, so I cannot enable "Use basic internationalization" in my iOS app.

Please help me how to enable “Use basic internationalization” without selecting a storyboard and what to do to perform various alerts in order to localize them using the “Localizable.strings” file.

+5
source share
2 answers

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

now

  • Now go on to setting up the project again ... then select the project instead of the goal in the setting ... Where you have only two options ... Go to the information section where you will find localization ... add your language here for localization.

  • the created file is already in the basic internationalization mode ... now go to the file and right-click the localization button in the sidebar ... click on it and select the language that you added to your project.

  • now this file adds a drop-down menu in it .. click on the arrow ... which will show you the localized .string file now the first is basic English ... which is the default and second localized string file ...
  • copy all the text you print in both files as follows

Base file-> "Enter a search keyword" = "Enter a search keyword"; Localize file → "Enter the search keyword" = "Localized string";

now, to use this localized string, you can get strings like this

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

Note. The string file should have the name "Localizable" ... if you do not save it with that name ... this will not work .. and you must provide a path every time you use a localized string

+8
source

Thanks Divyanshu Sharma .
Here are the steps for Xcode 8 (Swift 3).

  • File> New> File ... (⌘N)
  • Go to the "Resource" section and select "String file", click "Next"
  • Save it as "Localizable.string" in your project
  • In the Project Navigator, select the new file "Localizable.string" (usually already selected after creating a new file).
  • Go to View> Utilities> Show File Inspector (⌥⌘1)
  • Find the localization and select "Localize ..."
  • Choose your base language (I chose English), then click "Localize"
  • Open the project information settings and in
  • Click (+) to add a new language to the "Localization" section.
  • Select "Localizable.string" and click "Finish" in the window to select a localized resource

You should now have default localizations without a storyboard.

+3
source

Source: https://habr.com/ru/post/1240591/


All Articles