App Localization: Reaching a Global Audience with Swift

Moussa Hellal
3 min readJun 18, 2023

--

Application localization is essential for reaching a worldwide audience because it removes language barriers, improves user experience, promotes engagement, gives businesses a competitive edge, makes apps easier to find, fosters credibility and confidence, and raises income prospects.

In this post, we’ll look at how to localize your iOS apps using Swift.

We will go step by step with screenshots on how to setup your project to support multi languages.

However, if you want to download the end result project for this please make sure to scroll to the bottom of this article you will the Github link there.

First Step:

Create an Xcode project.

Second Step:

Create a new file.

Make sure to input “string” in the search box to get the file format that we need for the localization and make sure to name it Localizable.

Third Step:

Click on our newly created file Localizable

Go to the side menu and click on Localize.

Choose English and hit Localize button. That’s it, now you have you can start setting other languages. How? Next step.

Fourth Step:

Go to Project -> Click on Info -> click on “+” under Localization, and choose the language you wish to add in our case we are adding Arabic.

Then,

Click on finish and Voila! you will notice another file created! alongside you original Localizable file.

Try to add more languages yourself following the same steps.

As you can see we have 7 languages now.

Add the the hello key in every added language, and translate it.

"hello" = "Hello!";

Now let’s add our localized extension property to String: you can create a new file called String+Extensions.

This is simply will take the original string and get the localized string from our localization files.

import Foundation

extension String {
var localized: String {
NSLocalizedString(self, comment: "")
}
}

Now to the last step Check you ContentView.swift and modify the TextView taking of our new extension property .localized.

The fun part you can use this with any string in your project.

Text("hello".localized)

DONE! now your turn try it your self in different languages by changing the device settings.

Project Link:

https://github.com/MoussaHellal/SwiftAppLocalization

I appreciate you choosing to spend some of your day with me. I hope that my piece was informative and helpful to you.

Farewell, keep growing and learning. See you in the next one. ✌️

Make sure to follow me on Twitter to keep receiving the newest articles:

https://twitter.com/mosesCodeOs

--

--