Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

Add custom detector like XXLocalizedString(key); Select Localizable.strings as default; #37

Open
wants to merge 2 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
12 changes: 11 additions & 1 deletion Lin/LNAlertAccessoryView.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,17 @@ - (void)updateTables
[tableFileNames addObject:collection.fileName];
}

[self.tableButton addItemsWithTitles:[tableFileNames allObjects]];
NSMutableArray * names = [[tableFileNames allObjects] mutableCopy];
[names enumerateObjectsUsingBlock:^(NSString *name, NSUInteger idx, BOOL *stop) {

if ([name isEqualToString:@"Localizable.strings"])
{
[names exchangeObjectAtIndex:0 withObjectAtIndex:idx];
*stop = YES;
}
}];

[self.tableButton addItemsWithTitles:names];
}

- (void)updateLanguages
Expand Down
3 changes: 2 additions & 1 deletion Lin/LNDetector.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ - (instancetype)init
[LNRegularExpressionPattern patternWithType:LNEntityTypeLocalizedStringForKey],
[LNRegularExpressionPattern patternWithType:LNEntityTypeLocalizedStringFromTable],
[LNRegularExpressionPattern patternWithType:LNEntityTypeLocalizedStringFromTableInBundle],
[LNRegularExpressionPattern patternWithType:LNEntityTypeLocalizedStringWithDefaultValue]
[LNRegularExpressionPattern patternWithType:LNEntityTypeLocalizedStringWithDefaultValue],
[LNRegularExpressionPattern patternWithType:LNEntityTypeCustomLocalizedStringOnlyForKey]
];
}

Expand Down
11 changes: 10 additions & 1 deletion Lin/LNEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ typedef NS_ENUM(NSUInteger, LNEntityType) {
LNEntityTypeLocalizedStringForKey,
LNEntityTypeLocalizedStringFromTable,
LNEntityTypeLocalizedStringFromTableInBundle,
LNEntityTypeLocalizedStringWithDefaultValue
LNEntityTypeLocalizedStringWithDefaultValue,

/**
* Custom type just like XXLocalizedString(key)
* Add by Lings@Github
*/
LNEntityTypeCustomLocalizedStringOnlyForKey = 100
};

NS_INLINE NSString * NSStringFromEntityType(LNEntityType type) {
Expand All @@ -35,6 +41,9 @@ NS_INLINE NSString * NSStringFromEntityType(LNEntityType type) {
case LNEntityTypeLocalizedStringWithDefaultValue:
string = @"LNEntityTypeLocalizedStringWithDefaultValue";
break;
case LNEntityTypeCustomLocalizedStringOnlyForKey:
string = @"LNEntityTypeCustomLocalizedStringOnlyForKey";
break;
}

return string;
Expand Down
6 changes: 6 additions & 0 deletions Lin/LNRegularExpressionPattern+type.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ + (instancetype)patternWithType:(LNEntityType)type
numberOfRanges = 6;
}
break;
case LNEntityTypeCustomLocalizedStringOnlyForKey:
{
pettern = @"LocalizedString\\s*\\(\\s*@\"(.*?)\"\\s*\\)";
numberOfRanges = 2;
}
break;
}

if (pettern) {
Expand Down
1 change: 1 addition & 0 deletions Lin/Lin-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<string>37B30044-3B14-46BA-ABAA-F01000C27B63</string>
<string>640F884E-CE55-4B40-87C0-8869546CAB7A</string>
<string>A2E4D43F-41F4-4FB9-BB94-7177011C9AED</string>
<string>C4A681B0-4A26-480E-93EC-1218098B9AA0</string>
</array>
<key>LSApplicationCategoryType</key>
<string></string>
Expand Down