mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-09 21:24:36 +00:00
Auto-generate Cocoa strings file from code (at last!).
Also, removed TR() macro usage (didn't work with the genstrings command) and tweaked a couple of localized strings.
This commit is contained in:
parent
5a5a74d0e1
commit
653668dd96
86
build.py
86
build.py
@ -22,6 +22,8 @@ from hscommon.build import (add_to_pythonpath, print_and_do, copy_packages, file
|
||||
get_module_version, move_all, copy_sysconfig_files_for_embed, copy_all, move, copy,
|
||||
create_osx_app_structure)
|
||||
from hscommon import loc
|
||||
from hscommon.plat import ISOSX
|
||||
from hscommon.util import ensure_folder
|
||||
|
||||
def parse_args():
|
||||
usage = "usage: %prog [options]"
|
||||
@ -32,8 +34,10 @@ def parse_args():
|
||||
help="Build only the help file")
|
||||
parser.add_option('--loc', action='store_true', dest='loc',
|
||||
help="Build only localization")
|
||||
parser.add_option('--cocoa-ext', action='store_true', dest='cocoa_ext',
|
||||
help="Build only Cocoa extensions")
|
||||
parser.add_option('--cocoa-compile', action='store_true', dest='cocoa_compile',
|
||||
help="Build only Cocoa modules and executables")
|
||||
help="Build only Cocoa executable")
|
||||
parser.add_option('--xibless', action='store_true', dest='xibless',
|
||||
help="Build only xibless UIs")
|
||||
parser.add_option('--updatepot', action='store_true', dest='updatepot',
|
||||
@ -53,33 +57,44 @@ def cocoa_app_path(edition):
|
||||
'pe': 'build/dupeGuru PE.app',
|
||||
}[edition]
|
||||
|
||||
def build_xibless(edition):
|
||||
def build_cocoalib_xibless(dest='cocoa/autogen'):
|
||||
import xibless
|
||||
if not op.exists('cocoa/autogen'):
|
||||
os.mkdir('cocoa/autogen')
|
||||
xibless.generate('cocoalib/ui/progress.py', 'cocoa/autogen/ProgressController_UI')
|
||||
xibless.generate('cocoalib/ui/about.py', 'cocoa/autogen/HSAboutBox_UI', localizationTable='cocoalib')
|
||||
xibless.generate('cocoalib/ui/fairware_reminder.py', 'cocoa/autogen/HSFairwareReminder_UI', localizationTable='cocoalib')
|
||||
xibless.generate('cocoalib/ui/demo_reminder.py', 'cocoa/autogen/HSDemoReminder_UI', localizationTable='cocoalib')
|
||||
xibless.generate('cocoalib/ui/enter_code.py', 'cocoa/autogen/HSEnterCode_UI', localizationTable='cocoalib')
|
||||
xibless.generate('cocoalib/ui/error_report.py', 'cocoa/autogen/HSErrorReportWindow_UI', localizationTable='cocoalib')
|
||||
xibless.generate('cocoa/base/ui/ignore_list_dialog.py', 'cocoa/autogen/IgnoreListDialog_UI', localizationTable='Localizable')
|
||||
xibless.generate('cocoa/base/ui/deletion_options.py', 'cocoa/autogen/DeletionOptions_UI', localizationTable='Localizable')
|
||||
xibless.generate('cocoa/base/ui/problem_dialog.py', 'cocoa/autogen/ProblemDialog_UI', localizationTable='Localizable')
|
||||
xibless.generate('cocoa/base/ui/directory_panel.py', 'cocoa/autogen/DirectoryPanel_UI', localizationTable='Localizable')
|
||||
xibless.generate('cocoa/base/ui/prioritize_dialog.py', 'cocoa/autogen/PrioritizeDialog_UI', localizationTable='Localizable')
|
||||
xibless.generate('cocoa/base/ui/result_window.py', 'cocoa/autogen/ResultWindow_UI', localizationTable='Localizable')
|
||||
xibless.generate('cocoa/base/ui/main_menu.py', 'cocoa/autogen/MainMenu_UI',
|
||||
localizationTable='Localizable', args={'edition': edition})
|
||||
xibless.generate('cocoa/base/ui/preferences_panel.py', 'cocoa/autogen/PreferencesPanel_UI',
|
||||
localizationTable='Localizable', args={'edition': edition})
|
||||
ensure_folder(dest)
|
||||
FNPAIRS = [
|
||||
('progress.py', 'ProgressController_UI'),
|
||||
('about.py', 'HSAboutBox_UI'),
|
||||
('fairware_reminder.py', 'HSFairwareReminder_UI'),
|
||||
('demo_reminder.py', 'HSDemoReminder_UI'),
|
||||
('enter_code.py', 'HSEnterCode_UI'),
|
||||
('error_report.py', 'HSErrorReportWindow_UI'),
|
||||
]
|
||||
for srcname, dstname in FNPAIRS:
|
||||
xibless.generate(op.join('cocoalib', 'ui', srcname), op.join(dest, dstname), localizationTable='cocoalib')
|
||||
|
||||
def build_xibless(edition, dest='cocoa/autogen'):
|
||||
import xibless
|
||||
ensure_folder(dest)
|
||||
FNPAIRS = [
|
||||
('ignore_list_dialog.py', 'IgnoreListDialog_UI'),
|
||||
('deletion_options.py', 'DeletionOptions_UI'),
|
||||
('problem_dialog.py', 'ProblemDialog_UI'),
|
||||
('directory_panel.py', 'DirectoryPanel_UI'),
|
||||
('prioritize_dialog.py', 'PrioritizeDialog_UI'),
|
||||
('result_window.py', 'ResultWindow_UI'),
|
||||
('main_menu.py', 'MainMenu_UI'),
|
||||
('preferences_panel.py', 'PreferencesPanel_UI'),
|
||||
]
|
||||
for srcname, dstname in FNPAIRS:
|
||||
xibless.generate(op.join('cocoa', 'base', 'ui', srcname), op.join(dest, dstname),
|
||||
localizationTable='Localizable', args={'edition': edition})
|
||||
if edition == 'pe':
|
||||
xibless.generate('cocoa/pe/ui/details_panel.py', 'cocoa/autogen/DetailsPanel_UI', localizationTable='Localizable')
|
||||
xibless.generate('cocoa/pe/ui/details_panel.py', op.join(dest, 'DetailsPanel_UI'), localizationTable='Localizable')
|
||||
else:
|
||||
xibless.generate('cocoa/base/ui/details_panel.py', 'cocoa/autogen/DetailsPanel_UI', localizationTable='Localizable')
|
||||
xibless.generate('cocoa/base/ui/details_panel.py', op.join(dest, 'DetailsPanel_UI'), localizationTable='Localizable')
|
||||
|
||||
def build_cocoa(edition, dev):
|
||||
ed = lambda s: s.format(edition)
|
||||
build_cocoalib_xibless()
|
||||
build_xibless(edition)
|
||||
build_cocoa_proxy_module()
|
||||
build_cocoa_bridging_interfaces(edition)
|
||||
@ -174,6 +189,15 @@ def build_localizations(ui, edition):
|
||||
shutil.copytree('locale', op.join('build', 'locale'), ignore=shutil.ignore_patterns('*.po', '*.pot'))
|
||||
|
||||
def build_updatepot():
|
||||
if ISOSX:
|
||||
print("Updating Cocoa strings file.")
|
||||
# We need to have strings from *all* editions in here, so we'll call xibless for all editions
|
||||
# in dummy subfolders.
|
||||
build_cocoalib_xibless('cocoalib/autogen')
|
||||
loc.generate_cocoa_strings_from_code('cocoalib', 'cocoalib/en.lproj')
|
||||
for edition in ('se', 'me', 'pe'):
|
||||
build_xibless(edition, op.join('cocoa', 'autogen', edition))
|
||||
loc.generate_cocoa_strings_from_code('cocoa', 'cocoa/base/en.lproj')
|
||||
print("Building .pot files from source files")
|
||||
print("Building core.pot")
|
||||
all_cores = ['core', 'core_se', 'core_me', 'core_pe']
|
||||
@ -187,12 +211,14 @@ def build_updatepot():
|
||||
loc.generate_pot(['hscommon'], op.join('hscommon', 'locale', 'hscommon.pot'), ['tr'])
|
||||
print("Building qtlib.pot")
|
||||
loc.generate_pot(['qtlib'], op.join('qtlib', 'locale', 'qtlib.pot'), ['tr'])
|
||||
print("Building cocoalib.pot")
|
||||
loc.strings2pot(op.join('cocoalib', 'en.lproj', 'cocoalib.strings'),
|
||||
op.join('cocoalib', 'locale', 'cocoalib.pot'))
|
||||
print("Enhancing ui.pot with Cocoa's strings files")
|
||||
loc.strings2pot(op.join('cocoa', 'base', 'en.lproj', 'Localizable.strings'),
|
||||
op.join('locale', 'ui.pot'))
|
||||
if ISOSX:
|
||||
print("Building cocoalib.pot")
|
||||
cocoalib_pot = op.join('cocoalib', 'locale', 'cocoalib.pot')
|
||||
os.remove(cocoalib_pot)
|
||||
loc.strings2pot(op.join('cocoalib', 'en.lproj', 'cocoalib.strings'), cocoalib_pot)
|
||||
print("Enhancing ui.pot with Cocoa's strings files")
|
||||
loc.strings2pot(op.join('cocoa', 'base', 'en.lproj', 'Localizable.strings'),
|
||||
op.join('locale', 'ui.pot'))
|
||||
|
||||
def build_mergepot():
|
||||
print("Updating .po files using .pot files")
|
||||
@ -311,14 +337,16 @@ def main():
|
||||
build_updatepot()
|
||||
elif options.mergepot:
|
||||
build_mergepot()
|
||||
elif options.cocoa_compile:
|
||||
elif options.cocoa_ext:
|
||||
build_cocoa_proxy_module()
|
||||
build_cocoa_bridging_interfaces(edition)
|
||||
elif options.cocoa_compile:
|
||||
os.chdir('cocoa')
|
||||
os.system(cocoa_compile_command(edition))
|
||||
os.chdir('..')
|
||||
copy('cocoa/build/dupeGuru', op.join(cocoa_app_path(edition), 'Contents/MacOS/dupeGuru'))
|
||||
elif options.xibless:
|
||||
build_cocoalib_xibless()
|
||||
build_xibless(edition)
|
||||
else:
|
||||
build_normal(edition, ui, dev)
|
||||
|
@ -136,7 +136,7 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
[op setCanCreateDirectories:NO];
|
||||
[op setAllowsMultipleSelection:NO];
|
||||
[op setAllowedFileTypes:[NSArray arrayWithObject:@"dupeguru"]];
|
||||
[op setTitle:TR(@"Select a results file to load")];
|
||||
[op setTitle:NSLocalizedString(@"Select a results file to load", @"")];
|
||||
if ([op runModal] == NSOKButton) {
|
||||
NSString *filename = [[op filenames] objectAtIndex:0];
|
||||
[model loadResultsFrom:filename];
|
||||
@ -212,7 +212,7 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
|
||||
{
|
||||
if ([model resultsAreModified]) {
|
||||
NSString *msg = TR(@"You have unsaved results, do you really want to quit?");
|
||||
NSString *msg = NSLocalizedString(@"You have unsaved results, do you really want to quit?", @"");
|
||||
if ([Dialogs askYesNo:msg] == NSAlertSecondButtonReturn) { // NO
|
||||
return NSTerminateCancel;
|
||||
}
|
||||
|
@ -6,8 +6,6 @@ which should be included with this package. The terms are also available at
|
||||
http://www.hardcoded.net/licenses/bsd_license
|
||||
*/
|
||||
|
||||
#import "HSConsts.h"
|
||||
|
||||
#define JobStarted @"JobStarted"
|
||||
#define JobInProgress @"JobInProgress"
|
||||
#define TableFontSize @"TableFontSize"
|
||||
|
@ -11,7 +11,6 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
#import "Dialogs.h"
|
||||
#import "Utils.h"
|
||||
#import "AppDelegate.h"
|
||||
#import "Consts.h"
|
||||
|
||||
@implementation DirectoryPanel
|
||||
|
||||
@ -55,7 +54,7 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
- (void)fillPopUpMenu
|
||||
{
|
||||
NSMenu *m = [addButtonPopUp menu];
|
||||
NSMenuItem *mi = [m addItemWithTitle:TR(@"Add New Folder...") action:@selector(askForDirectory) keyEquivalent:@""];
|
||||
NSMenuItem *mi = [m addItemWithTitle:NSLocalizedString(@"Add New Folder...", @"") action:@selector(askForDirectory) keyEquivalent:@""];
|
||||
[mi setTarget:self];
|
||||
[m addItem:[NSMenuItem separatorItem]];
|
||||
}
|
||||
@ -89,7 +88,7 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
[op setCanChooseFiles:YES];
|
||||
[op setCanChooseDirectories:YES];
|
||||
[op setAllowsMultipleSelection:YES];
|
||||
[op setTitle:TR(@"Select a folder to add to the scanning list")];
|
||||
[op setTitle:NSLocalizedString(@"Select a folder to add to the scanning list", @"")];
|
||||
[op setDelegate:self];
|
||||
if ([op runModal] == NSOKButton) {
|
||||
for (NSString *directory in [op filenames]) {
|
||||
@ -116,7 +115,7 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
while ([m numberOfItems] > 0) {
|
||||
[m removeItemAtIndex:0];
|
||||
}
|
||||
NSMenuItem *mi = [m addItemWithTitle:TR(@"Load from file...") action:@selector(loadResults) keyEquivalent:@""];
|
||||
NSMenuItem *mi = [m addItemWithTitle:NSLocalizedString(@"Load from file...", @"") action:@selector(loadResults) keyEquivalent:@""];
|
||||
[mi setTarget:_app];
|
||||
[m addItem:[NSMenuItem separatorItem]];
|
||||
[[_app recentResults] fillMenu:m];
|
||||
|
@ -9,7 +9,6 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
#import "ResultTable.h"
|
||||
#import "Dialogs.h"
|
||||
#import "Utils.h"
|
||||
#import "Consts.h"
|
||||
#import "HSQuicklook.h"
|
||||
|
||||
@interface HSTable (private)
|
||||
@ -99,7 +98,7 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
if (![newName isEqual:oldName]) {
|
||||
BOOL renamed = [[self model] renameSelected:newName];
|
||||
if (!renamed) {
|
||||
[Dialogs showMessage:[NSString stringWithFormat:TR(@"The name '%@' already exists."), newName]];
|
||||
[Dialogs showMessage:[NSString stringWithFormat:NSLocalizedString(@"The name '%@' already exists.", @""), newName]];
|
||||
}
|
||||
else {
|
||||
[[self view] setNeedsDisplay:YES];
|
||||
|
@ -80,7 +80,7 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
[mi setTag:i];
|
||||
}
|
||||
[[app columnsMenu] addItem:[NSMenuItem separatorItem]];
|
||||
NSMenuItem *mi = [[app columnsMenu] addItemWithTitle:TR(@"Reset to Default")
|
||||
NSMenuItem *mi = [[app columnsMenu] addItemWithTitle:NSLocalizedString(@"Reset to Default", @"")
|
||||
action:@selector(resetColumnsToDefault) keyEquivalent:@""];
|
||||
[mi setTarget:self];
|
||||
}
|
||||
@ -259,7 +259,7 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
NSSavePanel *sp = [NSSavePanel savePanel];
|
||||
[sp setCanCreateDirectories:YES];
|
||||
[sp setAllowedFileTypes:[NSArray arrayWithObject:@"dupeguru"]];
|
||||
[sp setTitle:TR(@"Select a file to save your results to")];
|
||||
[sp setTitle:NSLocalizedString(@"Select a file to save your results to", @"")];
|
||||
if ([sp runModal] == NSOKButton) {
|
||||
[model saveResultsAs:[sp filename]];
|
||||
[[app recentResults] addFile:[sp filename]];
|
||||
@ -269,7 +269,7 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
- (void)startDuplicateScan
|
||||
{
|
||||
if ([model resultsAreModified]) {
|
||||
if ([Dialogs askYesNo:TR(@"You have unsaved results, do you really want to continue?")] == NSAlertSecondButtonReturn) // NO
|
||||
if ([Dialogs askYesNo:NSLocalizedString(@"You have unsaved results, do you really want to continue?", @"")] == NSAlertSecondButtonReturn) // NO
|
||||
return;
|
||||
}
|
||||
[self setScanOptions];
|
||||
@ -342,7 +342,7 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
|
||||
- (void)jobInProgress:(NSNotification *)aNotification
|
||||
{
|
||||
[Dialogs showMessage:TR(@"A previous action is still hanging in there. You can't start a new one yet. Wait a few seconds, then try again.")];
|
||||
[Dialogs showMessage:NSLocalizedString(@"A previous action is still hanging in there. You can't start a new one yet. Wait a few seconds, then try again.", @"")];
|
||||
}
|
||||
|
||||
- (void)jobStarted:(NSNotification *)aNotification
|
||||
|
@ -8,8 +8,8 @@ promptLabel = Label(result, "Add criteria to the right box and click OK to send
|
||||
categoryPopup = Popup(result)
|
||||
criteriaTable = ListView(result)
|
||||
prioritizationTable = ListView(result)
|
||||
addButton = Button(result, "-->")
|
||||
removeButton = Button(result, "<--")
|
||||
addButton = Button(result, NLSTR("-->"))
|
||||
removeButton = Button(result, NLSTR("<--"))
|
||||
okButton = Button(result, "Ok")
|
||||
cancelButton = Button(result, "Cancel")
|
||||
|
||||
|
@ -7,7 +7,6 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
*/
|
||||
|
||||
#import "DirectoryPanel.h"
|
||||
#import "Consts.h"
|
||||
|
||||
@implementation DirectoryPanelME
|
||||
- (id)initWithParentApp:(id)aParentApp
|
||||
@ -21,7 +20,7 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
{
|
||||
[super fillPopUpMenu];
|
||||
NSMenu *m = [addButtonPopUp menu];
|
||||
NSMenuItem *mi = [m insertItemWithTitle:TR(@"Add iTunes Library") action:@selector(addiTunes:)
|
||||
NSMenuItem *mi = [m insertItemWithTitle:NSLocalizedString(@"Add iTunes Library", @"") action:@selector(addiTunes:)
|
||||
keyEquivalent:@"" atIndex:1];
|
||||
[mi setTarget:self];
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
*/
|
||||
|
||||
#import "DirectoryPanel.h"
|
||||
#import "Consts.h"
|
||||
|
||||
@implementation DirectoryPanelPE
|
||||
- (id)initWithParentApp:(id)aParentApp
|
||||
@ -21,10 +20,10 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
{
|
||||
[super fillPopUpMenu];
|
||||
NSMenu *m = [addButtonPopUp menu];
|
||||
NSMenuItem *mi = [m insertItemWithTitle:TR(@"Add iPhoto Library") action:@selector(addiPhoto:)
|
||||
NSMenuItem *mi = [m insertItemWithTitle:NSLocalizedString(@"Add iPhoto Library", @"") action:@selector(addiPhoto:)
|
||||
keyEquivalent:@"" atIndex:1];
|
||||
[mi setTarget:self];
|
||||
mi = [m insertItemWithTitle:TR(@"Add Aperture Library") action:@selector(addAperture:)
|
||||
mi = [m insertItemWithTitle:NSLocalizedString(@"Add Aperture Library", @"") action:@selector(addAperture:)
|
||||
keyEquivalent:@"" atIndex:2];
|
||||
[mi setTarget:self];
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
#import "ResultWindow.h"
|
||||
#import "Dialogs.h"
|
||||
#import "Utils.h"
|
||||
#import "Consts.h"
|
||||
#import "PyDupeGuru.h"
|
||||
|
||||
@implementation ResultWindow
|
||||
@ -50,7 +49,7 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
/* Actions */
|
||||
- (void)clearPictureCache
|
||||
{
|
||||
NSString *msg = TR(@"Do you really want to remove all your cached picture analysis?");
|
||||
NSString *msg = NSLocalizedString(@"Do you really want to remove all your cached picture analysis?", @"");
|
||||
if ([Dialogs askYesNo:msg] == NSAlertSecondButtonReturn) // NO
|
||||
return;
|
||||
[model clearPictureCache];
|
||||
|
Loading…
x
Reference in New Issue
Block a user