As I went on a redesigned the entire App Shortcuts in MoneyCoach, I realized that I need to localize the App Intents. I mean, it’s a no brainer, but I didn’t think about it until I had to do it.
App Intents use a new more intelligent way of handling localizations. You need to use the LocalizedStringResource. The documentation is a bit lacking, but I managed to figure it out after wasting/investing/spending 2 days of trial and error. Looking forward to save you time with this simple tutorial.
How to localize App Intents
- First you need to use LocalizedStringResource.
- Second you have Xcode generate the strings file for you. Just go over to Product --> Export Localizations and select the language you want to localize. Xcode will generate the strings file for you. Except that it doesn't.
Solution
So the trick is to go over to your project build settings or target build settings, find the "Use Compiler To Extract Swift Strings" and set it to Yes
.
That's it. Go ahead and repeat step 2.
So this is now easy it is to have Xcode generate the strings for LocalizedStringResource. Now let's see how to use it.