Skip to main content
Logo Appt Light

Localization on iOS

Assistive technologies, such as the screen reader, use the locale for the pronunciation of utterances. It is important to explictly set a locale for your app. An incorrect locale leads to unclear pronunciation. Also, setting a locale can help with displaying characters correctly.

On iOS, you can set the locale of an app via the CFBundleDevelopmentRegion property. We suggest using Base internationalization to separate user-facing strings from .storyboard and .xib files. You can load a specific Bundle to load assets in the desired language.

For more information, see Adding Support for Languages and Regions.

extension String {
    func localized(_ language: String) -> String {
        guard let path = Bundle.main.path(forResource: language, ofType: "lproj"),
              let bundle = Bundle(path: path) else {
          return localized(Bundle.main)
        }
        return NSLocalizedString(self, tableName: nil, bundle: bundle, value: "", comment: "")
    }
}

Feedback?

Let us know!