View Issue Details

IDProjectCategoryView StatusLast Update
0035234LazarusWidgetsetpublic2019-12-08 20:34
ReporterZoë Peterson Assigned ToDmitry Boyarintsev  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version2.0 
Summary0035234: Cocoa captions for hardcoded apple menu items should be resourcestrings
DescriptionThe attached patch makes the captions for the hardcoded apple menu items resource strings so they can be translated. Affects "Services", "Hide <app>", "Hide Others", "Show All", and "Quit <app>"
TagsNo tags attached.
Fixed in Revision62355
LazTarget-
WidgetsetCocoa
Attached Files

Activities

Zoë Peterson

2019-03-15 17:25

reporter  

cocoawsmenus-resourcestrings.patch (3,106 bytes)   
Index: interfaces/cocoa/cocoawsmenus.pas
===================================================================
--- interfaces/cocoa/cocoawsmenus.pas	(revision 60681)
+++ interfaces/cocoa/cocoawsmenus.pas	(working copy)
@@ -29,7 +29,7 @@
   sysutils,
   // LCL
   Controls, Forms, Menus, Graphics, LCLType, LMessages, LCLProc, Classes,
-  LCLMessageGlue,
+  LCLMessageGlue, LCLStrConsts,
   // Widgetset
   WSMenus, WSLCLClasses,
   // LCL Cocoa
@@ -337,11 +337,11 @@
   submenu.insertItem_atIndex(NSMenuItem.separatorItem, submenu.itemArray.count);
 
   // Services
-  item := LCLMenuItemInit( TCocoaMenuItem.alloc, 'Services');
+  item := LCLMenuItemInit( TCocoaMenuItem.alloc, rsCocoaMenuServices);
   item.setTarget(nil);
   item.setAction(nil);
   submenu.insertItem_atIndex(item, submenu.itemArray.count);
-  item.setSubmenu(NSMenu.alloc.initWithTitle( NSSTR('Services')));
+  item.setSubmenu(NSMenu.alloc.initWithTitle( ControlTitleToNSStr(rsCocoaMenuServices)));
   NSApplication(NSApp).setServicesMenu(item.submenu);
 
   // Separator
@@ -348,15 +348,15 @@
   submenu.insertItem_atIndex(NSMenuItem.separatorItem, submenu.itemArray.count);
 
   // Hide App     Meta-H
-  item := LCLMenuItemInit( TCocoaMenuItem_HideApp.alloc, 'Hide ' + Application.Title, VK_H, [ssMeta]);
+  item := LCLMenuItemInit( TCocoaMenuItem_HideApp.alloc, Format(rsCocoaMenuHide, [Application.Title]), VK_H, [ssMeta]);
   submenu.insertItem_atIndex(item, submenu.itemArray.count);
 
   // Hide Others  Meta-Alt-H
-  item := LCLMenuItemInit( TCocoaMenuItem_HideOthers.alloc, 'Hide Others', VK_H, [ssMeta, ssAlt]);
+  item := LCLMenuItemInit( TCocoaMenuItem_HideOthers.alloc, rsCocoaMenuHideOthers, VK_H, [ssMeta, ssAlt]);
   submenu.insertItem_atIndex(item, submenu.itemArray.count);
 
   // Show All
-  item := LCLMenuItemInit( TCocoaMenuItem_ShowAllApp.alloc, 'Show All');
+  item := LCLMenuItemInit( TCocoaMenuItem_ShowAllApp.alloc, rsCocoaMenuShowAll);
   submenu.insertItem_atIndex(item, submenu.itemArray.count);
 
   // Separator
@@ -363,7 +363,7 @@
   submenu.insertItem_atIndex(NSMenuItem.separatorItem, submenu.itemArray.count);
 
   // Quit   Meta-Q
-  item := LCLMenuItemInit( TCocoaMenuItem_Quit.alloc, 'Quit '+Application.Title, VK_Q, [ssMeta]);
+  item := LCLMenuItemInit( TCocoaMenuItem_Quit.alloc, Format(rsCocoaMenuQuit, [Application.Title]), VK_Q, [ssMeta]);
   submenu.insertItem_atIndex(item, submenu.itemArray.count);
 
   attachedAppleMenuItems := True;
Index: lclstrconsts.pas
===================================================================
--- lclstrconsts.pas	(revision 60681)
+++ lclstrconsts.pas	(working copy)
@@ -89,7 +89,14 @@
   rsPostRecordHint = 'Post';
   rsCancelRecordHint = 'Cancel';
   rsRefreshRecordsHint = 'Refresh';
-  
+
+  // cocoa interface
+  rsCocoaMenuHide = 'Hide %s';
+  rsCocoaMenuHideOthers = 'Hide Others';
+  rsCocoaMenuQuit = 'Quit %s';
+  rsCocoaMenuServices = 'Services';
+  rsCocoaMenuShowAll = 'Show All';
+
   // gtk interface
   rsWarningUnremovedPaintMessages = ' WARNING: There are %s unremoved LM_'
     +'PAINT/LM_GtkPAINT message links left.';

Dmitry Boyarintsev

2019-12-08 20:34

developer   ~0119697

thank you, the patch is applied
please test and close if ok

Translations: https://wiki.freepascal.org/macOS_Translation

Issue History

Date Modified Username Field Change
2019-03-15 17:25 Zoë Peterson New Issue
2019-03-15 17:25 Zoë Peterson File Added: cocoawsmenus-resourcestrings.patch
2019-12-08 20:24 Dmitry Boyarintsev Assigned To => Dmitry Boyarintsev
2019-12-08 20:24 Dmitry Boyarintsev Status new => assigned
2019-12-08 20:34 Dmitry Boyarintsev Status assigned => resolved
2019-12-08 20:34 Dmitry Boyarintsev Resolution open => fixed
2019-12-08 20:34 Dmitry Boyarintsev Fixed in Revision => 62355
2019-12-08 20:34 Dmitry Boyarintsev LazTarget => -
2019-12-08 20:34 Dmitry Boyarintsev Widgetset => Cocoa
2019-12-08 20:34 Dmitry Boyarintsev Note Added: 0119697