macOS: Add helper function for getting AppKit localized strings
If we for some reason can't look up AppKit, or if the table or string within that table is not found we will end up using the key as is. Change-Id: I5d574288e421e586458266899ffdff90eeadec8f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 5f15a93f16727824372bfd1a6490754440de942f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
d3fba01cdc
commit
df753ab453
@ -78,6 +78,9 @@ Qt::MouseButtons currentlyPressedMouseButtons();
|
||||
// accelerators.
|
||||
QString qt_mac_removeAmpersandEscapes(QString s);
|
||||
|
||||
// Similar to __NXKitString for localized AppKit strings
|
||||
NSString *qt_mac_AppKitString(NSString *table, NSString *key);
|
||||
|
||||
enum {
|
||||
QtCocoaEventSubTypeWakeup = SHRT_MAX,
|
||||
QtCocoaEventSubTypePostMessage = SHRT_MAX-1
|
||||
|
@ -336,6 +336,15 @@ QString qt_mac_removeAmpersandEscapes(QString s)
|
||||
return QPlatformTheme::removeMnemonics(s).trimmed();
|
||||
}
|
||||
|
||||
NSString *qt_mac_AppKitString(NSString *table, NSString *key)
|
||||
{
|
||||
static const NSBundle *appKit = [NSBundle bundleForClass:NSApplication.class];
|
||||
if (!appKit)
|
||||
return key;
|
||||
|
||||
return [appKit localizedStringForKey:key value:nil table:table];
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
/*! \internal
|
||||
|
@ -204,8 +204,7 @@ void QCocoaMenuBar::syncMenu_helper(QPlatformMenu *menu, bool menubarUpdate)
|
||||
// and document that the user needs to ensure their application matches
|
||||
// this translation.
|
||||
if ([menuTitle isEqual:@"Edit"] || [menuTitle isEqual:tr("Edit").toNSString()]) {
|
||||
static const NSBundle *appKit = [NSBundle bundleForClass:NSApplication.class];
|
||||
menuItem.title = [appKit localizedStringForKey:@"Edit" value:menuTitle table:@"InputManager"];
|
||||
menuItem.title = qt_mac_AppKitString(@"InputManager", @"Edit");
|
||||
} else {
|
||||
// The Edit menu is the only case we know of so far, but to be on
|
||||
// the safe side we always sync the menu title.
|
||||
|
Loading…
x
Reference in New Issue
Block a user