From 36f91cffd4cc350a5626940319e33a2f25b43da0 Mon Sep 17 00:00:00 2001 From: Li Linfeng Date: Wed, 20 Nov 2019 12:44:34 +0800 Subject: [PATCH] remove "po" localized string reference from UI --- macosx/BrowserItem.mm | 14 ++++----- macosx/BrowserWindowController.mm | 2 +- macosx/{CGLInfo.m => CGLInfo.mm} | 13 +++----- macosx/EclipseFinderController.mm | 5 +-- .../{Menu_Extensions.m => Menu_Extensions.mm} | 31 ++++++++++--------- macosx/celestia.xcodeproj/project.pbxproj | 16 +++++----- 6 files changed, 39 insertions(+), 42 deletions(-) rename macosx/{CGLInfo.m => CGLInfo.mm} (91%) rename macosx/{Menu_Extensions.m => Menu_Extensions.mm} (82%) diff --git a/macosx/BrowserItem.mm b/macosx/BrowserItem.mm index 306e142f4..29a5b8712 100644 --- a/macosx/BrowserItem.mm +++ b/macosx/BrowserItem.mm @@ -16,7 +16,7 @@ #import "CelestiaAppCore.h" #import "CelestiaUniverse_PrivateAPI.h" #include "solarsys.h" - +#include @implementation BrowserItem - (id)initWithCelestiaDSO: (CelestiaDSO *)aDSO @@ -96,12 +96,12 @@ continue; case Body::Planet: if (!planets) - planets = [[BrowserItem alloc] initWithName: NSLocalizedStringFromTable(@"Planets",@"po",@"")]; + planets = [[BrowserItem alloc] initWithName:[NSString stringWithUTF8String:_("Planets")]]; subItem = planets; break; case Body::DwarfPlanet: if (!dwarfPlanets) - dwarfPlanets = [[BrowserItem alloc] initWithName: NSLocalizedStringFromTable(@"Dwarf Planets",@"po",@"")]; + dwarfPlanets = [[BrowserItem alloc] initWithName:[NSString stringWithUTF8String:_("Dwarf Planets")]]; subItem = dwarfPlanets; break; case Body::Moon: @@ -119,12 +119,12 @@ break; case Body::Asteroid: if (!asteroids) - asteroids = [[BrowserItem alloc] initWithName: NSLocalizedStringFromTable(@"Asteroids",@"po",@"")]; + asteroids = [[BrowserItem alloc] initWithName:[NSString stringWithUTF8String:_("Asteroids")]]; subItem = asteroids; break; case Body::Comet: if (!comets) - comets = [[BrowserItem alloc] initWithName: NSLocalizedStringFromTable(@"Comets",@"po",@"")]; + comets = [[BrowserItem alloc] initWithName:[NSString stringWithUTF8String:_("Comets")]]; subItem = comets; break; case Body::Spacecraft: @@ -189,7 +189,7 @@ break; case Body::Comet: if (!comets) - comets = [[BrowserItem alloc] initWithName: NSLocalizedStringFromTable(@"Comets",@"po",@"")]; + comets = [[BrowserItem alloc] initWithName:[NSString stringWithUTF8String:_("Comets")]]; subItem = comets; break; case Body::Spacecraft: @@ -212,7 +212,7 @@ std::vector* locations = [(CelestiaBody *)[aBody body] body]->getLocations(); if (locations != NULL) { - BrowserItem *locationItems = [[BrowserItem alloc] initWithName: NSLocalizedStringFromTable(@"Locations",@"po",@"")]; + BrowserItem *locationItems = [[BrowserItem alloc] initWithName:[NSString stringWithUTF8String:_("Locations")]]; for (vector::const_iterator iter = locations->begin(); iter != locations->end(); iter++) { diff --git a/macosx/BrowserWindowController.mm b/macosx/BrowserWindowController.mm index e61ed0b27..2d494e1a5 100644 --- a/macosx/BrowserWindowController.mm +++ b/macosx/BrowserWindowController.mm @@ -76,7 +76,7 @@ static CelestiaCore *appCore; NSLocalizedString(@"Galaxies (Elliptical)",@""), @"E", NSLocalizedString(@"Galaxies (Irregular)",@""), @"Irr", NSLocalizedString(@"Nebulae",@""), @"Neb", - NSLocalizedStringFromTable(@"Globulars",@"po",@""), @"Glob", + [NSString stringWithUTF8String:_("Globulars")], @"Glob", NSLocalizedString(@"Open Clusters",@""), @"Clust", NSLocalizedString(@"Unknown",@""), @"Unknown", nil]; diff --git a/macosx/CGLInfo.m b/macosx/CGLInfo.mm similarity index 91% rename from macosx/CGLInfo.m rename to macosx/CGLInfo.mm index 607d19629..ac430de9c 100644 --- a/macosx/CGLInfo.m +++ b/macosx/CGLInfo.mm @@ -10,6 +10,7 @@ #import #import #import +#include #ifndef GL_SHADING_LANGUAGE_VERSION_ARB #define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C @@ -83,9 +84,7 @@ static NSString *queryGLExtension(const char *extName) if (glslVersion) { [result appendString: - [NSString stringWithFormat: @"%@%@", - NSLocalizedStringFromTable(@"GLSL version: ",@"po",""), - glslVersion] + [NSString stringWithFormat:@"%s%@", _("GLSL version: "), glslVersion] ]; ENDL; } } @@ -103,18 +102,14 @@ static NSString *queryGLExtension(const char *extName) GLint maxCubeMapSize = 0; glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, &maxCubeMapSize); [result appendString: - [NSString stringWithFormat: @"%@%d", - NSLocalizedStringFromTable(@"Max cube map size: ",@"po",""), - maxCubeMapSize] + [NSString stringWithFormat:@"%s%d", _("Max cube map size: "), maxCubeMapSize] ]; ENDL; } GLfloat pointSizeRange[2]; glGetFloatv(GL_POINT_SIZE_RANGE, pointSizeRange); [result appendString: - [NSString stringWithFormat: @"%@%f - %f", - NSLocalizedStringFromTable(@"Point size range: ",@"po",""), - pointSizeRange[0], pointSizeRange[1]] + [NSString stringWithFormat:@"%s%f - %f", _("Point size range: "), pointSizeRange[0], pointSizeRange[1]] ]; ENDL; ENDL; diff --git a/macosx/EclipseFinderController.mm b/macosx/EclipseFinderController.mm index 4b1c74f37..2f8da64de 100644 --- a/macosx/EclipseFinderController.mm +++ b/macosx/EclipseFinderController.mm @@ -10,7 +10,8 @@ #import "CelestiaAppCore.h" #import "NSString_ObjCPlusPlus.h" #import "CelestiaBody_PrivateAPI.h" -#import "eclipsefinder.h" +#include "eclipsefinder.h" +#include @interface EclipseFinderController(Private) - (void)getEclipses: (id)aObject; @@ -233,7 +234,7 @@ static CelestiaBody *eclipseBody; [eclipses addObject: [NSDictionary dictionaryWithObjectsAndKeys: - NSLocalizedStringFromTable(eclipseName,@"po",@""), @"caster", + [NSString stringWithUTF8String:_([eclipseName UTF8String])], @"caster", eclipseDate, @"date", [[CelestiaBody alloc] initWithBody: eclipse->body], @"body", [NSNumber numberWithDouble: eclipse->startTime], @"start", diff --git a/macosx/Menu_Extensions.m b/macosx/Menu_Extensions.mm similarity index 82% rename from macosx/Menu_Extensions.m rename to macosx/Menu_Extensions.mm index 58ed77ddf..43ed680d0 100644 --- a/macosx/Menu_Extensions.m +++ b/macosx/Menu_Extensions.mm @@ -10,6 +10,7 @@ #import "CelestiaSelection.h" #import "BrowserItem.h" #import "CelestiaSettings.h" +#include @implementation NSMenu (CelestiaMenu) - (NSInteger) indexOfItemWithLocalizableTitle: (NSString *) aTitle @@ -23,19 +24,19 @@ - (void) removeRefMarkItems { NSInteger index; - index = [self indexOfItemWithTitle: NSLocalizedStringFromTable(@"Reference Vectors",@"po",@"")]; + index = [self indexOfItemWithTitle:[NSString stringWithUTF8String:_("Reference Vectors")]]; if (index >= 0) [self removeItemAtIndex: index]; } - (void) removePlanetarySystemItem { NSInteger satMenuIndex = [self indexOfItemWithTitle: - NSLocalizedStringFromTable(@"Satellites",@"po",@"")]; + [NSString stringWithUTF8String:_("Satellites")]]; if (satMenuIndex < 0) satMenuIndex = [self indexOfItemWithTitle: - NSLocalizedStringFromTable(@"Orbiting Bodies",@"po",@"")]; + [NSString stringWithUTF8String:_("Orbiting Bodies")]]; if (satMenuIndex < 0) - satMenuIndex = [self indexOfItemWithTitle: NSLocalizedStringFromTable(@"Planets",@"po",@"")]; + satMenuIndex = [self indexOfItemWithTitle:[NSString stringWithUTF8String:_("Planets")]]; if (satMenuIndex >= 0) [self removeItemAtIndex: satMenuIndex]; } @@ -59,7 +60,7 @@ if ([aSelection body]) { target = [aSelection body]; - mi = [[NSMenuItem alloc] initWithTitle: NSLocalizedStringFromTable(@"Reference Vectors",@"po",@"") action: nil keyEquivalent: @""]; + mi = [[NSMenuItem alloc] initWithTitle:[NSString stringWithUTF8String:_("Reference Vectors")] action: nil keyEquivalent: @""]; NSMenu *refMarksMenu = [[NSMenu alloc] initWithTitle: @"Reference Vectors" ]; [mi setSubmenu: refMarksMenu]; if (mi) @@ -67,42 +68,42 @@ [self insertItem: mi atIndex: aIndex]; } - mi = [[NSMenuItem alloc] initWithTitle: NSLocalizedStringFromTable(@"Show Body Axes",@"po",@"") action: nil keyEquivalent: @""]; + mi = [[NSMenuItem alloc] initWithTitle:[NSString stringWithUTF8String:_("Show Body Axes")] action: nil keyEquivalent: @""]; if (mi) { [mi setTag: 1000]; [refMarksMenu addItem: mi]; [settings scanForKeys: mi]; } - mi = [[NSMenuItem alloc] initWithTitle: NSLocalizedStringFromTable(@"Show Frame Axes",@"po",@"") action: nil keyEquivalent: @""]; + mi = [[NSMenuItem alloc] initWithTitle:[NSString stringWithUTF8String:_("Show Frame Axes")] action: nil keyEquivalent: @""]; if (mi) { [mi setTag: 1001]; [refMarksMenu addItem: mi]; [settings scanForKeys: mi]; } - mi = [[NSMenuItem alloc] initWithTitle: NSLocalizedStringFromTable(@"Show Sun Direction",@"po",@"") action: nil keyEquivalent: @""]; + mi = [[NSMenuItem alloc] initWithTitle:[NSString stringWithUTF8String:_("Show Sun Direction")] action: nil keyEquivalent: @""]; if (mi) { [mi setTag: 1002]; [refMarksMenu addItem: mi]; [settings scanForKeys: mi]; } - mi = [[NSMenuItem alloc] initWithTitle: NSLocalizedStringFromTable(@"Show Velocity Vector",@"po",@"") action: nil keyEquivalent: @""]; + mi = [[NSMenuItem alloc] initWithTitle:[NSString stringWithUTF8String:_("Show Velocity Vector")] action: nil keyEquivalent: @""]; if (mi) { [mi setTag: 1003]; [refMarksMenu addItem: mi]; [settings scanForKeys: mi]; } - mi = [[NSMenuItem alloc] initWithTitle: NSLocalizedStringFromTable(@"Show Planetographic Grid",@"po",@"") action: nil keyEquivalent: @""]; + mi = [[NSMenuItem alloc] initWithTitle:[NSString stringWithUTF8String:_("Show Planetographic Grid")] action: nil keyEquivalent: @""]; if (mi) { [mi setTag: 1004]; [refMarksMenu addItem: mi]; [settings scanForKeys: mi]; } - mi = [[NSMenuItem alloc] initWithTitle: NSLocalizedStringFromTable(@"Show Terminator",@"po",@"") action: nil keyEquivalent: @""]; + mi = [[NSMenuItem alloc] initWithTitle:[NSString stringWithUTF8String:_("Show Terminator")] action: nil keyEquivalent: @""]; if (mi) { [mi setTag: 1005]; @@ -128,7 +129,7 @@ NSArray *children = [browseItem allChildNames]; if (children && [children count] > 0) { - mi = [[NSMenuItem alloc] initWithTitle: NSLocalizedStringFromTable(@"Satellites",@"po",@"") action: nil keyEquivalent: @""]; + mi = [[NSMenuItem alloc] initWithTitle:[NSString stringWithUTF8String:_("Satellites")] action: nil keyEquivalent: @""]; [mi addPlanetarySystemMenuForItem: browseItem target: aTarget action: @selector(selectSatellite:)]; @@ -143,7 +144,7 @@ { NSString *satMenuItemName = [[browseItem name] isEqualToString: @"Sol"] ? @"Orbiting Bodies" : @"Planets"; - mi = [[NSMenuItem alloc] initWithTitle: NSLocalizedStringFromTable(satMenuItemName,@"po",@"") action: nil keyEquivalent: @""]; + mi = [[NSMenuItem alloc] initWithTitle:[NSString stringWithUTF8String:_([satMenuItemName UTF8String])] action: nil keyEquivalent: @""]; [mi addPlanetarySystemMenuForItem: browseItem target: aTarget action: @selector(selectSatellite:)]; @@ -197,7 +198,7 @@ NSArray *childChildren; unsigned childCount = 0; BOOL loneChild = NO; - NSString *locationsName = NSLocalizedStringFromTable(@"Locations",@"po",@""); + NSString *locationsName =[NSString stringWithUTF8String:_("Locations")]; NSArray *children = [browseItem allChildNames]; NSEnumerator *childEnum = [children objectEnumerator]; @@ -272,7 +273,7 @@ unsigned i; for (i = 0; i < [surfaces count]; ++i) { - newItem = [[NSMenuItem alloc] initWithTitle: NSLocalizedStringFromTable([surfaces objectAtIndex: i],@"po",@"") action: action keyEquivalent: @""]; + newItem = [[NSMenuItem alloc] initWithTitle:[NSString stringWithUTF8String:_([[surfaces objectAtIndex: i] UTF8String])] action: action keyEquivalent: @""]; [newItem setTag: 601+i ]; [newItem setTarget: target ]; [ surfaceMenu addItem: newItem ]; diff --git a/macosx/celestia.xcodeproj/project.pbxproj b/macosx/celestia.xcodeproj/project.pbxproj index b6ec561bf..869563dcf 100644 --- a/macosx/celestia.xcodeproj/project.pbxproj +++ b/macosx/celestia.xcodeproj/project.pbxproj @@ -231,8 +231,8 @@ E5D3E6550D1EA18A00214838 /* axisarrow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E5D3E6530D1EA18A00214838 /* axisarrow.cpp */; }; E5D446660777291700A1577D /* utf8.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E5D446640777291700A1577D /* utf8.cpp */; }; E5D4467607772B6C00A1577D /* CelestiaSettings.mm in Sources */ = {isa = PBXBuildFile; fileRef = E5D4467407772B6C00A1577D /* CelestiaSettings.mm */; }; - E5D4467807772BA000A1577D /* CGLInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = F505BFFA02CA9DAE0100020A /* CGLInfo.m */; }; - E5D542770D0B87EA00E8C513 /* Menu_Extensions.m in Sources */ = {isa = PBXBuildFile; fileRef = E5D5425F0D0B86B200E8C513 /* Menu_Extensions.m */; }; + E5D4467807772BA000A1577D /* CGLInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = F505BFFA02CA9DAE0100020A /* CGLInfo.mm */; }; + E5D542770D0B87EA00E8C513 /* Menu_Extensions.mm in Sources */ = {isa = PBXBuildFile; fileRef = E5D5425F0D0B86B200E8C513 /* Menu_Extensions.mm */; }; E5D766140982B1860099DBBD /* HelpWindow.nib in Resources */ = {isa = PBXBuildFile; fileRef = E5D7660E0982B1860099DBBD /* HelpWindow.nib */; }; E5D766700982B4660099DBBD /* amalthea.cmod in Copy Models */ = {isa = PBXBuildFile; fileRef = E5D766270982B3300099DBBD /* amalthea.cmod */; }; E5D766720982B4660099DBBD /* asteroid.cms in Copy Models */ = {isa = PBXBuildFile; fileRef = E5D766290982B3300099DBBD /* asteroid.cms */; }; @@ -681,7 +681,7 @@ E5D4467407772B6C00A1577D /* CelestiaSettings.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CelestiaSettings.mm; sourceTree = ""; }; E5D471260778E33C007731C3 /* libpng.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libpng.dylib; path = Frameworks/libpng.dylib; sourceTree = ""; }; E5D5425E0D0B86B200E8C513 /* Menu_Extensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Menu_Extensions.h; sourceTree = ""; }; - E5D5425F0D0B86B200E8C513 /* Menu_Extensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Menu_Extensions.m; sourceTree = ""; }; + E5D5425F0D0B86B200E8C513 /* Menu_Extensions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Menu_Extensions.mm; sourceTree = ""; }; E5D7660B0982B15C0099DBBD /* es */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = es; path = es.lproj/Credits.rtf; sourceTree = ""; }; E5D7660C0982B1630099DBBD /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = fr; path = fr.lproj/Credits.rtf; sourceTree = ""; }; E5D766150982B19F0099DBBD /* fr */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = fr; path = fr.lproj/HelpWindow.nib; sourceTree = ""; }; @@ -750,7 +750,7 @@ F5040B0602A47B91014901DC /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = ""; }; F5040B0E02A484DA014901DC /* CelestiaController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CelestiaController.h; sourceTree = ""; }; F5040B0F02A484DA014901DC /* CelestiaController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CelestiaController.m; sourceTree = ""; }; - F505BFFA02CA9DAE0100020A /* CGLInfo.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CGLInfo.m; sourceTree = ""; }; + F505BFFA02CA9DAE0100020A /* CGLInfo.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CGLInfo.mm; sourceTree = ""; }; F505BFFB02CA9DAE0100020A /* CGLInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CGLInfo.h; sourceTree = ""; }; F51C6D450295968D014901DC /* 3dsmodel.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = 3dsmodel.cpp; path = ../src/cel3ds/3dsmodel.cpp; sourceTree = SOURCE_ROOT; }; F51C6D460295968D014901DC /* 3dsmodel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = 3dsmodel.h; path = ../src/cel3ds/3dsmodel.h; sourceTree = SOURCE_ROOT; }; @@ -1034,7 +1034,7 @@ F5231C7102C2997601000006 /* CelestiaFavorites.m */, F5274ED302AE88260100020A /* CelestiaOpenGLView.mm */, E5D4467407772B6C00A1577D /* CelestiaSettings.mm */, - F505BFFA02CA9DAE0100020A /* CGLInfo.m */, + F505BFFA02CA9DAE0100020A /* CGLInfo.mm */, E51224580CF9FC7D009092A2 /* BrowserItem.mm */, E54343150783C42500053094 /* BrowserWindowController.mm */, E50CCA680C06632A00E9C76A /* EclipseFinderController.mm */, @@ -1738,7 +1738,7 @@ isa = PBXGroup; children = ( F57F9FD402B94A0B01000006 /* ContextOutlineView.m */, - E5D5425F0D0B86B200E8C513 /* Menu_Extensions.m */, + E5D5425F0D0B86B200E8C513 /* Menu_Extensions.mm */, F56FFFAA02C571280100020A /* MyTree.m */, F578B7A102B3E2DD0100020A /* NSArray_Extensions.m */, F578B7A002B3E2DD0100020A /* NSOutlineView_Extensions.m */, @@ -2030,7 +2030,7 @@ E56431630776D5C800E2C4A3 /* starcolors.cpp in Sources */, E5D446660777291700A1577D /* utf8.cpp in Sources */, E5D4467607772B6C00A1577D /* CelestiaSettings.mm in Sources */, - E5D4467807772BA000A1577D /* CGLInfo.m in Sources */, + E5D4467807772BA000A1577D /* CGLInfo.mm in Sources */, E54343170783C42500053094 /* BrowserWindowController.mm in Sources */, E589B6DD078AC511005B8DD9 /* glshader.cpp in Sources */, E589B6DF078AC511005B8DD9 /* shadermanager.cpp in Sources */, @@ -2058,7 +2058,7 @@ E5B48EBA0C22065E00C6FBD7 /* MacInputWatcher.mm in Sources */, E5E2BDD70C24F7E6000D6E83 /* TextWindowController.m in Sources */, E512245A0CF9FC7D009092A2 /* BrowserItem.mm in Sources */, - E5D542770D0B87EA00E8C513 /* Menu_Extensions.m in Sources */, + E5D542770D0B87EA00E8C513 /* Menu_Extensions.mm in Sources */, E5D3E6550D1EA18A00214838 /* axisarrow.cpp in Sources */, E5CAABA70D3D7A08001926FC /* POSupport.cpp in Sources */, 8844B87E0D5AA3290059AA3A /* customrotation.cpp in Sources */,