Member-only story

Localisation in Xcode 15

Jacob Bartlett
Better Programming
Published in
8 min readNov 8, 2023
Photo by Kyle Glenn on Unsplash

I mostly post to Substack these days. Subscribe now to receive non-paywalled, ludicrously in-depth articles on iOS, Swift, and indie projects every 2 weeks.

String Catalogs are a neat new feature introduced in WWDC 2023.

.strings files (and, to an even greater extent, .stringsdict files) were one of the final bastions of Objective-C-era cruft in the Apple development environment.

But no more.

I’ve been upgrading Bev, my trusty, boozy side project, to iOS 17. Along the way, I’ve been implementing the teachings from WWDC23’s Discover String Catalogs.

Join me on the journey!

The Bad Old World™

Prior to Xcode 15, most of your strings will be defined in a .strings file:

// Home screen
"home_screen_title"="Home";
"home_screen_button_add_friend"="Add friend";
"home_screen_button_settings"="Settings";
"home_screen_friends_list"="Your friends list";

You missed one semicolon?

Too bad, every string in your module is now broken, displaying home_screen_title or home_screen_button_add_friend in place of your actual copy.

.stringsdict files are even tougher to grasp. Because different languages have different grammatical rules for handling pluralisation, we need a far more complex beast to define a single string, even to say something as simple as “3 friends”:

<dict>
<key>home_screen_friends_count</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@friends_count@</string>
<key>friends_count</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>zero</key>
<string>No friends</string>
<key>one</key>
<string>1 friend</string>
<key>other</key>
<string>%d friends</string>
</dict>
</dict>
</dict>

Creating a String Catalog

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Jacob Bartlett
Jacob Bartlett

Written by Jacob Bartlett

I'm an iOS Engineer in London startups. Every 2 weeks, I'll send you ludicrously in-depth articles about iOS, Swift, tech, and indie projects.

Responses (1)

Write a response