Skip to content
This repository was archived by the owner on Apr 6, 2020. It is now read-only.
Open
1 change: 1 addition & 0 deletions Lin/LNAlertAccessoryView.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
@property (nonatomic, copy, readonly) LNLocalizationCollection *selectedCollection;
@property (nonatomic, copy, readonly) NSString *inputtedKey;
@property (nonatomic, copy, readonly) NSString *inputtedValue;
@property (nonatomic, copy, readonly) NSString *inputtedComment;

@end
6 changes: 6 additions & 0 deletions Lin/LNAlertAccessoryView.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ @interface LNAlertAccessoryView ()
@property (weak) IBOutlet NSPopUpButton *languageButton;
@property (weak) IBOutlet NSTextField *keyTextField;
@property (weak) IBOutlet NSTextField *valueTextField;
@property (weak) IBOutlet NSTextField *commentTextField;

@end

Expand Down Expand Up @@ -71,6 +72,10 @@ - (NSString *)inputtedValue
return self.valueTextField.stringValue;
}

- (NSString *)inputtedComment
{
return self.commentTextField.stringValue;
}

#pragma mark - Actions

Expand Down Expand Up @@ -123,6 +128,7 @@ - (void)configureButton
{
NSString *key = self.keyTextField.stringValue;
NSString *value = self.valueTextField.stringValue;
// comment is optional

[self.button setEnabled:(self.collections.count > 0 && key.length > 0 && value.length > 0)];
}
Expand Down
48 changes: 35 additions & 13 deletions Lin/LNAlertAccessoryView.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="4510" systemVersion="12F37" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="5056" systemVersion="13C1021" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment defaultVersion="1080" identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="4510"/>
<deployment defaultVersion="1070" identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="5056"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSViewController">
Expand All @@ -13,11 +13,11 @@
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application"/>
<customView id="1" customClass="LNAlertAccessoryView">
<rect key="frame" x="0.0" y="0.0" width="276" height="126"/>
<rect key="frame" x="0.0" y="0.0" width="276" height="162"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="g8L-IS-4Xk">
<rect key="frame" x="-3" y="105" width="74" height="18"/>
<rect key="frame" x="-3" y="141" width="74" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Table:" id="jNJ-it-poE">
<font key="font" size="11" name="LucidaGrande"/>
Expand All @@ -26,7 +26,7 @@
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="c83-4U-gPj">
<rect key="frame" x="-3" y="74" width="74" height="18"/>
<rect key="frame" x="-3" y="110" width="74" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Language:" id="kRy-xH-jEz">
<font key="font" size="11" name="LucidaGrande"/>
Expand All @@ -35,7 +35,7 @@
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="eXz-ob-H9h">
<rect key="frame" x="-3" y="38" width="74" height="18"/>
<rect key="frame" x="-3" y="74" width="74" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Key:" id="aF0-zx-EL7">
<font key="font" size="11" name="LucidaGrande"/>
Expand All @@ -44,16 +44,25 @@
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="RCM-7S-qgd">
<rect key="frame" x="-3" y="2" width="74" height="18"/>
<rect key="frame" x="-3" y="38" width="74" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Value:" id="oqq-yX-bGL">
<font key="font" size="11" name="LucidaGrande"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="t32-WG-uMt">
<rect key="frame" x="-3" y="2" width="74" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Comment:" id="p3o-kt-HlQ">
<font key="font" size="11" name="LucidaGrande"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Ffd-kG-7Ps">
<rect key="frame" x="84" y="101" width="175" height="26"/>
<rect key="frame" x="84" y="137" width="175" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="Bnc-Jb-pk1" id="f33-uO-Fvh">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
Expand All @@ -71,7 +80,7 @@
</connections>
</popUpButton>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="8bv-Xr-gdv">
<rect key="frame" x="84" y="70" width="175" height="26"/>
<rect key="frame" x="84" y="106" width="175" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="in5-1O-5XW" id="Dtc-dm-ra0">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
Expand All @@ -86,7 +95,7 @@
</popUpButtonCell>
</popUpButton>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Qol-ST-d7x">
<rect key="frame" x="86" y="36" width="170" height="22"/>
<rect key="frame" x="86" y="72" width="170" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="eux-4V-Yap">
<font key="font" metaFont="system"/>
Expand All @@ -98,7 +107,7 @@
</connections>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2iU-j0-HKh">
<rect key="frame" x="86" y="0.0" width="170" height="22"/>
<rect key="frame" x="86" y="36" width="170" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="6k4-Zy-TKZ">
<font key="font" metaFont="system"/>
Expand All @@ -109,13 +118,26 @@
<outlet property="delegate" destination="1" id="bbF-ov-OoT"/>
</connections>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="CbY-TS-xeA">
<rect key="frame" x="86" y="0.0" width="170" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="eDx-ZF-z6B">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<outlet property="delegate" destination="1" id="cj3-z7-Mxb"/>
</connections>
</textField>
</subviews>
<connections>
<outlet property="commentTextField" destination="CbY-TS-xeA" id="QmF-g8-Cqg"/>
<outlet property="keyTextField" destination="Qol-ST-d7x" id="TpR-9R-1mv"/>
<outlet property="languageButton" destination="8bv-Xr-gdv" id="fP1-93-XWJ"/>
<outlet property="tableButton" destination="Ffd-kG-7Ps" id="742-rf-D76"/>
<outlet property="valueTextField" destination="2iU-j0-HKh" id="Bap-fJ-DcY"/>
</connections>
</customView>
</objects>
</document>
</document>
5 changes: 3 additions & 2 deletions Lin/LNLocalization.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@

@property (nonatomic, copy, readonly) NSString *key;
@property (nonatomic, copy, readonly) NSString *value;
@property (nonatomic, copy, readonly) NSString *comment;

@property (nonatomic, assign, readonly) NSRange entityRange;
@property (nonatomic, assign, readonly) NSRange keyRange;
@property (nonatomic, assign, readonly) NSRange valueRange;

@property (nonatomic, weak, readonly) LNLocalizationCollection *collection;

+ (instancetype)localizationWithKey:(NSString *)key value:(NSString *)value entityRange:(NSRange)entityRange keyRange:(NSRange)keyRange valueRange:(NSRange)valueRange collection:(LNLocalizationCollection *)collection;
+ (instancetype)localizationWithKey:(NSString *)key value:(NSString *)value comment:(NSString *)comment entityRange:(NSRange)entityRange keyRange:(NSRange)keyRange valueRange:(NSRange)valueRange collection:(LNLocalizationCollection *)collection;

- (instancetype)initWithKey:(NSString *)key value:(NSString *)value entityRange:(NSRange)entityRange keyRange:(NSRange)keyRange valueRange:(NSRange)valueRange collection:(LNLocalizationCollection *)collection;
- (instancetype)initWithKey:(NSString *)key value:(NSString *)value comment:(NSString *)comment entityRange:(NSRange)entityRange keyRange:(NSRange)keyRange valueRange:(NSRange)valueRange collection:(LNLocalizationCollection *)collection;

@end
11 changes: 7 additions & 4 deletions Lin/LNLocalization.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ @interface LNLocalization ()

@property (nonatomic, copy, readwrite) NSString *key;
@property (nonatomic, copy, readwrite) NSString *value;
@property (nonatomic, copy, readwrite) NSString *comment;

@property (nonatomic, assign, readwrite) NSRange entityRange;
@property (nonatomic, assign, readwrite) NSRange keyRange;
Expand All @@ -23,18 +24,19 @@ @interface LNLocalization ()

@implementation LNLocalization

+ (instancetype)localizationWithKey:(NSString *)key value:(NSString *)value entityRange:(NSRange)entityRange keyRange:(NSRange)keyRange valueRange:(NSRange)valueRange collection:(LNLocalizationCollection *)collection
+ (instancetype)localizationWithKey:(NSString *)key value:(NSString *)value comment:(NSString *)comment entityRange:(NSRange)entityRange keyRange:(NSRange)keyRange valueRange:(NSRange)valueRange collection:(LNLocalizationCollection *)collection
{
return [[self alloc] initWithKey:key value:value entityRange:(NSRange)entityRange keyRange:keyRange valueRange:valueRange collection:collection];
return [[self alloc] initWithKey:key value:value comment:comment entityRange:(NSRange)entityRange keyRange:keyRange valueRange:valueRange collection:collection];
}

- (instancetype)initWithKey:(NSString *)key value:(NSString *)value entityRange:(NSRange)entityRange keyRange:(NSRange)keyRange valueRange:(NSRange)valueRange collection:(LNLocalizationCollection *)collection
- (instancetype)initWithKey:(NSString *)key value:(NSString *)value comment:(NSString *)comment entityRange:(NSRange)entityRange keyRange:(NSRange)keyRange valueRange:(NSRange)valueRange collection:(LNLocalizationCollection *)collection
{
self = [super init];

if (self) {
self.key = key;
self.value = value;
self.comment = comment;

self.entityRange = entityRange;
self.keyRange = keyRange;
Expand Down Expand Up @@ -66,11 +68,12 @@ - (NSUInteger)hash
- (NSString *)description
{
return [NSString stringWithFormat:
@"<%@: %p; key = %@; value = %@; entityRange = %@; keyRange = %@; valueRange = %@; collection = %p>",
@"<%@: %p; key = %@; value = %@; comment = %@; entityRange = %@; keyRange = %@; valueRange = %@; collection = %p>",
NSStringFromClass([self class]),
self,
self.key,
self.value,
self.comment,
NSStringFromRange(self.entityRange),
NSStringFromRange(self.keyRange),
NSStringFromRange(self.valueRange),
Expand Down
Loading