App Intents Siri Phrases Localization

If you have a Siri phrase for an app Intent:

phrases: ["Show me my books on \(.applicationName)"]

What is the right format to localize that phrase in a strings file?

genstrings does not work for that phrase.

I assumed that it would be:

"Show me my books on ${applicationName}" = "Show me my books on ${applicationName}";

But that does not work.

I couldn't get localization to work at all in the new AppIntents framework (I filed several radars). Almost nothing with parameters works and even some unparameterized phrases just show the localization key. I thought we could still use %@ like in normal localizations and it does work for the dialog in the perform function.

i.e. return .result(dialog: "play.news.intent.success \(station.name)") gives me the correct result for the "play.news.intent.success %@" localization key

Is there any updates on this? 🤔I can't get localised phrases too 😢I cannot find anything on that in WWDC videos or sample code, nothing...

Lost 3 hours trying to make this work. I managed to get it working using:

let localizedString = LocalizedStringResource("my.intents.string.id %@ %d", defaultValue: "my.intents.string.id \(myString) and \(myInteger)")

and then like this in Localizable.strings:

"my.intents.string.id %@ %d" = "%@ and %d more";

Thanks to @sowenjub I got it working. He wrote a really nice blog post that sums up everything (https://sowenjub.me/writes/localizing-app-shortcuts-with-app-intents/)

The gist is that you need 2 localization files:

  • an AppShortcuts.strings for the phrases and
  • Localizable.strings for the rest (it is possible to have something other than that specific name but you have to provide the table name in every place you reference the Strings which is quite annoying)

Then everything in code like the phrase

  • "Key: Add a meal (.$content) to (.applicationName)" (implicitly looked up in AppShortcuts.strings)

gets referenced via the following in your AppShortcuts.strings (i.e. english):

  • "Key: Add a meal {content} to {applicationName}" = "Add a meal {content} to {applicationName}";

And stuff like app entitiy typeDisplayNames:

  • static var typeDisplayName: LocalizedStringResource = "some.entitiy.type.name" (implicitly looked up in Localizable.strings; if you have an Alternative.strings file use something like .init("some.entitiy.type.name", table: "Alternative", locale: .autoupdatingCurrent, bundle: .main, comment: nil))

gets referenced via the following in your Localizable.strings (i.e. english): "some.entitiy.type.name" = "Some";

App Intents Siri Phrases Localization
 
 
Q