How to use String Catalogs for pluralization in Swift
Learn about pluralization and variables in String Catalogs.
10 Jul 2023 · 3 min read
At WWDC23, Apple introduced String Catalogs which replaces the way we add localization to iOS projects. In the previous article on how String Catalogs work, we covered the basics on localization with String Catalogs.
In this article, we'll look at how we can use them for pluralization.

Before String Catalogs, we had to use .stringdict files to add localized pluralization support. To learn how that worked, check out this article on how to localize plurals by using the Localizable.stringsdict file.
String Catalogs come with built-in support for String pluralization. To localize plurals with String Catalogs, we have to:
- Define a format specifier within the localization key, for example applesSelection.title.%lld
- Use the format specifier within the translations, for example %lld apples
- Right-click on the created key-value and choose Vary by plural:

- Xcode prefills all values for us. What's left to do is to adjust the translations for different pluralization cases:

Now, we can use the localized String as follows:
LocalizedStringKey("applesSelection.title.\(5)")
In case we need pluralization for more than one value in a String, we can use variables:

Xcode provides options to create variables when we add more than one format specifier. We can also define them by enclosing the variable name as follows: %#@applesCount@

Newsletter
Like to support my work?
Say hi
Related tags
Articles with related topics
Latest articles and tips