Roymunson Roymunson - 5 months ago 12
iOS Question

Is it necessary to have a Localizable.strings file if you do not want to localize any strings?

I am learning how to make IOS apps from an Android background. In Android you should put most/all of your strings that are visible to the user in a

strings.xml
file even if your app is not going to be translated.

That means if you set the title of a button/set the text of the Android equivalent of a "UILabel" you will fetch the string from the
strings.xml
file.

I am not going to localize my IOS app. Since this is the case, is it normal to just do:

exampleUIButton.setTitle("Test string", forState: .Normal)


Or should "Test String" be stored in a
Localized.strings
file?

Answer

While not mandatory using Localized.strings is a very good habit to get into. It will it be much easier to add localizations should you change your mind later, because you don't have to search your entire project for strings. With it you have all your strings in one location. And the difference in code is really not that big:

exampleUIButton.setTitle("Test string", forState: .Normal)

vs

exampleUIButton.setTitle(NSLocalizedString("str_test", comment: ""), forState: .Normal)

Other benefits are ease of sharing sets of strings between projects, spell checking and increased visibility of strings in the editor.

Comments