Chapter 24
Localizing Your App to Support Multiple Languages

Good code is its own best documentation. As you're about to add a comment, ask yourself, "How can I improve the code so that this comment isn't needed?" Improve the code and then document it to make it even clearer.

- Steve McConnell

In this chapter, let's talk about localization. The iOS devices including iPhone and iPad are available globally. The App Store is available in more than 150 countries around the world. Your users are from different countries and speak different languages. To deliver a great user experience and reach a global audience, you definitely want to make your app available in multiple languages. The process of adapting an app to support a particular language is usually known as localization.

Xcode has the built-in support for localization. It's fairly easy for developers to localize an app through the localization feature and a few API calls.

You may have heard of the terms: localization and internationalization. You probably think that both terms refer to the process of translation; that's partially correct. In iOS development, internationalization is considered a milestone in building a localized app. Before your app can be adapted to different languages, you design and structure the app to be language and region independent. This process is known as internationalization. For instance, your app displays a price field. As you may know, some countries use a dot to indicate decimal place (e.g. $1000.50), while many other countries use a comma instead (e.g. $1000,50). The internationalization process involves designing the price field so that it can be adapted to different regions.

Localization is the process of adapting an internationalized app for different languages and regions. This involves translating static and visible text to a specific language and adding country-specific elements such as images, videos, and sounds.

In this chapter, we'll localize the FoodPin app into Chinese and German. However, don't expect me to translate all the text in the app - I just want to show you the overall process of localization using Xcode.

Introducing String Catalogs in Xcode 15

With the release of Xcode 15, Apple introduced an exciting feature called String Catalogs. This feature aims to streamline the localization process for your app, making it easier than ever to manage all your strings in one central location. By leveraging String Catalogs, you can ensure that your app is fully localized before it reaches your users. This new feature offers both convenience and confidence in the localization process.

Before we proceed with the implementation, let's examine the user-facing text within the app. There is a significant amount of user-facing text present in the source code, such as the text fields displayed in the "New Restaurant" form. Figure 24-1 showcases a few examples of user-facing texts found in the NewRestaurantView struct.

In earlier versions of Xcode, you have to go through a string internationalization process that requires to modify the existing texts with the String(localized:) macro. However, with the introduction of String Catalogs, this process is no longer necessary. String Catalogs automatically extracts all user-facing texts for you, eliminating the need for manual modifications.

To access the full version of the book, please get the full copy here. You will also be able to access the full source code of the project.

results matching ""

    No results matching ""