I am new to coding in Objective-C, but am coming from the Java world of mobile development. In Android, we use a strings resource, and then point to those in the Java class. Is there an analogous process in iOS that we should be using, or do we “hard-code” the strings into the implementation files? I haven’t yet found a good tutorial using the localizable string (and .strings) file.
Share
You can use the NSLocalizedString macro from Foundation to retrieve a localized string. Read here:
http://www.icanlocalize.com/site/tutorials/iphone-applications-localization-guide/
Example: build a bilingual (English-French) app.
Whenever you encounter a string to be displayed to the user, use NSLocalizedString instead of the actual string constant. For example:
instead
use
Create two directories inside your app bundle as follows:
In the first Localizable.strings file you can write key-value pairs like this:
In the second one:
When you add these files and folders to your application, an recompile it using the NSLocalizedString macro, you’ll be able to use your app in French also when the system language is French.