From 6c60e76b55f41e87ec7791c1aa895c1c416112cf Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Mon, 24 Jan 2011 11:30:45 +0100 Subject: [PATCH] Localized Fairware dialogs to french and made a few fixes here and there. --- build.py | 2 +- cocoa/pe/fr.lproj/Preferences.strings | 2 +- core/app.py | 28 ++++++++++++++++++++++++++- core/app_cocoa.py | 14 +++++++++++--- core/app_cocoa_inter.py | 4 ---- help/fr/preferences.rst | 2 +- qt/base/app.py | 10 ++++++++-- qt/lang/fr.ts | 2 +- 8 files changed, 50 insertions(+), 14 deletions(-) diff --git a/build.py b/build.py index bc22c6bc..873846d9 100644 --- a/build.py +++ b/build.py @@ -88,7 +88,7 @@ def build_cocoa(edition, dev): def build_qt(edition, dev): print("Building .ts files") - build_all_qt_locs(op.join('qt', 'lang')) + build_all_qt_locs(op.join('qt', 'lang'), extradirs=[op.join('qtlib', 'lang')]) print("Building Qt stuff") print_and_do("pyrcc4 -py3 {0} > {1}".format(op.join('qt', 'base', 'dg.qrc'), op.join('qt', 'base', 'dg_rc.py'))) print("Creating the run.py file") diff --git a/cocoa/pe/fr.lproj/Preferences.strings b/cocoa/pe/fr.lproj/Preferences.strings index 371f5d1d..ccbf1233 100644 --- a/cocoa/pe/fr.lproj/Preferences.strings +++ b/cocoa/pe/fr.lproj/Preferences.strings @@ -30,7 +30,7 @@ "30.title" = "Directement à la destination"; /* Class = "NSButtonCell"; title = "Match scaled pictures together"; ObjectID = "31"; */ -"31.title" = "Comparer les images de taille différente"; +"31.title" = "Comparer les images de tailles différentes"; /* Class = "NSButtonCell"; title = "Automatically check for updates"; ObjectID = "32"; */ "32.title" = "Vérifier automatiquement les mises à jour"; diff --git a/core/app.py b/core/app.py index a1e280fc..fe48180f 100644 --- a/core/app.py +++ b/core/app.py @@ -18,7 +18,7 @@ from hscommon.reg import RegistrableApplication from hscommon.notify import Broadcaster from hscommon.path import Path from hscommon.conflict import smart_move, smart_copy -from hscommon.util import delete_if_empty, first, escape +from hscommon.util import delete_if_empty, first, escape, nonone from hscommon.trans import tr from . import directories, results, scanner, export, fs @@ -29,6 +29,8 @@ JOB_MOVE = 'job_move' JOB_COPY = 'job_copy' JOB_DELETE = 'job_delete' +HAD_FIRST_LAUNCH_PREFERENCE = 'HadFirstLaunch' + class NoScannableFileError(Exception): pass @@ -36,6 +38,9 @@ class DupeGuru(RegistrableApplication, Broadcaster): def __init__(self, data_module, appdata): RegistrableApplication.__init__(self, appid=1) Broadcaster.__init__(self) + self.is_first_run = not self.get_default(HAD_FIRST_LAUNCH_PREFERENCE, False) + if self.is_first_run: + self.set_default(HAD_FIRST_LAUNCH_PREFERENCE, True) self.appdata = appdata if not op.exists(self.appdata): os.makedirs(self.appdata) @@ -50,6 +55,7 @@ class DupeGuru(RegistrableApplication, Broadcaster): } self.selected_dupes = [] + #--- Private def _do_delete(self, j, replace_with_hardlinks): def op(dupe): j.add_progress() @@ -129,6 +135,13 @@ class DupeGuru(RegistrableApplication, Broadcaster): # func(j, *args) raise NotImplementedError() + def _get_default(self, key_name, fallback_value=None): + raise NotImplementedError() + + def _set_default(self, key_name, value): + raise NotImplementedError() + + #--- Public def add_directory(self, d): try: self.directories.add_path(Path(d)) @@ -350,6 +363,19 @@ class DupeGuru(RegistrableApplication, Broadcaster): def without_ref(self, dupes): return [dupe for dupe in dupes if self.results.get_group_of_duplicate(dupe).ref is not dupe] + def get_default(self, key, fallback_value=None): + result = nonone(self._get_default(key), fallback_value) + if fallback_value is not None and not isinstance(result, type(fallback_value)): + # we don't want to end up with garbage values from the prefs + try: + result = type(fallback_value)(result) + except Exception: + result = fallback_value + return result + + def set_default(self, key, value): + self._set_default(key, value) + #--- Properties @property def stat_line(self): diff --git a/core/app_cocoa.py b/core/app_cocoa.py index 7a8838c0..9e2b5e53 100644 --- a/core/app_cocoa.py +++ b/core/app_cocoa.py @@ -11,7 +11,7 @@ import os.path as op from jobprogress import job from hscommon import cocoa -from hscommon.cocoa import install_exception_hook +from hscommon.cocoa import install_exception_hook, pythonify from hscommon.cocoa.objcmin import (NSNotificationCenter, NSUserDefaults, NSSearchPathForDirectoriesInDomains, NSApplicationSupportDirectory, NSUserDomainMask, NSWorkspace) @@ -29,7 +29,7 @@ JOBID2TITLE = { class DupeGuru(app.DupeGuru): def __init__(self, data_module, appdata_subdir): - LOGGING_LEVEL = logging.DEBUG if NSUserDefaults.standardUserDefaults().boolForKey_('debug') else logging.WARNING + LOGGING_LEVEL = logging.DEBUG if self.get_default('debug') else logging.WARNING logging.basicConfig(level=LOGGING_LEVEL, format='%(levelname)s %(message)s') logging.debug('started in debug mode') install_exception_hook() @@ -58,7 +58,15 @@ class DupeGuru(app.DupeGuru): ud = {'desc': JOBID2TITLE[jobid], 'jobid':jobid} NSNotificationCenter.defaultCenter().postNotificationName_object_userInfo_('JobStarted', self, ud) - #---Public + def _get_default(self, key_name): + raw = NSUserDefaults.standardUserDefaults().objectForKey_(key_name) + result = pythonify(raw) + return result + + def _set_default(self, key_name, value): + NSUserDefaults.standardUserDefaults().setObject_forKey_(value, key_name) + + #--- Public def start_scanning(self): self._select_dupes([]) try: diff --git a/core/app_cocoa_inter.py b/core/app_cocoa_inter.py index b499ddc8..dc3f1aef 100644 --- a/core/app_cocoa_inter.py +++ b/core/app_cocoa_inter.py @@ -18,10 +18,6 @@ from .gui.problem_table import ProblemTable from .gui.result_table import ResultTable from .gui.stats_label import StatsLabel -# Fix py2app's problems on relative imports -from core import app, app_cocoa, data, directories, engine, export, ignore, results, fs, scanner -from hscommon import conflict - class PyDupeGuruBase(PyFairware): #---Directories def addDirectory_(self, directory): diff --git a/help/fr/preferences.rst b/help/fr/preferences.rst index 6cb7aaf9..a7250de7 100644 --- a/help/fr/preferences.rst +++ b/help/fr/preferences.rst @@ -32,7 +32,7 @@ Préférences **Seuil du filtre:** Plus il est élevé, plus les images doivent être similaires pour être considérées comme des doublons. Le défaut de 95% permet quelques petites différence, comme par exemple une différence de qualité ou bien une légère modification des couleurs. - **Comparer les images de taille différente:** Le nom dit tout. Sans cette option, les images de taille différentes ne sont pas comparées. + **Comparer les images de tailles différentes:** Le nom dit tout. Sans cette option, les images de tailles différentes ne sont pas comparées. **Comparer les fichiers de différents types:** Sans cette option, seulement les fichiers du même type seront comparés. diff --git a/qt/base/app.py b/qt/base/app.py index d7d03e61..30cda8e2 100644 --- a/qt/base/app.py +++ b/qt/base/app.py @@ -49,6 +49,8 @@ class DupeGuru(DupeGuruBase, QObject): os.makedirs(appdata) # For basicConfig() to work, we have to be sure that no logging has taken place before this call. logging.basicConfig(filename=op.join(appdata, 'debug.log'), level=logging.WARNING) + self.prefs = self._create_preferences() + self.prefs.load() DupeGuruBase.__init__(self, data_module, appdata) QObject.__init__(self) self._setup() @@ -56,8 +58,6 @@ class DupeGuru(DupeGuruBase, QObject): #--- Private def _setup(self): self._setupActions() - self.prefs = self._create_preferences() - self.prefs.load() self._update_options() self.recentResults = Recent(self, 'recentResults') self.recentResults.mustOpenItem.connect(self.load_from) @@ -147,6 +147,12 @@ class DupeGuru(DupeGuruBase, QObject): msg = trmsg("TaskHangingMsg") QMessageBox.information(self.resultWindow, 'Action in progress', msg) + def _get_default(self, key): + return self.prefs.get_value(key) + + def _set_default(self, key, value): + self.prefs.set_value(key, value) + def add_selected_to_ignore_list(self): dupes = self.without_ref(self.selected_dupes) if not dupes: diff --git a/qt/lang/fr.ts b/qt/lang/fr.ts index 3b07beb3..f67dcdc3 100644 --- a/qt/lang/fr.ts +++ b/qt/lang/fr.ts @@ -512,7 +512,7 @@ Match scaled pictures together - Comparer les images de taille différente + Comparer les images de tailles différentes Clear Picture Cache