Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updates for Mac OS X 10.8 and Xcode 4.5

  • Loading branch information...
commit 7033708dbaeea846601e696a55608434ef817daf 1 parent 955f706
Whitney Young wbyoung authored
8 Example/Example.xcodeproj/project.pbxproj
@@ -275,7 +275,7 @@
275 275 );
276 276 runOnlyForDeploymentPostprocessing = 0;
277 277 shellPath = /bin/sh;
278   - shellScript = "localization create -s. -r.";
  278 + shellScript = "export PATH=\"${GREENWICH_PATH}:${PATH}\"\nlocalization create -s. -r.";
279 279 showEnvVarsInLog = 0;
280 280 };
281 281 /* End PBXShellScriptBuildPhase section */
@@ -305,7 +305,8 @@
305 305 isa = XCBuildConfiguration;
306 306 buildSettings = {
307 307 GREENWICH_LOCALIZATION_SYMBOL = MyLocalizedString;
308   - PATH = "$(SRCROOT)/../Framework/Scripts:$(PATH)";
  308 + GREENWICH_PATH = "$(SRCROOT)/../Framework/Scripts:$(PATH)";
  309 + PATH = "$(GREENWICH_PATH):$(PATH)";
309 310 SYMROOT = ../build;
310 311 };
311 312 name = Debug;
@@ -314,7 +315,8 @@
314 315 isa = XCBuildConfiguration;
315 316 buildSettings = {
316 317 GREENWICH_LOCALIZATION_SYMBOL = MyLocalizedString;
317   - PATH = "$(SRCROOT)/../Framework/Scripts:$(PATH)";
  318 + GREENWICH_PATH = "$(SRCROOT)/../Framework/Scripts:$(PATH)";
  319 + PATH = "$(GREENWICH_PATH):$(PATH)";
318 320 SYMROOT = ../build;
319 321 };
320 322 name = Release;
2  Example/Example.xcodeproj/xcshareddata/xcschemes/GreenwichExample.xcscheme
... ... @@ -1,6 +1,6 @@
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <Scheme
3   - LastUpgradeVersion = "0430"
  3 + LastUpgradeVersion = "0450"
4 4 version = "1.3">
5 5 <BuildAction
6 6 parallelizeBuildables = "YES"
99 Framework/Greenwich.xcodeproj/project.pbxproj
@@ -7,17 +7,6 @@
7 7 objects = {
8 8
9 9 /* Begin PBXAggregateTarget section */
10   - 8B153D1C15292EAB00098298 /* Package (Simulator) */ = {
11   - isa = PBXAggregateTarget;
12   - buildConfigurationList = 8B153D1F15292EAB00098298 /* Build configuration list for PBXAggregateTarget "Package (Simulator)" */;
13   - buildPhases = (
14   - );
15   - dependencies = (
16   - 8B153D2215292ECB00098298 /* PBXTargetDependency */,
17   - );
18   - name = "Package (Simulator)";
19   - productName = "Package (Simulator)";
20   - };
21 10 8BB93D4F1474CAA90056EC71 /* Package */ = {
22 11 isa = PBXAggregateTarget;
23 12 buildConfigurationList = 8BB93D521474CAA90056EC71 /* Build configuration list for PBXAggregateTarget "Package" */;
@@ -26,9 +15,6 @@
26 15 );
27 16 dependencies = (
28 17 8BB93D551474CAC00056EC71 /* PBXTargetDependency */,
29   - 8B40BE8915289D7800D1A161 /* PBXTargetDependency */,
30   - 8B40BE7D15289C8900D1A161 /* PBXTargetDependency */,
31   - 8B40BEBB1528A2F400D1A161 /* PBXTargetDependency */,
32 18 );
33 19 name = Package;
34 20 productName = Package;
@@ -127,34 +113,6 @@
127 113 /* End PBXBuildFile section */
128 114
129 115 /* Begin PBXContainerItemProxy section */
130   - 8B153D2115292ECB00098298 /* PBXContainerItemProxy */ = {
131   - isa = PBXContainerItemProxy;
132   - containerPortal = 8BAD1E54146F114700E16433 /* Project object */;
133   - proxyType = 1;
134   - remoteGlobalIDString = 8BD5E23214D1E7C80021848F;
135   - remoteInfo = "Greenwich (iOS)";
136   - };
137   - 8B40BE7C15289C8900D1A161 /* PBXContainerItemProxy */ = {
138   - isa = PBXContainerItemProxy;
139   - containerPortal = 8BAD1E54146F114700E16433 /* Project object */;
140   - proxyType = 1;
141   - remoteGlobalIDString = 8B2B99A114D347C400A40CD4;
142   - remoteInfo = Translator;
143   - };
144   - 8B40BE8815289D7800D1A161 /* PBXContainerItemProxy */ = {
145   - isa = PBXContainerItemProxy;
146   - containerPortal = 8BAD1E54146F114700E16433 /* Project object */;
147   - proxyType = 1;
148   - remoteGlobalIDString = 8BD5E23214D1E7C80021848F;
149   - remoteInfo = "Greenwich (iOS)";
150   - };
151   - 8B40BEBA1528A2F400D1A161 /* PBXContainerItemProxy */ = {
152   - isa = PBXContainerItemProxy;
153   - containerPortal = 8BAD1E54146F114700E16433 /* Project object */;
154   - proxyType = 1;
155   - remoteGlobalIDString = 8F6BF6FE14CA19CD00C25754;
156   - remoteInfo = Proofer;
157   - };
158 116 8BB93D541474CAC00056EC71 /* PBXContainerItemProxy */ = {
159 117 isa = PBXContainerItemProxy;
160 118 containerPortal = 8BAD1E54146F114700E16433 /* Project object */;
@@ -691,7 +649,7 @@
691 649 8BAD1E54146F114700E16433 /* Project object */ = {
692 650 isa = PBXProject;
693 651 attributes = {
694   - LastUpgradeCheck = 0430;
  652 + LastUpgradeCheck = 0450;
695 653 };
696 654 buildConfigurationList = 8BAD1E57146F114700E16433 /* Build configuration list for PBXProject "Greenwich" */;
697 655 compatibilityVersion = "Xcode 3.2";
@@ -718,7 +676,6 @@
718 676 8BF40E241527BBCB00DEFE74 /* Greenwich (iOS Wrapper) */,
719 677 8B2B99A114D347C400A40CD4 /* Translator */,
720 678 8BB93D4F1474CAA90056EC71 /* Package */,
721   - 8B153D1C15292EAB00098298 /* Package (Simulator) */,
722 679 8F6BF6FE14CA19CD00C25754 /* Proofer */,
723 680 );
724 681 };
@@ -772,7 +729,7 @@
772 729 );
773 730 runOnlyForDeploymentPostprocessing = 0;
774 731 shellPath = /bin/sh;
775   - shellScript = "localization create -s Source/Mac -r Resources/Mac";
  732 + shellScript = "export PATH=\"${GREENWICH_PATH}:${PATH}\"\nlocalization create -s Source/Mac -r Resources/Mac";
776 733 showEnvVarsInLog = 0;
777 734 };
778 735 8B11043814FB33AE004D17D7 /* Copy libarchive */ = {
@@ -817,7 +774,7 @@
817 774 );
818 775 runOnlyForDeploymentPostprocessing = 0;
819 776 shellPath = /bin/sh;
820   - shellScript = "localization create -s Source/iOS -r Resources/iOS";
  777 + shellScript = "export PATH=\"${GREENWICH_PATH}:${PATH}\"\nlocalization create -s Source/iOS -r Resources/iOS";
821 778 showEnvVarsInLog = 0;
822 779 };
823 780 8BA68C2B150C0FB100712760 /* Update & Copy Localizations */ = {
@@ -832,7 +789,7 @@
832 789 );
833 790 runOnlyForDeploymentPostprocessing = 0;
834 791 shellPath = /bin/sh;
835   - shellScript = "localization create -s Source/Mac -r Resources/Mac/Translator:Resources/Mac";
  792 + shellScript = "export PATH=\"${GREENWICH_PATH}:${PATH}\"\nlocalization create -s Source/Mac -r Resources/Mac/Translator:Resources/Mac";
836 793 showEnvVarsInLog = 0;
837 794 };
838 795 8BB93D561474CACB0056EC71 /* Package */ = {
@@ -938,26 +895,6 @@
938 895 /* End PBXSourcesBuildPhase section */
939 896
940 897 /* Begin PBXTargetDependency section */
941   - 8B153D2215292ECB00098298 /* PBXTargetDependency */ = {
942   - isa = PBXTargetDependency;
943   - target = 8BD5E23214D1E7C80021848F /* Greenwich (iOS) */;
944   - targetProxy = 8B153D2115292ECB00098298 /* PBXContainerItemProxy */;
945   - };
946   - 8B40BE7D15289C8900D1A161 /* PBXTargetDependency */ = {
947   - isa = PBXTargetDependency;
948   - target = 8B2B99A114D347C400A40CD4 /* Translator */;
949   - targetProxy = 8B40BE7C15289C8900D1A161 /* PBXContainerItemProxy */;
950   - };
951   - 8B40BE8915289D7800D1A161 /* PBXTargetDependency */ = {
952   - isa = PBXTargetDependency;
953   - target = 8BD5E23214D1E7C80021848F /* Greenwich (iOS) */;
954   - targetProxy = 8B40BE8815289D7800D1A161 /* PBXContainerItemProxy */;
955   - };
956   - 8B40BEBB1528A2F400D1A161 /* PBXTargetDependency */ = {
957   - isa = PBXTargetDependency;
958   - target = 8F6BF6FE14CA19CD00C25754 /* Proofer */;
959   - targetProxy = 8B40BEBA1528A2F400D1A161 /* PBXContainerItemProxy */;
960   - };
961 898 8BB93D551474CAC00056EC71 /* PBXTargetDependency */ = {
962 899 isa = PBXTargetDependency;
963 900 target = 8BAD1E6F146F11CB00E16433 /* Greenwich */;
@@ -982,20 +919,6 @@
982 919 /* End PBXVariantGroup section */
983 920
984 921 /* Begin XCBuildConfiguration section */
985   - 8B153D1D15292EAB00098298 /* Debug */ = {
986   - isa = XCBuildConfiguration;
987   - buildSettings = {
988   - PRODUCT_NAME = "$(TARGET_NAME)";
989   - };
990   - name = Debug;
991   - };
992   - 8B153D1E15292EAB00098298 /* Release */ = {
993   - isa = XCBuildConfiguration;
994   - buildSettings = {
995   - PRODUCT_NAME = "$(TARGET_NAME)";
996   - };
997   - name = Release;
998   - };
999 922 8B2B99BB14D347C500A40CD4 /* Debug */ = {
1000 923 isa = XCBuildConfiguration;
1001 924 baseConfigurationReference = 8BAD1EB3146F159C00E16433 /* Base.xcconfig */;
@@ -1037,7 +960,8 @@
1037 960 baseConfigurationReference = 8BAD1EB1146F158E00E16433 /* Project.debug.xcconfig */;
1038 961 buildSettings = {
1039 962 FR_FRAMEWORKS_DIR = "$(PROJECT_DIR)/..";
1040   - PATH = "$(SRCROOT)/Scripts:$(PATH)";
  963 + GREENWICH_PATH = "$(SRCROOT)/Scripts:$(PATH)";
  964 + PATH = "$(GREENWICH_PATH):$(PATH)";
1041 965 SYMROOT = ../build;
1042 966 };
1043 967 name = Debug;
@@ -1047,7 +971,8 @@
1047 971 baseConfigurationReference = 8BAD1EB2146F158E00E16433 /* Project.release.xcconfig */;
1048 972 buildSettings = {
1049 973 FR_FRAMEWORKS_DIR = "$(PROJECT_DIR)/..";
1050   - PATH = "$(SRCROOT)/Scripts:$(PATH)";
  974 + GREENWICH_PATH = "$(SRCROOT)/Scripts:$(PATH)";
  975 + PATH = "$(GREENWICH_PATH):$(PATH)";
1051 976 SYMROOT = ../build;
1052 977 };
1053 978 name = Release;
@@ -1235,14 +1160,6 @@
1235 1160 /* End XCBuildConfiguration section */
1236 1161
1237 1162 /* Begin XCConfigurationList section */
1238   - 8B153D1F15292EAB00098298 /* Build configuration list for PBXAggregateTarget "Package (Simulator)" */ = {
1239   - isa = XCConfigurationList;
1240   - buildConfigurations = (
1241   - 8B153D1D15292EAB00098298 /* Debug */,
1242   - 8B153D1E15292EAB00098298 /* Release */,
1243   - );
1244   - defaultConfigurationIsVisible = 0;
1245   - };
1246 1163 8B2B99BD14D347C500A40CD4 /* Build configuration list for PBXNativeTarget "Translator" */ = {
1247 1164 isa = XCConfigurationList;
1248 1165 buildConfigurations = (
4 Framework/Source/Mac/FRLocalizationWindowController.m
@@ -327,7 +327,7 @@ - (IBAction)packageStringsFiles:(id)sender {
327 327 NSFileManager *fileManager = [NSFileManager defaultManager];
328 328 char *tmpname = NULL;
329 329 asprintf(&tmpname, "%s/translation.XXXXXX", [NSTemporaryDirectory() UTF8String]);
330   - mktemp(tmpname);
  330 + mkdtemp(tmpname);
331 331 NSString *temp = [[NSString stringWithUTF8String:tmpname] stringByAppendingPathComponent:
332 332 [[NSBundle mainBundle] name]];
333 333 free(tmpname);
@@ -412,7 +412,7 @@ - (IBAction)sendToDevice:(id)sender {
412 412
413 413 - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)row {
414 414 if ([[aTableColumn identifier] isEqualToString:@"index"]) {
415   - return [NSString stringWithFormat:@"%i", row + 1];
  415 + return [NSString stringWithFormat:@"%ti", row + 1];
416 416 } else {
417 417 return nil;
418 418 }
75 Framework/Source/Mac/FRNibAutomaticLocalization.m
@@ -25,6 +25,7 @@
25 25
26 26 static int FRAutomaticLocalizationBundleKey;
27 27 static int FRAutomaticLocalizationTableKey;
  28 +static int FRAutomaticLocalizationProgressCountKey;
28 29
29 30 static Class gTextFinderClass = nil;
30 31 static Class gPopoverClass = nil;
@@ -81,6 +82,8 @@ static BOOL FRLoadNibFile(id self, SEL _cmd, NSString *fileName, NSDictionary *c
81 82 static id (FRInitWithNib)(id self, SEL _cmd, NSString *nibName, NSBundle *bundle);
82 83 static BOOL (*SInstantiateNib)(id self, SEL _cmd, NSDictionary *externalNameTable);
83 84 static BOOL (FRInstantiateNib)(id self, SEL _cmd, NSDictionary *externalNameTable);
  85 +static BOOL (*SInstantiateNibWithOwner)(id self, SEL _cmd, id owner, NSArray **topLevelObjects);
  86 +static BOOL (FRInstantiateNibWithOwner)(id self, SEL _cmd, id owner, NSArray **topLevelObjects);
84 87
85 88 @implementation NSNib (FRNibAutomaticLocalization)
86 89
@@ -90,6 +93,9 @@ + (void)load {
90 93 [self swizzle:@selector(instantiateNibWithExternalNameTable:)
91 94 with:(IMP)FRInstantiateNib
92 95 store:(IMPPointer)&SInstantiateNib];
  96 + [self swizzle:@selector(instantiateNibWithOwner:topLevelObjects:)
  97 + with:(IMP)FRInstantiateNibWithOwner
  98 + store:(IMPPointer)&SInstantiateNibWithOwner];
93 99 }
94 100
95 101 static id FRInitWithContents(id self, SEL _cmd, NSURL *nibFileURL) {
@@ -118,6 +124,23 @@ static id FRInitWithNib(id self, SEL _cmd, NSString *nibName, NSBundle *bundle)
118 124 return self;
119 125 }
120 126
  127 +- (void)beginInitializationForLocalization {
  128 + NSUInteger count = [objc_getAssociatedObject(self, &FRAutomaticLocalizationProgressCountKey) unsignedIntegerValue];
  129 + NSNumber *value = [NSNumber numberWithUnsignedInteger:count+1];
  130 + objc_setAssociatedObject(self, &FRAutomaticLocalizationProgressCountKey, value, OBJC_ASSOCIATION_RETAIN);
  131 +}
  132 +
  133 +- (void)endInitializationForLocalization {
  134 + NSUInteger count = [objc_getAssociatedObject(self, &FRAutomaticLocalizationProgressCountKey) unsignedIntegerValue];
  135 + NSNumber *value = [NSNumber numberWithUnsignedInteger:count-1];
  136 + objc_setAssociatedObject(self, &FRAutomaticLocalizationProgressCountKey, value, OBJC_ASSOCIATION_RETAIN);
  137 +}
  138 +
  139 +- (BOOL)isInitializingForLocalization {
  140 + NSUInteger count = [objc_getAssociatedObject(self, &FRAutomaticLocalizationProgressCountKey) unsignedIntegerValue];
  141 + return count > 0;
  142 +}
  143 +
121 144 - (BOOL)automaticallyLocalizes {
122 145 return objc_getAssociatedObject(self, &FRAutomaticLocalizationTableKey) != nil;
123 146 }
@@ -416,33 +439,51 @@ - (void)localizeTextBinding:(NSString *)bindingName forObject:(id)object {
416 439 options:(NSDictionary *)newOptions];
417 440 }
418 441
  442 +- (BOOL)localizeInstantiatedNibWithOwner:(id)owner topLevelObjects:(NSArray *)topLevelObjects {
  443 + BOOL success = TRUE;
  444 + if ([self automaticallyLocalizes]) {
  445 + [self localizeObject:topLevelObjects];
  446 +
  447 + NSMutableSet *set = [NSMutableSet set];
  448 + if (topLevelObjects) { [set addObjectsFromArray:topLevelObjects]; }
  449 + if (owner) { [set addObject:owner]; }
  450 + for (id object in set) {
  451 + if ([object respondsToSelector:@selector(awakeFromLocalization)]) {
  452 + [object performSelector:@selector(awakeFromLocalization)];
  453 + }
  454 + }
  455 + }
  456 + return success;
  457 +}
  458 +
419 459 static BOOL FRInstantiateNib(id self, SEL _cmd, NSDictionary *externalNameTable) {
420 460 id nameTable = externalNameTable;
421 461 if (![externalNameTable objectForKey:NSNibTopLevelObjects]) {
422 462 nameTable = [externalNameTable mutableCopy];
423 463 [(NSMutableDictionary *)nameTable setObject:[NSMutableArray array] forKey:NSNibTopLevelObjects];
424 464 }
425   -
  465 +
  466 + BOOL shouldLocalize = [self isInitializingForLocalization] == FALSE;
  467 + [self beginInitializationForLocalization];
426 468 BOOL result = SInstantiateNib(self, _cmd, nameTable);
427   -
428   - if (result && [self automaticallyLocalizes]) {
429   - [self localizeObject:
430   - [nameTable objectForKey:NSNibTopLevelObjects]];
  469 + if (result && shouldLocalize) {
  470 + [self localizeInstantiatedNibWithOwner:[nameTable objectForKey:NSNibOwner]
  471 + topLevelObjects:[nameTable objectForKey:NSNibTopLevelObjects]];
431 472 }
  473 + [self endInitializationForLocalization];
  474 + return result;
  475 +}
432 476
433   - if (result && [self automaticallyLocalizes]) {
434   - NSMutableSet *set = [NSMutableSet set];
435   - NSArray *topLevel = [nameTable objectForKey:NSNibTopLevelObjects];
436   - NSObject *owner = [externalNameTable objectForKey:NSNibOwner];
437   - if (topLevel) { [set addObjectsFromArray:topLevel]; }
438   - if (owner) { [set addObject:owner]; }
439   - for (id object in set) {
440   - if ([object respondsToSelector:@selector(awakeFromLocalization)]) {
441   - [object performSelector:@selector(awakeFromLocalization)];
442   - }
443   - }
444   - }
  477 +static BOOL (FRInstantiateNibWithOwner)(id self, SEL _cmd, id owner, NSArray **topLevelObjects) {
  478 + topLevelObjects = topLevelObjects ? topLevelObjects : &(NSArray *){ nil };
445 479
  480 + BOOL shouldLocalize = [self isInitializingForLocalization] == FALSE;
  481 + [self beginInitializationForLocalization];
  482 + BOOL result = SInstantiateNibWithOwner(self, _cmd, owner, topLevelObjects);
  483 + if (result && shouldLocalize) {
  484 + [self localizeInstantiatedNibWithOwner:owner topLevelObjects:*topLevelObjects];
  485 + }
  486 + [self endInitializationForLocalization];
446 487 return result;
447 488 }
448 489
2  Framework/Source/Mac/FRUntranslatedCountCell.m
@@ -47,7 +47,7 @@ - (NSAttributedString *)untranslatedAttributedString {
47 47 NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
48 48 [style setAlignment:NSCenterTextAlignment];
49 49
50   - NSString *string = [NSString stringWithFormat:@"%i", untranslated];
  50 + NSString *string = [NSString stringWithFormat:@"%tu", untranslated];
51 51 NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
52 52 font, NSFontAttributeName,
53 53 color, NSForegroundColorAttributeName,

0 comments on commit 7033708

Please sign in to comment.
Something went wrong with that request. Please try again.