SFSafariToolbarItem can't be localizable

I added a Safari Extension fot my Mac OS App.

Because of need localizable App, I configed the InfoPlist.strings for App Extension's Info.plist,

CFBundleDisplayName = "App name"
NSHumanReadableDescription = "Human Readable";


The CFBundleDisplayName and NSHumanReadableDescription worked

but NSExtension's SFSafariToolbarItem always can't work,

hear is the two snapshot


https://raw.githubusercontent.com/lengain/LengainGraphBed/master/picture/1.jpg


https://raw.githubusercontent.com/lengain/LengainGraphBed/master/picture/2.jpg


Hope your suggest





I didn't find a solution to localized that value either. However, we could change the label value in code.

Code Block swift
override func validateToolbarItem(in window: SFSafariWindow, validationHandler: @escaping ((Bool, String) -> Void)) {
// This is called when Safari's state changed in some way that would require the extension's toolbar item to be validated again.
window.getToolbarItem { (toolbarItem) in
toolbarItem?.setImage(NSImage(named: "MonochromeIcon"))
toolbarItem?.setLabel(NSLocalizedString("Open URL in Page By Poster 2", comment: ""))
}
validationHandler(true, "")
}


Then you can localized the text what you want.
Since .strings file have no hierarchy, but only key = value; on each line, this would not work indeed.

In your InfoPlist.strings, your can keep your root keys like this (e.g. CFBundleDisplayName).
But for your keys on a sub-level, you have to use: "English value" = "Chinese value";

Then in InfoPlist.strings for Chinese:
Code Block
CFBundleDisplayName = "Localized Name";
NSHumanReadableDescription = "Localized Value";
"Your English Value for Label" = "Your Chinese Value for Label";


SFSafariToolbarItem can't be localizable
 
 
Q