Skip to content

Commit

Permalink
Updated main to be able to pass a folder parameter, updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
Almer Lucke committed Sep 11, 2015
1 parent c384cc4 commit fb4e3e6
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
10 changes: 5 additions & 5 deletions FCGenstrings.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
CBED22231BA2D9FF0089A0DF /* FCGenstrings */ = {
CBED22231BA2D9FF0089A0DF /* fcgenstrings */ = {
isa = PBXNativeTarget;
buildConfigurationList = CBED222B1BA2D9FF0089A0DF /* Build configuration list for PBXNativeTarget "FCGenstrings" */;
buildConfigurationList = CBED222B1BA2D9FF0089A0DF /* Build configuration list for PBXNativeTarget "fcgenstrings" */;
buildPhases = (
CBED22201BA2D9FF0089A0DF /* Sources */,
CBED22211BA2D9FF0089A0DF /* Frameworks */,
Expand All @@ -91,7 +91,7 @@
);
dependencies = (
);
name = FCGenstrings;
name = fcgenstrings;
productName = FCGenstrings;
productReference = CBED22241BA2D9FF0089A0DF /* FCGenstrings */;
productType = "com.apple.product-type.tool";
Expand Down Expand Up @@ -122,7 +122,7 @@
projectDirPath = "";
projectRoot = "";
targets = (
CBED22231BA2D9FF0089A0DF /* FCGenstrings */,
CBED22231BA2D9FF0089A0DF /* fcgenstrings */,
);
};
/* End PBXProject section */
Expand Down Expand Up @@ -243,7 +243,7 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
CBED222B1BA2D9FF0089A0DF /* Build configuration list for PBXNativeTarget "FCGenstrings" */ = {
CBED222B1BA2D9FF0089A0DF /* Build configuration list for PBXNativeTarget "fcgenstrings" */ = {
isa = XCConfigurationList;
buildConfigurations = (
CBED222C1BA2D9FF0089A0DF /* Debug */,
Expand Down
26 changes: 25 additions & 1 deletion FCGenstrings/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,31 @@

int main(int argc, const char * argv[]) {
@autoreleasepool {
[FCGenstrings genstringsForDirectory:@"/Users/almerlucke/Documents/Projects/iOS/CentreOfAppliedGaming_Parkinson/CentreOfAppliedGaming_Parkinson"];
NSArray *arguments = [[NSProcessInfo processInfo] arguments];

if (arguments.count != 2) {
printf("Usage: FCGenstrings folder\n");
return 0;
}

NSString *folder = arguments[1];

if (![folder isKindOfClass:[NSString class]]) {
printf("Usage: FCGenstrings folder\n");
return 0;
}

if (folder.length > 0 && ![[folder substringToIndex:1] isEqualToString:@"/"]) {
NSString *currentDirectory = [[NSFileManager defaultManager] currentDirectoryPath];

folder = [currentDirectory stringByAppendingPathComponent:folder];
}

printf("Generating strings for folder %s\n", [folder cStringUsingEncoding:NSUTF8StringEncoding]);

[FCGenstrings genstringsForDirectory:folder];

printf("Finished generating strings\n");
}
return 0;
}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,8 @@ Example generated strings:

## Usage

If you have build the command line tool **fcgenstrings** from the Xcode project you can use it by executing it and passing it a folder name

fcgenstrings foldername

This will scan all .m, .xib and .storyboard files and parse the localized strings. Then fcgenstrings will go through all existing Localizable.strings and update these.
4 changes: 4 additions & 0 deletions Source/FCGenstrings.m
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ + (void)genstringsForDirectory:(NSString *)directory
// them with existing Localizable.strings files, we keep the values already in Localizable.strings files
// for the collected keys found and then overwrite Localizable.strings files

printf("Scanning directories for localized strings...\n");

// get collected strings from root directory .m, .xib and .storyboard
NSDictionary *collectedStrings = [self localizedStringsForDirectory:directory];

Expand All @@ -405,6 +407,8 @@ + (void)genstringsForDirectory:(NSString *)directory
NSArray *collectedKeys = [collectedStrings allKeys];

for (NSString *localizableStringsFile in localizableStringsFiles) {
printf("Updating Localized.strings file %s\n", [localizableStringsFile cStringUsingEncoding:NSUTF8StringEncoding]);

// get current strings in Localizable file
NSDictionary *currentStrings = [self localizedStringsForLocalizableStringsFile:localizableStringsFile];
NSMutableArray *entries = [NSMutableArray array];
Expand Down

0 comments on commit fb4e3e6

Please sign in to comment.