Localisation for local notification - Strange behaviour in action buttons

Hello,
I am facing one issue in implementing localization in local notifications. I am using the action buttons so that users can take action from the notifications. A strange thing is happening while showing the notification in Spanish; the description shows in Spanish and the action buttons are in English and vice-versa. I have used the below code as per the Apple documentation but still no solution:

Code Block
let logNow = NSLocalizedString("Log Now", comment: "Alert")
let logNowAction = UNNotificationAction(identifier: "LOG_NOW_ACTION", title: NSString.localizedUserNotificationString(forKey: logNow, arguments: nil),options: [.foreground])
UNNotificationCategory(identifier: "CATEGORY_REMINDERS",
                                   actions: [logNowAction],
                                   intentIdentifiers: [],
                                   hiddenPreviewsBodyPlaceholder: "",
                                   options: .customDismissAction)
NSString.localizedUserNotificationString(forKey: logNow, arguments: nil)


Please help. Any pointers would be appreciated!

Regards,
Sunil

while showing the notification in Spanish; the description shows in Spanish and the action buttons are in English and vice-versa

Which buttons precisely ?
What is the iPhone language setting ?
I do not find where you tried to ;localise those buttons ; if so, they are displayed in the language of settings.

Have a look here for a somewhat similar issue:
https://developer.apple.com/forums/thread/667963?page=1#649779022
Hello Claude,
Thanks for then reply.

Code Block
Which buttons precisely ?
  • Actions button. When you long press the notification. There comes action buttons.

Code Block
What is the iPhone language setting ?
  • Language setting is English. However, project setting is Spanish.

Code Block
I do not find where you tried to ;localise those buttons ; if so, they are displayed in the language of settings.

I localised it while add the local notification in UNUserNotificationCenter:


let logNow = NSLocalizedString("Log Now", comment: "Alert")
let logNowAction = UNNotificationAction(identifier: "LOG_NOW_ACTION", title: NSString.localizedUserNotificationString(forKey: logNow, arguments: nil),options: [.foreground])

UNNotificationCategory(identifier: "CATEGORY_REMINDERS", actions: [logNowAction], intentIdentifiers: [],                                 hiddenPreviewsBodyPlaceholder: "", options: .customDismissAction)

notifyCenter.getNotificationCategories(completionHandler: { categories in
            var allCategories = categories
            self.notifyCenter.setNotificationCategories(allCategories)
        })



Thanks Claude for the response. I tried that but no luck.

One thing I found while doing some research, it converts it into their respective language if we change device's language along with application language. So, maybe because they are native button outside the application and hence, it depends on the device's language. So, I tried that thing and now it is showing me the button title in Spanish after I change the device's language to Spanish and vice-versa.
Localisation for local notification - Strange behaviour in action buttons
 
 
Q