Internationalization with iOS

As we know, Apple ships its products all over the world and two-thirds of Apple’s users are outside the U.S. We have users all over the place from New York to New Zealand and Dubai to Durban. And two-third of these users are most likely to be use your apps if they were in their native languages. This makes it really important to ensure that the linguistic experience is right in your apps. Apple continues to extend and expand its support. With iOS 10 Apple is offering multilingual keyboards. Apple also localized the keyboard number pads this year.

Another great enhancement is the new measurement for matter that is added in foundation and this will take care of unit conversions in a language and region aware manner for you all under the hood, and it already supports more than 20 different units like temperature, energy, pressure, etc.

So, what are the various aspects that you would need to internationalize here for this app to work in different languages and countries?


  1. Localized Strings

    First of all, we need to localize the strings. This is basically any button or tab or view that has a string in it, we need to make sure that it’s translated into all the different languages you’re going to be supporting. Let’s assume that we have got our setup for localization, so we have got some localized strings in your app. If you’re using storyboards with Base Internationalization, you’re done. There’s nothing you need to do – you launch your app and the strings get loaded. If not, see <link> for a how-to.Load strings for views created in code using NSLocalizedString, which uses Bundle’s language matching logic

    // Set localized string to label
    label.text = NSLocalizedString("World Clock", comment: "Title text")

    We want to double check that everything we have done is actually localized. To do that, We can use the new static analyzer in Xcode 8, which will actually find any issues that you have with localizability, where you’re feeding non-localized strings into the UI. And that’s all there is to localized strings.


  2. Formatted Strings

    Then there’s another category of string that needs to be localized but it is formatted content and so we should use formatters to achieve that. Here’s a quick example of a Date and Time Formatter code, that does not leverage best practices of Internationalization

    // Date & Time
    var formatter = DateFormatter()
    formatter.dateFormat = "hh:mm a"
    let str = formatter.string(from: date) // 9:41 AM for English (U.S.)

    The problem is actually that we’re using this method which is formatter.dateFormat setting a fixed format on it. The correct approach for this is to just use the predefined short style on the date formatter.

    formatter.timeStyle = .shortStyle

    There are more Built-in time styles:

    .shortStyle, .mediumStyle, .longStyle, .fullStyle

    And of course, not just for times. For dates, also, we have the whole range of styles going from short to long.

    And also, Custom Style –

    formatter.setLocalizedDateFormatFromTemplate("yMd")  // 6/14/2016
    formatter.setLocalizedDateFormatFromTemplate("dM") // 6/14
    formatter.setLocalizedDateFormatFromTemplate("dMMM")  // Jun 14
    formatter.setLocalizedDateFormatFromTemplate("EdMMM") // Tue, Jun 14

    Some of the other formatters that are commonly used include:

    • TimeFormatters
    • Date Formatters
    • DateComponentsFormatter
    • DateIntervalFormatter
    • ByteCountFormatter
    • NumberFormatter
    • PersonNameComponentsFormatter
    • MeasurementFormatter


  3. Internationalize the layout

    Lastly, we need to internationalize the layout so that it will work well for right-to-left languages. These guidelines also apply to languages that have longer or shorter translations than the language you’re starting with.Now, using Auto Layout makes life simpler – It automatically lays things out. And so whether you’re in a left-to-right app, if you use Auto Layout you will get automatically a user interface for a right-to-left language.Use UIStackView as much as we can because these are very easy to use APIs that leverage Auto Layout and make sure that your views will flip in the right way for right-to-left languages and adjust appropriately when they get long and shorter strings.In a future article, we will add details on Tall Scripts and Multi-Line Labels


    • Localize your app to reach a wider audience
    • Use Bundle and Formatter APIs
    • Flexible layout to accommodate taller and wider languages
    • Design world-ready iconography
    • Localize your app’s name and screenshots!


Important Video Links


Some Code


Thanks, Happy Coding….

Loading Likes...