Skip to content

Commit e6f7dd8

Browse files
committed
Merge branch 'release-1.0.0'
2 parents 36186af + a92ab33 commit e6f7dd8

14 files changed

+400
-13
lines changed

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
language: objective-c
3+
4+
before_script:
5+
- sudo easy_install cpp-coveralls
6+
7+
script:
8+
- xctool -project genstrings2.xcodeproj -scheme "Static Library" test -arch x86_64 ONLY_ACTIVE_ARCH=NO
9+
### disabled until Travis-CI fixes missing appledoc install on 10.9 machines
10+
# - appledoc -o /tmp .
11+
12+
after_success:
13+
- ./coveralls.rb --extension m --exclude-folder Demo --exclude-folder Test --exclude-folder Externals

Core/Source/DTLocalizableStringAggregator.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ - (id)init
5858

5959
- (void)dealloc
6060
{
61+
#if !OS_OBJECT_USE_OBJC
6162
dispatch_release(_tableQueue);
6263
dispatch_release(_tableGroup);
64+
#endif
6365
}
6466

6567
- (void)setCustomMacroPrefix:(NSString *)customMacroPrefix

Core/Source/DTLocalizableStringEntry.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ - (void)addComment:(NSString *)comment
101101
comment = [self _stringByRecognizingNil:comment];
102102

103103
// remove the quotes
104-
comment = [comment stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"\""]];
104+
comment = [comment stringByRemovingSurroundingQuotes];
105105

106106
if (![comment length])
107107
{

Core/Source/NSString+DTLocalizableStringScanner.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,11 @@
4646
@returns The receiver's content with control characters slash-escaped
4747
*/
4848
- (NSString *)stringByAddingSlashEscapes;
49+
50+
/**
51+
Change "foo" to foo. This will remove just one set of quotes, so that e.g. ""foo"" becomes "foo"
52+
If the string does not begin and end with a quote, returns it unmodified.
53+
@returns The string with one set of surrounding quotes removed.
54+
*/
55+
- (NSString *)stringByRemovingSurroundingQuotes;
4956
@end

Core/Source/NSString+DTLocalizableStringScanner.m

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ - (NSString *)stringByNumberingFormatPlaceholders
1515
static dispatch_once_t onceToken;
1616
static NSRegularExpression *matchNonEscapedPercent = nil;
1717
dispatch_once(&onceToken, ^{
18-
matchNonEscapedPercent = [NSRegularExpression regularExpressionWithPattern:@"(?<=[^%]|^)(?:(?:%%)*)(%)(?:[^%]|$)" options:0 error:NULL];
18+
matchNonEscapedPercent = [NSRegularExpression regularExpressionWithPattern:@"(?<=[^%]|^)(?:(?:%%)*)(%(?!\\d+\\$))(?:[^%]|$)" options:0 error:NULL];
1919
});
2020

2121
__block NSMutableString *tmpString = nil;
@@ -618,4 +618,16 @@ - (NSString *)stringByAddingSlashEscapes
618618
return clean;
619619
}
620620

621+
- (NSString *)stringByRemovingSurroundingQuotes
622+
{
623+
NSUInteger length = [self length];
624+
NSString *clean = self;
625+
626+
if (length >= 2 && [self characterAtIndex:0] == '\"' && [self characterAtIndex:length-1] == '\"') {
627+
clean = [self substringWithRange:NSMakeRange(1, length-2)];
628+
}
629+
630+
return clean;
631+
}
632+
621633
@end

DTLocalizableStringScanner.podspec

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Pod::Spec.new do |spec|
2+
spec.name = 'DTLocalizableStringScanner'
3+
spec.version = '1.0.0'
4+
spec.platform = :osx, '10.7'
5+
spec.license = 'BSD'
6+
spec.source = { :git => 'https://github.com/Cocoanetics/DTLocalizableStringScanner.git', :tag => spec.version.to_s }
7+
spec.source_files = 'Core/Source/*.{h,m,c}'
8+
spec.requires_arc = true
9+
spec.homepage = 'https://github.com/Cocoanetics/DTLocalizableStringScanner'
10+
spec.summary = 'A better performing multi-threaded replacement for genstrings as component you can use in your own apps scanning for localizable strings.'
11+
spec.author = { 'Oliver Drobnik' => '[email protected]' }
12+
spec.documentation_url = 'docs.cocoanetics.com/DTLocalizableStringScanner'
13+
spec.social_media_url = 'https://twitter.com/cocoanetics'
14+
end
15+

Readme.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
DTLocalizableStringScanner
22
==========================
33

4+
[![Build Status](https://travis-ci.org/Cocoanetics/DTLocalizableStringScanner.png?branch=develop)](https://travis-ci.org/Cocoanetics/DTLocalizableStringScanner) [![Coverage Status](https://coveralls.io/repos/Cocoanetics/DTLocalizableStringScanner/badge.png?branch=develop)](https://coveralls.io/r/Cocoanetics/DTLocalizableStringScanner?branch=develop)
5+
46
This project aims to duplicate and enhance the functionality found in the `genstrings` utility provided by Apple. The Demo builds a command line utility `genstrings2` which works like the original but using more modern techniques. The Core contains classes and categories to add this scanning functionality to [Linguan](http://www.cocoanetics.com/apps/linguan/).
57

68
Documentation

Test/Resources/Multiple_Parts.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* Issue 7: A string can span multiple lines */
2+
3+
NSString *multiLine = NSLocalizedString(@"Here is one line!"
4+
"And another"
5+
"And yet another", @"Multiple Lines");
6+
7+
8+
/* Issue 10: A string can have multiple parts */
9+
10+
NSLocalizedString(@"foo " @"bar", @"Test multi-part quoted strings");
11+
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/* Tests if the escaping of double quotes and slashes works */
22

3-
NSLocalizedString(@"here are three \\\\\\\"\"\"\nslashes&quotes: \\\\\\\"\"\"", nil)
3+
NSLocalizedString(@"here are three \\\\\\\"\"\"\nslashes&quotes: \\\\\\\"\"\"", nil)
4+
5+
NSLocalizedString(@"bar", @"Test comment ending with \"quotes\"");

Test/Resources/Testcases.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ NSString *message = [NSString stringWithFormat:NSLocalizedString(@"\"%@\" has be
77

88
NSLocalizedString(@"%@ had been successfully added to the Address Book.\nWould you like to edit the card now?", nil);
99

10+
NSLocalizedString(@"Item %1$d of %2$d", @"Test positional params");
11+
1012
// some regular test cases
1113

1214

0 commit comments

Comments
 (0)