← All daysDay 45 of 49 · Part 11: Platform features and shipping
Day 45

Localization

These are the lesson notes for this day. Its build-along tutorial and flash cards have not been written yet.

Lesson 51

Localization

String literals in Text, Button, and similar views are localizable automatically. Xcode collects them into a String Catalog (a .xcstrings file), where you add translations and plural forms. Use formatters for numbers, dates, currency, and measurements so that they follow the user's locale. Your layouts have to tolerate longer text — German runs about 30% longer than English — and right-to-left languages, which SwiftUI mirrors for you provided you use leading and trailing rather than left and right.

Exercise

Add a second language to one screen using a String Catalog, including one plural. Preview the screen in that language, and in a right-to-left pseudo-language.

After this lesson you should be able to answer
  1. How do the strings in a SwiftUI view get into the String Catalog?
  2. How do you handle plurals?
  3. Why use .leading rather than .left?
Resources