LocalizedStringResource with Formatter

I am trying to use DateComponentsFormatter() with my AppIntent, but I can not find a way to localize the formatter string with the same language that LocalizedStringResource use...

Example (My App: Arabic, Device: English, Siri: English)

let formatter = DateComponentsFormatter()
    formatter.unitsStyle = .full
    formatter.maximumUnitCount = 2
    formatter.allowedUnits = [.hour, .minute]
    formatter.includesTimeRemainingPhrase = true

let relativeDate = formatter.string(from: .now, to: nextEvent.date) ?? ""

     return .result(
            value: value,
            dialog: "intent_current_event\(relativeDate)"
          )

The result is: Next event متبقي 4 ساعات و 5 دقائق

The relativeDate is in Arabic (App Language) and the "intent_current_event%@" localized in English (Siri Language)

Can anyone please help me to use the Formatter and get it to localized the same local as LocalizedStringResource.

  • Hi, would you be able to report this issue with the Feedback Assistant app available on iOS or macOS betas, or at https://feedbackassistant.apple.com; and share the FB number here?

Add a Comment

Replies

It's so strange no much documents for LocalizedStringResource and no one reply on the Developer Forums, how we will make great Apps? Who will use your amazing APIs you created?

I searched the internet and only few articles on LocalizedStringResource just explain the basics.

But what if I want to formatter.string(from: .now) and display that date with same local as LocalizedStringResource?

I am sure there is an simple answer, so please @Apple I wast allot of time try to find answers.

how we will make great Apps?

Keep in mind that DevForums is not a formal support channel. If you need an answer to this question, I recommend that you open a DTS tech support incident and discuss it with our localisation specialist [1].

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] DTS, like most of Apple, is closed for the winter break right now, but we’ll get to your question in the new year.