Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature delete nodes with outlets #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/fame/interface_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def nodes
raw_nodes = doc.xpath("//userDefinedRuntimeAttribute[@keyPath='#{LOCALIZATION_ENABLED_KEYPATH}']")

# Map raw nodes info to instances of LocalizedNode
raw_nodes.map do |node|
user_defined_nodes = raw_nodes.map do |node|
parent = node.parent.parent # i.e. UILabel, UISwitch, etc.
vc = parent.xpath("ancestor::viewController") # the view controller of the element (only available in .storyboard files)
element_name = parent.name # i.e. label, switch
Expand All @@ -46,6 +46,18 @@ def nodes

LocalizedNode.new(node, original_id, vc_name, element_name, i18n_enabled, i18n_comment)
end

# Grab raw nodes that have outlets (i.e. they are dynamically set in code)
raw_outlet_nodes = doc.xpath("//outlet")

# Map raw nodes info to instances of LocalizedNode (they will all have i18n_enabled set to false)
outlet_nodes = raw_outlet_nodes.map do |node|
original_id = node['destination']
i18n_enabled = false
LocalizedNode.new(node, original_id, nil, nil, i18n_enabled, nil)
end

user_defined_nodes + outlet_nodes
end

#
Expand Down
2 changes: 1 addition & 1 deletion lib/fame/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Fame
VERSION = "0.1"
VERSION = "0.1.1"
end
60 changes: 60 additions & 0 deletions platform/Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
4D8D894B1C8073FE004DD23A /* View.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4D8D89491C8073FE004DD23A /* View.xib */; };
4DA64ECD1C85E53A00894E22 /* SecondViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DA64ECC1C85E53A00894E22 /* SecondViewController.swift */; };
4DE85E1D1C8478D50073D5A0 /* Fame.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DE85E1C1C8478D50073D5A0 /* Fame.swift */; };
BC3D81001C91C8DE0040AF2A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = BC3D81021C91C8DE0040AF2A /* InfoPlist.strings */; };
BC3D81051C91C8DE0040AF2A /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = BC3D81071C91C8DE0040AF2A /* Localizable.strings */; };
BC3D810A1C91C8DF0040AF2A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = BC3D810C1C91C8DF0040AF2A /* InfoPlist.strings */; };
BC3D81101C91C8E00040AF2A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = BC3D81121C91C8E00040AF2A /* InfoPlist.strings */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -57,6 +61,16 @@
4D8D894F1C80743C004DD23A /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/View.strings; sourceTree = "<group>"; };
4DA64ECC1C85E53A00894E22 /* SecondViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SecondViewController.swift; sourceTree = "<group>"; };
4DE85E1C1C8478D50073D5A0 /* Fame.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Fame.swift; path = ../../Fame.swift; sourceTree = "<group>"; };
BC3D81011C91C8DE0040AF2A /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/InfoPlist.strings; sourceTree = "<group>"; };
BC3D81061C91C8DE0040AF2A /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Localizable.strings; sourceTree = "<group>"; };
BC3D810B1C91C8DF0040AF2A /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/InfoPlist.strings; sourceTree = "<group>"; };
BC3D810D1C91C8DF0040AF2A /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/LaunchScreen.strings; sourceTree = "<group>"; };
BC3D81111C91C8E00040AF2A /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/InfoPlist.strings; sourceTree = "<group>"; };
BC3D81131C91C9030040AF2A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
BC3D81141C91C9030040AF2A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
BC3D81151C91C9040040AF2A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
BC3D81161C91C9040040AF2A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/LaunchScreen.strings; sourceTree = "<group>"; };
BC3D81171C91C9040040AF2A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -107,6 +121,8 @@
4D01B0B61C7EFB0F00AAD90C /* Example */ = {
isa = PBXGroup;
children = (
BC3D81071C91C8DE0040AF2A /* Localizable.strings */,
BC3D81021C91C8DE0040AF2A /* InfoPlist.strings */,
4D01B0B71C7EFB0F00AAD90C /* AppDelegate.swift */,
4D01B0B91C7EFB0F00AAD90C /* FirstViewController.swift */,
4DA64ECC1C85E53A00894E22 /* SecondViewController.swift */,
Expand All @@ -123,6 +139,7 @@
4D01B0CB1C7EFB1000AAD90C /* ExampleTests */ = {
isa = PBXGroup;
children = (
BC3D810C1C91C8DF0040AF2A /* InfoPlist.strings */,
4D01B0CC1C7EFB1000AAD90C /* ExampleTests.swift */,
4D01B0CE1C7EFB1000AAD90C /* Info.plist */,
);
Expand All @@ -132,6 +149,7 @@
4D01B0D61C7EFB1000AAD90C /* ExampleUITests */ = {
isa = PBXGroup;
children = (
BC3D81121C91C8E00040AF2A /* InfoPlist.strings */,
4D01B0D71C7EFB1000AAD90C /* ExampleUITests.swift */,
4D01B0D91C7EFB1000AAD90C /* Info.plist */,
);
Expand Down Expand Up @@ -244,23 +262,27 @@
buildActionMask = 2147483647;
files = (
4D8D894B1C8073FE004DD23A /* View.xib in Resources */,
BC3D81051C91C8DE0040AF2A /* Localizable.strings in Resources */,
4D01B0F91C7F15D500AAD90C /* Main.storyboard in Resources */,
4D01B0BF1C7EFB1000AAD90C /* Assets.xcassets in Resources */,
4D01B0F81C7F15D500AAD90C /* LaunchScreen.storyboard in Resources */,
BC3D81001C91C8DE0040AF2A /* InfoPlist.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
4D01B0C61C7EFB1000AAD90C /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BC3D810A1C91C8DF0040AF2A /* InfoPlist.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
4D01B0D11C7EFB1000AAD90C /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BC3D81101C91C8E00040AF2A /* InfoPlist.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -314,6 +336,8 @@
isa = PBXVariantGroup;
children = (
4D01B1041C7F160000AAD90C /* Base */,
BC3D810D1C91C8DF0040AF2A /* de */,
BC3D81161C91C9040040AF2A /* en */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
Expand All @@ -338,6 +362,42 @@
name = View.xib;
sourceTree = "<group>";
};
BC3D81021C91C8DE0040AF2A /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
BC3D81011C91C8DE0040AF2A /* de */,
BC3D81131C91C9030040AF2A /* en */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
BC3D81071C91C8DE0040AF2A /* Localizable.strings */ = {
isa = PBXVariantGroup;
children = (
BC3D81061C91C8DE0040AF2A /* de */,
BC3D81141C91C9030040AF2A /* en */,
);
name = Localizable.strings;
sourceTree = "<group>";
};
BC3D810C1C91C8DF0040AF2A /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
BC3D810B1C91C8DF0040AF2A /* de */,
BC3D81151C91C9040040AF2A /* en */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
BC3D81121C91C8E00040AF2A /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
BC3D81111C91C8E00040AF2A /* de */,
BC3D81171C91C9040040AF2A /* en */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */

/* Begin XCBuildConfiguration section */
Expand Down
2 changes: 1 addition & 1 deletion platform/Example/Example/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Dynamic label 2" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="si2-WH-Hr5">
<rect key="frame" x="193" y="348" width="122" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
Expand Down
1 change: 1 addition & 0 deletions platform/Example/Example/de.lproj/InfoPlist.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* No Localized Strings */
1 change: 1 addition & 0 deletions platform/Example/Example/de.lproj/LaunchScreen.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* No Localized Strings */
1 change: 1 addition & 0 deletions platform/Example/Example/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* No Localized Strings */
21 changes: 11 additions & 10 deletions platform/Example/Example/de.lproj/Main.strings
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
/* label.text: A fancy Label */
"R52-bk-905.text" = "Label (de)";
/* Class = "UINavigationItem"; title = "First ViewController"; ObjectID = "4Bk-Mt-SxL"; */
"4Bk-Mt-SxL.title" = "First ViewController (de)";

/* button.normalTitle: An awesome Button */
/* Class = "UIButton"; normalTitle = "Button"; ObjectID = "JOe-j0-s5G"; */
"JOe-j0-s5G.normalTitle" = "Button (de)";

/* textField.placeholder: A gorgeous TextField */
/* Class = "UILabel"; text = "Label"; ObjectID = "R52-bk-905"; */
"R52-bk-905.text" = "Label (de)";

/* Class = "UITextField"; placeholder = "Placeholder Text"; ObjectID = "gwT-Xy-34b"; */
"gwT-Xy-34b.placeholder" = "Placeholder Text (de)";

/* textField.text: A gorgeous TextField */
/* Class = "UITextField"; text = "Text"; ObjectID = "gwT-Xy-34b"; */
"gwT-Xy-34b.text" = "Text (de)";

/* segmentedControl.segmentTitles[0]: An outstanding SegmentedControl */
/* Class = "UISegmentedControl"; l0d-C1-RK1.segmentTitles[0] = "First"; ObjectID = "l0d-C1-RK1"; */
"l0d-C1-RK1.segmentTitles[0]" = "First (de)";

/* segmentedControl.segmentTitles[1]: An outstanding SegmentedControl */
/* Class = "UISegmentedControl"; l0d-C1-RK1.segmentTitles[1] = "Second"; ObjectID = "l0d-C1-RK1"; */
"l0d-C1-RK1.segmentTitles[1]" = "Second (de)";

/* barButtonItem.title: An unbelievable BarButtonItem */
/* Class = "UIBarButtonItem"; title = "BarButtonItem"; ObjectID = "lFA-pn-E9n"; */
"lFA-pn-E9n.title" = "BarButtonItem (de)";

/* navigationItem.title: An uber NavigationItem */
"4Bk-Mt-SxL.title" = "First ViewController (de)";
2 changes: 1 addition & 1 deletion platform/Example/Example/de.lproj/View.strings
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

/* Class = "UILabel"; text = "Label in XIB"; ObjectID = "Rfi-2u-xEd"; */
"Rfi-2u-xEd.text" = "Label in XIB";

6 changes: 6 additions & 0 deletions platform/Example/Example/en.lproj/InfoPlist.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* (No Commment) */
"CFBundleName" = "$(PRODUCT_NAME)";

/* (No Commment) */
"CFBundleShortVersionString" = "1.0";

1 change: 1 addition & 0 deletions platform/Example/Example/en.lproj/LaunchScreen.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* No Localized Strings */
6 changes: 6 additions & 0 deletions platform/Example/Example/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* First dynamic text, should be short */
"secondViewController.dynamicLabel.text" = "First Dynamic Label Text";

/* Second dynamic text, can be longer */
"secondViewController.dynamicLabel2.text" = "Second Dynamic Label Text";

35 changes: 21 additions & 14 deletions platform/Example/Example/en.lproj/Main.strings
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
/* FirstViewController label text: A fancy Label */
"R52-bk-905.text" = "Label";
/* Class = "UINavigationItem"; title = "First ViewController"; ObjectID = "4Bk-Mt-SxL"; */
"4Bk-Mt-SxL.title" = "First ViewController";

/* FirstViewController button normalTitle: An awesome Button */
/* Class = "UIButton"; normalTitle = "Button"; ObjectID = "JOe-j0-s5G"; */
"JOe-j0-s5G.normalTitle" = "Button";

/* FirstViewController textField placeholder: A gorgeous TextField */
/* Class = "UILabel"; text = "Dynamic label"; ObjectID = "Pgq-eq-Uvk"; */
"Pgq-eq-Uvk.text" = "Dynamic label";

/* Class = "UILabel"; text = "Label"; ObjectID = "R52-bk-905"; */
"R52-bk-905.text" = "Label";

/* Class = "UINavigationItem"; title = "Second ViewController"; ObjectID = "SAx-7C-11b"; */
"SAx-7C-11b.title" = "Second ViewController";

/* Class = "UITextField"; placeholder = "Placeholder Text"; ObjectID = "gwT-Xy-34b"; */
"gwT-Xy-34b.placeholder" = "Placeholder Text";

/* FirstViewController textField text: A gorgeous TextField */
/* Class = "UITextField"; text = "Text"; ObjectID = "gwT-Xy-34b"; */
"gwT-Xy-34b.text" = "Text";

/* FirstViewController segmentedControl segmentTitles[0]: An outstanding SegmentedControl */
/* Class = "UISegmentedControl"; l0d-C1-RK1.segmentTitles[0] = "First"; ObjectID = "l0d-C1-RK1"; */
"l0d-C1-RK1.segmentTitles[0]" = "First";

/* FirstViewController navigationItem title: An uber NavigationItem */
"4Bk-Mt-SxL.title" = "First ViewController";
/* Class = "UISegmentedControl"; l0d-C1-RK1.segmentTitles[1] = "Second"; ObjectID = "l0d-C1-RK1"; */
"l0d-C1-RK1.segmentTitles[1]" = "Second";

/* FirstViewController barButtonItem title: An unbelievable BarButtonItem */
/* Class = "UIBarButtonItem"; title = "BarButtonItem"; ObjectID = "lFA-pn-E9n"; */
"lFA-pn-E9n.title" = "BarButtonItem";

/* FirstViewController segmentedControl segmentTitles[1]: An outstanding SegmentedControl */
"l0d-C1-RK1.segmentTitles[1]" = "Second";
/* Class = "UILabel"; text = "Dynamic label 2"; ObjectID = "si2-WH-Hr5"; */
"si2-WH-Hr5.text" = "Dynamic label 2";

/* SecondViewController label text: A fancy label in a second view controller */
/* Class = "UILabel"; text = "Second view controller label"; ObjectID = "uHO-0u-WyN"; */
"uHO-0u-WyN.text" = "Second view controller label";

/* SecondViewController navigationItem title: Second navigation item */
"SAx-7C-11b.title" = "Second ViewController";
5 changes: 3 additions & 2 deletions platform/Example/Example/en.lproj/View.strings
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/* label text: A fancy view in a xib file */
"Rfi-2u-xEd.text" = "Label in XIB";
/* Class = "UILabel"; text = "Label in XIB"; ObjectID = "Rfi-2u-xEd"; */
"Rfi-2u-xEd.text" = "Label in XIB";

1 change: 1 addition & 0 deletions platform/Example/ExampleTests/de.lproj/InfoPlist.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* No Localized Strings */
6 changes: 6 additions & 0 deletions platform/Example/ExampleTests/en.lproj/InfoPlist.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* (No Commment) */
"CFBundleName" = "$(PRODUCT_NAME)";

/* (No Commment) */
"CFBundleShortVersionString" = "1.0";

1 change: 1 addition & 0 deletions platform/Example/ExampleUITests/de.lproj/InfoPlist.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* No Localized Strings */
6 changes: 6 additions & 0 deletions platform/Example/ExampleUITests/en.lproj/InfoPlist.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* (No Commment) */
"CFBundleName" = "$(PRODUCT_NAME)";

/* (No Commment) */
"CFBundleShortVersionString" = "1.0";

Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@
<target>BarButtonItem (de)</target>
<note>[FirstViewController barButtonItem] An unbelievable BarButtonItem</note>
</trans-unit>
<trans-unit id="si2-WH-Hr5.text">
<source>Dynamic label 2</source>
<note>Class = "UILabel"; text = "Dynamic label 2"; ObjectID = "si2-WH-Hr5";</note>
</trans-unit>

<trans-unit id="uHO-0u-WyN.text">
<source>Second view controller label</source>
<note>[SecondViewController label] A fancy label in a second view controller</note>
Expand Down Expand Up @@ -91,7 +88,7 @@
</trans-unit>
</body>
</file>
<file original="Example/Localizable.strings" source-language="en" datatype="plaintext" target-language="de">
<file original="Example/en.lproj/Localizable.strings" source-language="en" datatype="plaintext" target-language="de">
<header>
<tool tool-id="com.apple.dt.xcode" tool-name="Xcode" tool-version="7.2.1" build-num="7C1002"/>
</header>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@
<target>BarButtonItem</target>
<note>[FirstViewController barButtonItem] An unbelievable BarButtonItem</note>
</trans-unit>
<trans-unit id="si2-WH-Hr5.text">
<source>Dynamic label 2</source>
<target>Dynamic label 2</target>
<note>Class = "UILabel"; text = "Dynamic label 2"; ObjectID = "si2-WH-Hr5";</note>
</trans-unit>

<trans-unit id="uHO-0u-WyN.text">
<source>Second view controller label</source>
<target>Second view controller label</target>
Expand Down Expand Up @@ -96,7 +92,7 @@
</trans-unit>
</body>
</file>
<file original="Example/Localizable.strings" source-language="en" datatype="plaintext" target-language="en">
<file original="Example/en.lproj/Localizable.strings" source-language="en" datatype="plaintext" target-language="en">
<header>
<tool tool-id="com.apple.dt.xcode" tool-name="Xcode" tool-version="7.2.1" build-num="7C1002"/>
</header>
Expand Down