While developing my new app, Wunderbar, I wanted to localize the app for German and Turkish. I already knew that I could just create a Strings file for each language and use keys for the texts in the app. But then I remembered that Apple introduced a new way of localizing apps called String Catalogs. I decided to give it a try.

It is very easy to use String Catalogs, you just need to create a new Strings Catalog file in Xcode, add the languages you want to support on Project > Info > Localizations, and then build your app. Xcode will automatically generate the keys for each language you added. The rest is just adding the translations for each key.

While testing my app, I realized that the texts that I used in Menu view were not listed in the Strings Catalog file because they were dynamicly generated from Enum values. First, I’ve tried to add the Enum values to the Strings Catalog file manually, but it didn’t work. Then after some research, I found out that I can use LocalizedStringResource function to handle dynamic text, and it worked like a charm.

Menu {
  ForEach(Language.allCases) { lang in
    Button("\(LocalizedStringResource(stringLiteral: lang.rawValue.capitalized))") {
      doSomething()
    }
  }
}

I hope this helps you too.

Older post

How to test the same Rake task multiple times

In some cases, you may want to test the same Rake task multiple times with different arguments. This post shows you how to do that.

Newer post

How to bring back English as supported languages on App Store

After starting to use String Catalogs, I noticed that English was no longer listed as a supported language on the App Store. This post shows you how to bring it back.