Skip to content

Commit

Permalink
Merge pull request hrydgard#17340 from hrydgard/mac-translation-work
Browse files Browse the repository at this point in the history
Mac translation work
  • Loading branch information
hrydgard authored Apr 27, 2023
2 parents b333e2b + 1ba4ca3 commit 4d4881f
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 32 deletions.
9 changes: 8 additions & 1 deletion Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,15 @@ static int DefaultGPUBackend() {
return (int)GPUBackend::VULKAN;
}
#endif

#elif PPSSPP_PLATFORM(MAC)
#if PPSSPP_ARCH(ARM64)
return (int)GPUBackend::VULKAN;
#else
// On Intel (generally older Macs) default to OpenGL.
return (int)GPUBackend::OPENGL;
#endif
#endif

// TODO: On some additional Linux platforms, we should also default to Vulkan.
return (int)GPUBackend::OPENGL;
}
Expand Down
63 changes: 35 additions & 28 deletions SDL/CocoaBarItems.mm
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ @interface BarItemsManager : NSObject <NSMenuDelegate>
+(instancetype)sharedInstance;
-(void)setupAppBarItems;
@property (assign) NSMenu *fileMenu;
@property (assign) std::shared_ptr<I18NCategory> mainSettingsLocalization;
@property (assign) std::shared_ptr<I18NCategory> graphicsLocalization;
@end

void initializeOSXExtras() {
Expand All @@ -57,12 +55,19 @@ + (instancetype)sharedInstance {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
stub = [BarItemsManager new];
stub.mainSettingsLocalization = GetI18NCategory(I18NCat::MAINSETTINGS);
});

return stub;
}

-(NSString *)localizedString: (const char *)key category: (I18NCat)cat {
return @(T(cat, key));
}

-(NSString *)localizedMenuString: (const char *)key {
std::string processed = UnescapeMenuString(T(I18NCat::DESKTOPUI, key), nullptr);
return @(processed.c_str());
}

-(void)setupAppBarItems {

NSMenuItem *fileMenuItem = [[NSMenuItem alloc] init];
Expand All @@ -85,7 +90,7 @@ -(void)setupAppBarItems {
[NSApplication.sharedApplication.menu addItem:debugMenuItem];
[NSApplication.sharedApplication.menu addItem:helpMenuItem];

NSString *windowMenuItemTitle = @"Window";
NSString *windowMenuItemTitle = @"Window"; // Don't translate, we lookup this.
// Rearrange 'Window' to be behind 'Help'
for (NSMenuItem *item in NSApplication.sharedApplication.menu.itemArray) {
if ([item.title isEqualToString:windowMenuItemTitle]) {
Expand Down Expand Up @@ -138,7 +143,7 @@ -(void)presentAboutMenu {
}

- (void)menuNeedsUpdate:(NSMenu *)menu {
if ([menu.title isEqualToString: [self localizedString:"Graphics" category: self.mainSettingsLocalization]]) {
if ([menu.title isEqualToString: [self localizedMenuString:"Graphics"]]) {
for (NSMenuItem *item in menu.itemArray) {
switch (item.tag) {
case 1:
Expand Down Expand Up @@ -166,7 +171,7 @@ - (void)menuNeedsUpdate:(NSMenu *)menu {
break;
}
}
} else if ([menu.title isEqualToString: [self localizedString:"Debug" category: self.mainSettingsLocalization]]) {
} else if ([menu.title isEqualToString: [self localizedMenuString:"Debug"]]) {
for (NSMenuItem *item in menu.itemArray) {
switch ([item tag]) {
case 2:
Expand All @@ -182,10 +187,6 @@ - (void)menuNeedsUpdate:(NSMenu *)menu {
}
}

-(NSString *)localizedString: (const char *)key category: (std::shared_ptr<I18NCategory>)cat {
return @(self.mainSettingsLocalization->T(key));
}

-(NSMenu *)makeHelpMenu {
NSMenu *menu = [[NSMenu alloc] initWithTitle:@"Help"];
NSMenuItem *githubItem = [[NSMenuItem alloc] initWithTitle:@"Report an issue" action:@selector(reportAnIssue) keyEquivalent:@""];
Expand All @@ -207,8 +208,11 @@ -(void)joinTheDiscord {
}

-(NSMenu *)makeFileSubmenu {
NSMenu *menu = [[NSMenu alloc] initWithTitle:@"File"];
NSMenuItem *openWithSystemFolderBrowserItem = [[NSMenuItem alloc] initWithTitle:@"Open..." action:@selector(openSystemFileBrowser) keyEquivalent:@"o"];
std::shared_ptr<I18NCategory> desktopUILocalization = GetI18NCategory(I18NCat::DESKTOPUI);
#define DESKTOPUI_LOCALIZED(key) @(UnescapeMenuString(desktopUILocalization->T(key), nil).c_str())

NSMenu *menu = [[NSMenu alloc] initWithTitle:DESKTOPUI_LOCALIZED("File")];
NSMenuItem *openWithSystemFolderBrowserItem = [[NSMenuItem alloc] initWithTitle:DESKTOPUI_LOCALIZED("Load") action:@selector(openSystemFileBrowser) keyEquivalent:@"o"];
openWithSystemFolderBrowserItem.keyEquivalentModifierMask = NSEventModifierFlagCommand;
openWithSystemFolderBrowserItem.enabled = YES;
openWithSystemFolderBrowserItem.target = self;
Expand All @@ -218,21 +222,24 @@ -(NSMenu *)makeFileSubmenu {

[self.fileMenu addItem:[NSMenuItem separatorItem]];

NSMenuItem *openMemstickFolderItem = [[NSMenuItem alloc] initWithTitle:@"Open Memory Stick" action:@selector(openMemstickFolder) keyEquivalent:@""];
NSMenuItem *openMemstickFolderItem = [[NSMenuItem alloc] initWithTitle:DESKTOPUI_LOCALIZED("Open Memory Stick") action:@selector(openMemstickFolder) keyEquivalent:@""];
openMemstickFolderItem.target = self;
[self.fileMenu addItem:openMemstickFolderItem];

return menu;
}

-(NSMenu *)makeGraphicsMenu {
NSMenu *parent = [[NSMenu alloc] initWithTitle:@(self.mainSettingsLocalization->T("Graphics"))];
-(NSMenu *)makeGraphicsMenu {
std::shared_ptr<I18NCategory> mainSettingsLocalization = GetI18NCategory(I18NCat::MAINSETTINGS);
std::shared_ptr<I18NCategory> graphicsLocalization = GetI18NCategory(I18NCat::GRAPHICS);
std::shared_ptr<I18NCategory> desktopUILocalization = GetI18NCategory(I18NCat::DESKTOPUI);

NSMenu *parent = [[NSMenu alloc] initWithTitle:@(mainSettingsLocalization->T("Graphics"))];
NSMenu *backendsMenu = [[NSMenu alloc] init];
#define GRAPHICS_LOCALIZED(key) @(graphicsLocalization->T(key))
#define DESKTOPUI_LOCALIZED(key) @(UnescapeMenuString(desktopUILocalization->T(key), nil).c_str())

self.graphicsLocalization = GetI18NCategory(I18NCat::GRAPHICS);
#define GRAPHICS_LOCALIZED(key) @(self.graphicsLocalization->T(key))

NSMenuItem *gpuBackendItem = [[NSMenuItem alloc] initWithTitle:GRAPHICS_LOCALIZED("Backend") action:nil keyEquivalent:@""];
NSMenuItem *gpuBackendItem = [[NSMenuItem alloc] initWithTitle:DESKTOPUI_LOCALIZED("Backend") action:nil keyEquivalent:@""];

std::vector<GPUBackend> allowed = [self allowedGPUBackends];
for (int i = 0; i < allowed.size(); i++) {
Expand All @@ -254,7 +261,7 @@ -(NSMenu *)makeGraphicsMenu {
MENU_ITEM(vsyncItem, GRAPHICS_LOCALIZED("VSync"), @selector(toggleVSync:), g_Config.bVSync, 2)
[parent addItem:vsyncItem];

MENU_ITEM(fullScreenItem, GRAPHICS_LOCALIZED("Fullscreen"), @selector(toggleFullScreen:), g_Config.bFullScreen, 3)
MENU_ITEM(fullScreenItem, DESKTOPUI_LOCALIZED("Fullscreen"), @selector(toggleFullScreen:), g_Config.bFullScreen, 3)
[parent addItem:fullScreenItem];

[parent addItem:[NSMenuItem separatorItem]];
Expand All @@ -264,7 +271,7 @@ -(NSMenu *)makeGraphicsMenu {

[parent addItem:[NSMenuItem separatorItem]];

MENU_ITEM(fpsCounterItem, GRAPHICS_LOCALIZED("Show FPS Counter"), @selector(setToggleShowCounterItem:), g_Config.iShowStatusFlags & (int)ShowStatusFlags::FPS_COUNTER, 5)
MENU_ITEM(fpsCounterItem, DESKTOPUI_LOCALIZED("Show FPS Counter"), @selector(setToggleShowCounterItem:), g_Config.iShowStatusFlags & (int)ShowStatusFlags::FPS_COUNTER, 5)
fpsCounterItem.tag = (int)ShowStatusFlags::FPS_COUNTER + 100;

MENU_ITEM(speedCounterItem, GRAPHICS_LOCALIZED("Show Speed"), @selector(setToggleShowCounterItem:), g_Config.iShowStatusFlags & (int)ShowStatusFlags::SPEED_COUNTER, 6)
Expand All @@ -286,8 +293,8 @@ -(NSMenu *)makeDebugMenu {
std::shared_ptr<I18NCategory> sysInfoLocalization = GetI18NCategory(I18NCat::SYSINFO);
std::shared_ptr<I18NCategory> desktopUILocalization = GetI18NCategory(I18NCat::DESKTOPUI);
#define DESKTOPUI_LOCALIZED(key) @(UnescapeMenuString(desktopUILocalization->T(key), nil).c_str())
NSMenu *parent = [[NSMenu alloc] initWithTitle:@(sysInfoLocalization->T("Debug"))];

NSMenu *parent = [[NSMenu alloc] initWithTitle:DESKTOPUI_LOCALIZED("Debugging")];

NSMenuItem *breakAction = [[NSMenuItem alloc] initWithTitle:DESKTOPUI_LOCALIZED("Break") action:@selector(breakAction:) keyEquivalent:@""];
breakAction.tag = 1;
Expand All @@ -303,10 +310,10 @@ -(NSMenu *)makeDebugMenu {
[parent addItem:ignoreIllegalRWAction];
[parent addItem:[NSMenuItem separatorItem]];

NSMenuItem *loadSymbolMapAction = [[NSMenuItem alloc] initWithTitle:DESKTOPUI_LOCALIZED("Load Map file") action:@selector(loadMapFile) keyEquivalent:@""];
NSMenuItem *loadSymbolMapAction = [[NSMenuItem alloc] initWithTitle:DESKTOPUI_LOCALIZED("Load Map File...") action:@selector(loadMapFile) keyEquivalent:@""];
loadSymbolMapAction.target = self;

NSMenuItem *saveMapFileAction = [[NSMenuItem alloc] initWithTitle:DESKTOPUI_LOCALIZED("Save Map file") action:@selector(saveMapFile) keyEquivalent:@""];
NSMenuItem *saveMapFileAction = [[NSMenuItem alloc] initWithTitle:DESKTOPUI_LOCALIZED("Save Map file...") action:@selector(saveMapFile) keyEquivalent:@""];
saveMapFileAction.target = self;

NSMenuItem *loadSymFileAction = [[NSMenuItem alloc] initWithTitle:DESKTOPUI_LOCALIZED("Load .sym File...") action:@selector(loadSymbolsFile) keyEquivalent:@""];
Expand All @@ -321,7 +328,7 @@ -(NSMenu *)makeDebugMenu {
NSMenuItem *takeScreenshotAction = [[NSMenuItem alloc] initWithTitle:DESKTOPUI_LOCALIZED("Take Screenshot") action:@selector(takeScreenshot) keyEquivalent:@""];
takeScreenshotAction.target = self;

NSMenuItem *dumpNextFrameToLogAction = [[NSMenuItem alloc] initWithTitle:DESKTOPUI_LOCALIZED("Dump next frame to log") action:@selector(dumpNextFrameToLog) keyEquivalent:@""];
NSMenuItem *dumpNextFrameToLogAction = [[NSMenuItem alloc] initWithTitle:DESKTOPUI_LOCALIZED("Dump Next Frame to Log") action:@selector(dumpNextFrameToLog) keyEquivalent:@""];
dumpNextFrameToLogAction.target = self;

NSMenuItem *copyBaseAddr = [[NSMenuItem alloc] initWithTitle:DESKTOPUI_LOCALIZED("Copy PSP memory base address") action:@selector(copyAddr) keyEquivalent:@""];
Expand Down Expand Up @@ -497,7 +504,7 @@ -(NSControlStateValue) controlStateForBool: (BOOL)boolValue {

-(void)addOpenRecentlyItem {
std::vector<std::string> recentIsos = g_Config.RecentIsos();
NSMenuItem *openRecent = [[NSMenuItem alloc] initWithTitle:@"Open Recent" action:nil keyEquivalent:@""];
NSMenuItem *openRecent = [[NSMenuItem alloc] initWithTitle:@"Recent" action:nil keyEquivalent:@""];
NSMenu *recentsMenu = [[NSMenu alloc] init];
if (recentIsos.empty())
openRecent.enabled = NO;
Expand Down
1 change: 1 addition & 0 deletions assets/lang/en_US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ Pause When Not Focused = &Pause when not focused
Portrait = Portrait
Portrait reversed = Portrait reversed
PPSSPP Forums = PPSSPP &forums
Recent = &Recent
Record = &Record
Record Audio = Record &audio
Record Display = Record &display
Expand Down
6 changes: 3 additions & 3 deletions assets/lang/sv_SE.ini
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Break = Bryt
Break on Load = Stoppa direkt efter laddning
Buy Gold = Buy Gold
Control Mapping... = Kontrollmappning...
Copy PSP memory base address = Copy PSP memory base &address
Copy PSP memory base address = Kopiera bas-addressen till PSP'n minne
Debugging = Debuggning
Deposterize = Deposterize
Direct3D9 = Direct3D9
Expand Down Expand Up @@ -520,8 +520,8 @@ Must Restart = Starta om PPSSPP för att ändringen ska få effekt.
Native device resolution = Native device resolution
Nearest = Närmast
No buffer = Ingen buffer
Show Battery % = Show Battery %
Show Speed = Show Speed
Show Battery % = Visa batteri-%
Show Speed = Visa hastighet
Skip Buffer Effects = Skippa buffereffekter (snabbare, risk för fel)
None = Inget
Number of Frames = Antal frames
Expand Down

0 comments on commit 4d4881f

Please sign in to comment.