Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Create a basic working Mac version unlocalised

  • Loading branch information...
commit 150fcb19de8f9488b36ca7e83cfac5b7bf2f53b5 1 parent fdb153f
@Abizern authored
View
21 LocalisingTestMac/LocalisingTestMac.xcodeproj/project.pbxproj
@@ -7,8 +7,11 @@
objects = {
/* Begin PBXBuildFile section */
+ AD1F3BAD1515D07400737939 /* fish_n_chips.png in Resources */ = {isa = PBXBuildFile; fileRef = AD1F3BA91515D07400737939 /* fish_n_chips.png */; };
+ AD1F3BAF1515D07400737939 /* paella.png in Resources */ = {isa = PBXBuildFile; fileRef = AD1F3BAB1515D07400737939 /* paella.png */; };
AD58426F1515AEC900785656 /* MainWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = AD58426E1515AEC900785656 /* MainWindowController.m */; };
AD5842731515B0DA00785656 /* MainWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = AD5842711515B0DA00785656 /* MainWindowController.xib */; };
+ AD5842751515B65B00785656 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = AD5842741515B65B00785656 /* Localizable.strings */; };
ADA8582D15159A6C0091AADE /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ADA8582C15159A6C0091AADE /* Cocoa.framework */; };
ADA8583715159A6C0091AADE /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = ADA8583515159A6C0091AADE /* InfoPlist.strings */; };
ADA8583915159A6C0091AADE /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = ADA8583815159A6C0091AADE /* main.m */; };
@@ -19,9 +22,12 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
+ AD1F3BA91515D07400737939 /* fish_n_chips.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = fish_n_chips.png; sourceTree = "<group>"; };
+ AD1F3BAB1515D07400737939 /* paella.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = paella.png; sourceTree = "<group>"; };
AD58426D1515AEC900785656 /* MainWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainWindowController.h; sourceTree = "<group>"; };
AD58426E1515AEC900785656 /* MainWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainWindowController.m; sourceTree = "<group>"; };
AD5842721515B0DA00785656 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainWindowController.xib; sourceTree = "<group>"; };
+ AD5842741515B65B00785656 /* Localizable.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; path = Localizable.strings; sourceTree = "<group>"; };
ADA8582815159A6C0091AADE /* LocalisingTestMac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LocalisingTestMac.app; sourceTree = BUILT_PRODUCTS_DIR; };
ADA8582C15159A6C0091AADE /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
ADA8582F15159A6C0091AADE /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
@@ -51,6 +57,16 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
+ AD1F3BA81515D07400737939 /* Images */ = {
+ isa = PBXGroup;
+ children = (
+ AD1F3BA91515D07400737939 /* fish_n_chips.png */,
+ AD1F3BAB1515D07400737939 /* paella.png */,
+ );
+ name = Images;
+ path = ../../Images;
+ sourceTree = "<group>";
+ };
ADA8581D15159A6B0091AADE = {
isa = PBXGroup;
children = (
@@ -105,6 +121,8 @@
ADA8583315159A6C0091AADE /* Supporting Files */ = {
isa = PBXGroup;
children = (
+ AD1F3BA81515D07400737939 /* Images */,
+ AD5842741515B65B00785656 /* Localizable.strings */,
ADA8583415159A6C0091AADE /* Info.plist */,
ADA8583515159A6C0091AADE /* InfoPlist.strings */,
ADA8583815159A6C0091AADE /* main.m */,
@@ -169,6 +187,9 @@
ADA8583D15159A6C0091AADE /* Credits.rtf in Resources */,
ADA8584315159A6C0091AADE /* MainMenu.xib in Resources */,
AD5842731515B0DA00785656 /* MainWindowController.xib in Resources */,
+ AD5842751515B65B00785656 /* Localizable.strings in Resources */,
+ AD1F3BAD1515D07400737939 /* fish_n_chips.png in Resources */,
+ AD1F3BAF1515D07400737939 /* paella.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
12 LocalisingTestMac/LocalisingTestMac/Localizable.strings
@@ -0,0 +1,12 @@
+
+/* The name of the image file */
+"kImageFile" = "fish_n_chips";
+
+/* Initial button text 'What should I do' */
+"kInitialButtonText" = "What should I do?";
+
+/* Shut up and eat */
+"kLabelText" = "Shut up and eat!";
+
+/* Alternate button text 'Ok' */
+"kAlternateButtonText" = "OK";
View
4 LocalisingTestMac/LocalisingTestMac/MainWindowController.h
@@ -10,4 +10,8 @@
@interface MainWindowController : NSWindowController
+@property (weak) IBOutlet NSButton *button;
+
+- (IBAction)buttonClicked:(id)sender;
+
@end
View
102 LocalisingTestMac/LocalisingTestMac/MainWindowController.m
@@ -3,21 +3,119 @@
// LocalisingTestMac
//
// Created by Abizer Nasir on 18/03/2012.
-// Copyright (c) 2012 Jungle Candy Software. All rights reserved.
//
+static NSString* const kImageFile = @"kImageFile";
+static NSString* const kLabelText = @"kLabelText";
+static NSString* const kInitialButtonText = @"kInitialButtonText";
+static NSString* const kAlternateButtonText = @"kAlternateButtonText";
+
#import "MainWindowController.h"
+#import <QuartzCore/QuartzCore.h>
@interface MainWindowController ()
+@property (assign, nonatomic) BOOL imageShowing;
+@property (strong, nonatomic) CALayer *imageLayer;
+@property (strong, nonatomic) CATextLayer *textLayer;
+@property (assign, nonatomic) CGPoint initialTextLayerPosition;
+@property (assign, nonatomic) CGPoint displayTextLayerPosition;
+@property (assign, nonatomic) CGPoint initialImageLayerPosition;
+@property (assign, nonatomic) CGPoint displayImageLayerPosition;
+
+- (void)setupTextLayer;
+- (void)setupImageLayer;
+- (void)updateButtonText;
+
@end
@implementation MainWindowController
+@synthesize button = _button;
+@synthesize imageShowing = _imageShowing;
+@synthesize imageLayer = _imageLayer;
+@synthesize textLayer = _textLayer;
+@synthesize initialTextLayerPosition = _initialTextLayerPosition;
+@synthesize displayTextLayerPosition = _displayTextLayerPosition;
+@synthesize initialImageLayerPosition = _initialImageLayerPosition;
+@synthesize displayImageLayerPosition = _displayImageLayerPosition;
- (void)windowDidLoad {
[super windowDidLoad];
+ [[[self window] contentView] setWantsLayer:YES];
+
+ self.imageShowing = NO;
+
+ self.initialTextLayerPosition = CGPointMake(463.0f, 470.0f);
+ self.displayTextLayerPosition = CGPointMake(160.0f, 168.0f);
+
+ self.initialImageLayerPosition = CGPointMake(-160.0f, 580.0f);
+ self.displayImageLayerPosition = CGPointMake(160.0f, 340.0f);
+
+ [self setupTextLayer];
+ [self setupImageLayer];
+
+}
+
+#pragma mark - IBAction methods
+
+- (IBAction)buttonClicked:(id)sender {
+ if (self.imageShowing) {
+ self.imageShowing = NO;
+ self.textLayer.position = self.initialTextLayerPosition;
+ self.imageLayer.position = self.initialImageLayerPosition;
+ } else {
+ self.imageShowing = YES;
+ self.textLayer.position = self.displayTextLayerPosition;
+ self.imageLayer.position = self.displayImageLayerPosition;
+ }
+ [self updateButtonText];
+}
+
+#pragma mark - Private helper methods
+
+- (void)setupTextLayer {
+ CATextLayer *theLayer = [CATextLayer layer];
+ theLayer.font = (__bridge CFTypeRef)[NSFont systemFontOfSize:0.0f];
+ theLayer.fontSize = 13.0f;
+
+ theLayer.bounds = CGRectMake(0.0f, 0.0f, 286.0f, 20.0f);
+ theLayer.alignmentMode = kCAAlignmentCenter;
+
+ CGColorRef textColour = CGColorCreateGenericRGB(0.0f, 0.0f, 0.0f, 1.0f);
+ theLayer.foregroundColor = textColour;
+ CGColorRelease(textColour);
+
+
+ theLayer.string = NSLocalizedString(kLabelText, nil);
+
+ theLayer.position = self.initialTextLayerPosition;
+
+ self.textLayer = theLayer;
+
+ [[[[self window] contentView] layer] addSublayer:self.textLayer];
+}
+
+- (void)setupImageLayer {
+ CALayer *theLayer = [CALayer layer];
+ theLayer.bounds = CGRectMake(0.0f, 0.0f, 320.0f, 240.0f);
+ theLayer.position = self.initialImageLayerPosition;
+
+ NSString *imageFileName = NSLocalizedString(kImageFile, nil);
+ theLayer.contents = [NSImage imageNamed:imageFileName];
+
+
+ self.imageLayer = theLayer;
+
+ [[[self.window contentView] layer] addSublayer:self.imageLayer];
+
+}
- // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
+- (void)updateButtonText {
+ if (self.imageShowing) {
+ self.button.title = NSLocalizedString(kAlternateButtonText, nil);
+ } else {
+ self.button.title = NSLocalizedString(kInitialButtonText, nil);
+ }
}
@end
View
149 LocalisingTestMac/LocalisingTestMac/en.lproj/MainWindowController.xib
@@ -11,9 +11,12 @@
<string key="NS.object.0">2182</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
+ <string>IBNSLayoutConstraint</string>
<string>NSWindowTemplate</string>
<string>NSView</string>
+ <string>NSButtonCell</string>
<string>NSCustomObject</string>
+ <string>NSButton</string>
</array>
<array key="IBDocument.PluginDependencies">
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -32,7 +35,7 @@
<object class="NSCustomObject" id="1004">
<string key="NSClassName">NSApplication</string>
</object>
- <object class="NSWindowTemplate" id="1002124278">
+ <object class="NSWindowTemplate" id="474765513">
<int key="NSWindowStyleMask">7</int>
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{335, 390}, {320, 460}}</string>
@@ -42,13 +45,43 @@
<nil key="NSViewClass"/>
<nil key="NSUserInterfaceItemIdentifier"/>
<string key="NSWindowContentMaxSize">{320, 460}</string>
- <object class="NSView" key="NSWindowView" id="119717214">
+ <object class="NSView" key="NSWindowView" id="242900106">
<reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSButton" id="396397035">
+ <reference key="NSNextResponder" ref="242900106"/>
+ <int key="NSvFlags">268</int>
+ <string key="NSFrame">{{84, 53}, {152, 32}}</string>
+ <reference key="NSSuperview" ref="242900106"/>
+ <int key="NSViewLayerContentsRedrawPolicy">2</int>
+ <string key="NSReuseIdentifierKey">_NS:9</string>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="711223039">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">134217728</int>
+ <string key="NSContents">What should I do?</string>
+ <object class="NSFont" key="NSSupport">
+ <string key="NSName">LucidaGrande</string>
+ <double key="NSSize">13</double>
+ <int key="NSfFlags">1044</int>
+ </object>
+ <string key="NSCellIdentifier">_NS:9</string>
+ <reference key="NSControlView" ref="396397035"/>
+ <int key="NSButtonFlags">-2038284033</int>
+ <int key="NSButtonFlags2">129</int>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ </array>
<string key="NSFrameSize">{320, 460}</string>
<reference key="NSSuperview"/>
- <reference key="NSWindow"/>
- <reference key="NSNextKeyView"/>
+ <reference key="NSNextKeyView" ref="396397035"/>
+ <bool key="NSViewIsLayerTreeHost">YES</bool>
+ <int key="NSViewLayerContentsRedrawPolicy">2</int>
</object>
<string key="NSScreenRect">{{0, 0}, {1920, 1058}}</string>
<string key="NSMaxSize">{320, 482}</string>
@@ -61,10 +94,26 @@
<object class="IBOutletConnection" key="connection">
<string key="label">window</string>
<reference key="source" ref="1001"/>
- <reference key="destination" ref="1002124278"/>
+ <reference key="destination" ref="474765513"/>
</object>
<int key="connectionID">5</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">button</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="396397035"/>
+ </object>
+ <int key="connectionID">20</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">buttonClicked:</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="396397035"/>
+ </object>
+ <int key="connectionID">21</int>
+ </object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
@@ -94,16 +143,74 @@
</object>
<object class="IBObjectRecord">
<int key="objectID">3</int>
- <reference key="object" ref="1002124278"/>
+ <reference key="object" ref="474765513"/>
<array class="NSMutableArray" key="children">
- <reference ref="119717214"/>
+ <reference ref="242900106"/>
</array>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">4</int>
- <reference key="object" ref="119717214"/>
- <reference key="parent" ref="1002124278"/>
+ <reference key="object" ref="242900106"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="396397035"/>
+ <object class="IBNSLayoutConstraint" id="5455448">
+ <reference key="firstItem" ref="242900106"/>
+ <int key="firstAttribute">4</int>
+ <int key="relation">0</int>
+ <reference key="secondItem" ref="396397035"/>
+ <int key="secondAttribute">4</int>
+ <float key="multiplier">1</float>
+ <object class="IBLayoutConstant" key="constant">
+ <double key="value">61</double>
+ </object>
+ <float key="priority">1000</float>
+ <int key="scoringType">3</int>
+ <float key="scoringTypeFloat">9</float>
+ <int key="contentType">3</int>
+ <reference key="containingView" ref="242900106"/>
+ </object>
+ <object class="IBNSLayoutConstraint" id="452395413">
+ <reference key="firstItem" ref="396397035"/>
+ <int key="firstAttribute">9</int>
+ <int key="relation">0</int>
+ <reference key="secondItem" ref="242900106"/>
+ <int key="secondAttribute">9</int>
+ <float key="multiplier">1</float>
+ <object class="IBLayoutConstant" key="constant">
+ <double key="value">0.0</double>
+ </object>
+ <float key="priority">1000</float>
+ <int key="scoringType">5</int>
+ <float key="scoringTypeFloat">22</float>
+ <int key="contentType">2</int>
+ <reference key="containingView" ref="242900106"/>
+ </object>
+ </array>
+ <reference key="parent" ref="474765513"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">8</int>
+ <reference key="object" ref="396397035"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="711223039"/>
+ </array>
+ <reference key="parent" ref="242900106"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">9</int>
+ <reference key="object" ref="711223039"/>
+ <reference key="parent" ref="396397035"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">39</int>
+ <reference key="object" ref="5455448"/>
+ <reference key="parent" ref="242900106"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">44</int>
+ <reference key="object" ref="452395413"/>
+ <reference key="parent" ref="242900106"/>
</object>
</array>
</object>
@@ -114,26 +221,24 @@
<string key="3.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="3.IBWindowTemplateEditedContentRect">{{380, 496}, {480, 360}}</string>
<integer value="1" key="3.NSWindowTemplate.visibleAtLaunch"/>
+ <string key="39.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <array key="4.IBNSViewMetadataConstraints">
+ <reference ref="5455448"/>
+ <reference ref="452395413"/>
+ </array>
<string key="4.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="44.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <boolean value="NO" key="8.IBNSViewMetadataTranslatesAutoresizingMaskIntoConstraints"/>
+ <string key="8.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="9.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
- <int key="maxID">5</int>
- </object>
- <object class="IBClassDescriber" key="IBDocument.Classes">
- <array class="NSMutableArray" key="referencedPartialClassDescriptions">
- <object class="IBPartialClassDescription">
- <string key="className">MainWindowController</string>
- <string key="superclassName">NSWindowController</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBProjectSource</string>
- <string key="minorKey">./Classes/MainWindowController.h</string>
- </object>
- </object>
- </array>
+ <int key="maxID">49</int>
</object>
+ <object class="IBClassDescriber" key="IBDocument.Classes"/>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
Please sign in to comment.
Something went wrong with that request. Please try again.