diff options
author | Max <post@wickenrode.com> | 2015-10-12 01:09:23 +0200 |
---|---|---|
committer | Max <post@wickenrode.com> | 2015-10-12 01:14:33 +0200 |
commit | 319eee397f894160aa5d6132d7d07881a75a762e (patch) | |
tree | 7839b94dcc1c873e8d1d27c8006d7871f13df305 /Source/SPExportController.m | |
parent | 44af78202545ec911de052c5eec361f2296afc28 (diff) | |
download | sequelpro-319eee397f894160aa5d6132d7d07881a75a762e.tar.gz sequelpro-319eee397f894160aa5d6132d7d07881a75a762e.tar.bz2 sequelpro-319eee397f894160aa5d6132d7d07881a75a762e.zip |
Change how the custom filename pattern in export dialog is handled
Namely:
* They were previously stored in the users locale. Now they are stored using a language independent id
* Just typing a token in your language will no longer work. If you want to manually type a token use: {host}, {database}, and so on… (all in English)
* Copy & Paste of tokens will use the new form, too (so a user running SP in English can simply share a custom pattern with a user running SP in German)
* The localized token names can now contain spaces
Diffstat (limited to 'Source/SPExportController.m')
-rw-r--r-- | Source/SPExportController.m | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/Source/SPExportController.m b/Source/SPExportController.m index b249505a..bbbec9bd 100644 --- a/Source/SPExportController.m +++ b/Source/SPExportController.m @@ -124,6 +124,18 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled"; windowMinHeigth = [[self window] minSize].height; prefs = [NSUserDefaults standardUserDefaults]; + + localizedTokenNames = [@{ + SPFileNameHostTokenName: NSLocalizedString(@"Host", @"export filename host token"), + SPFileNameDatabaseTokenName: NSLocalizedString(@"Database", @"export filename database token"), + SPFileNameTableTokenName: NSLocalizedString(@"Table", @"table"), + SPFileNameDateTokenName: NSLocalizedString(@"Date", @"export filename date token"), + SPFileNameYearTokenName: NSLocalizedString(@"Year", @"export filename date token"), + SPFileNameMonthTokenName: NSLocalizedString(@"Month", @"export filename date token"), + SPFileNameDayTokenName: NSLocalizedString(@"Day", @"export filename date token"), + SPFileNameTimeTokenName: NSLocalizedString(@"Time", @"export filename time token"), + SPFileNameFavoriteTokenName: NSLocalizedString(@"Favorite", @"export filename favorite name token") + } retain]; } return self; @@ -680,7 +692,7 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled"; // Check whether to save the export filename. Save it if it's not blank and contains at least one // token - this suggests it's not a one-off filename if ([[exportCustomFilenameTokenField stringValue] length] < 1) { - [prefs removeObjectForKey:SPExportFilenameFormat]; + [prefs removeObjectForKey:SPExportFilenameFormatIntl]; } else { BOOL saveFilename = NO; @@ -692,7 +704,7 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled"; if ([aToken isKindOfClass:[SPExportFileNameTokenObject class]]) saveFilename = YES; } - if (saveFilename) [prefs setObject:[NSKeyedArchiver archivedDataWithRootObject:representedObjects] forKey:SPExportFilenameFormat]; + if (saveFilename) [prefs setObject:[NSKeyedArchiver archivedDataWithRootObject:representedObjects] forKey:SPExportFilenameFormatIntl]; } // If we are about to perform a table export, cache the current number of tables within the list, @@ -950,14 +962,15 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled"; */ - (void)_setPreviousExportFilenameAndPath { + id o; // Restore the export filename if it exists, and update the display - if ([prefs objectForKey:SPExportFilenameFormat]) { - [exportCustomFilenameTokenField setObjectValue:[NSKeyedUnarchiver unarchiveObjectWithData:[prefs objectForKey:SPExportFilenameFormat]]]; + if ((o = [prefs objectForKey:SPExportFilenameFormatIntl])) { + [exportCustomFilenameTokenField setObjectValue:[NSKeyedUnarchiver unarchiveObjectWithData:o]]; } // If a directory has previously been selected, reselect it - if ([prefs objectForKey:SPExportLastDirectory]) { - [exportPathField setStringValue:[prefs objectForKey:SPExportLastDirectory]]; + if ((o = [prefs objectForKey:SPExportLastDirectory])) { + [exportPathField setStringValue:o]; } else { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDesktopDirectory, NSAllDomainsMask, YES); @@ -1071,8 +1084,8 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled"; SPClear(exportFiles); SPClear(operationQueue); SPClear(exportFilename); - - if (previousConnectionEncoding) SPClear(previousConnectionEncoding); + SPClear(localizedTokenNames); + SPClear(previousConnectionEncoding); [super dealloc]; } |