Skip to content

Commit

Permalink
feat: Message to approach translators after 10 manual starts of BIT GUI
Browse files Browse the repository at this point in the history
Add a dialog with a message about current state of translation and how to contribute to the translation. The dialog is shown to users after the first 10 manual starts of Back In Time GUI. It is accessible every time via the Help menu.

Modifications in detail:
- New dialog class "ApproachTranslatorDialog"
- config: New variable "manual_starts_countdown"
- languages.py: Add a dictionary containing the language specific completeness in percent for each language.

Additional minor fixes and modifications:
- Fixed a problem with determining available languages.
- Snapshot settings dialog title is now consistent with its corresponding menu entry.
- GitHub issue template: Add information about the mailing list.
- README: Extended description about mailing list to make clear it is open not only to developers.
  • Loading branch information
buhtz committed Aug 29, 2023
1 parent ecf9312 commit d7e0297
Show file tree
Hide file tree
Showing 10 changed files with 193 additions and 27 deletions.
3 changes: 2 additions & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
To help us diagnose the problem quickly, please provide the output of the console command `backintime --diagnostics`.

Additionally, please specify as precisely as you can the package or installation source where you got BackInTime. Sometimes there are multiple alternatives, like [for Arch-based distros](https://aur.archlinux.org/packages?K=backintime).
Additionally, please specify as precisely as you can the package or installation source where you got Back In Time from. Sometimes there are multiple alternatives, like in [for Arch-based distros](https://aur.archlinux.org/packages?K=backintime).

As an alternative fell free to use our mailing list for every topic about Back In Time. Visit the subscribtion page at https://mail.python.org/mailman3/lists/bit-dev.python.org or send an email with subject "Subscribe" to bit-dev-join@python.org.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Version 1.3.4-dev (development of upcoming release)
* Translation: Plural forms support (#1488).
* Removed: Translation in Canadian English, British English and Javanese (#1455).
* Added: Translation in Persian and Vietnamese (#1460).
* Added: Message to users (after 10 starts of BIT Gui) to motivate them contributing translations (#1473).

Version 1.3.3 (2023-01-04)
* Feature: New command line argument "--diagnostics" to show helpful info for better issue support (#1100)
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ and [help wanted](https://github.com/bit-team/backintime/issues?q=is%3Aissue+is%
* [FAQ - Frequently Asked Questions](FAQ.md)
* [Source code documentation for developers](https://backintime-dev.readthedocs.org)
* Use [Issues](https://github.com/bit-team/backintime/issues) to ask questions and report bugs.
* [Mailing list _bit-dev_](https://mail.python.org/mailman3/lists/bit-dev.python.org/)
* [Mailing list
_bit-dev_](https://mail.python.org/mailman3/lists/bit-dev.python.org/) for
**every topic**, question and idea about _Back In Time_. Despite its name
it is not restricted to development topics only.

## Installation

Expand Down
23 changes: 22 additions & 1 deletion common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
# The bigger problem with config.py is that it do use translatebale strings.
# Strings like this do not belong into a config file or its context.
try:
_('Foo')
_('Cancel')
except NameError:
_ = lambda val: val

Expand Down Expand Up @@ -568,6 +568,27 @@ def language(self) -> str:
def setLanguage(self, language: str):
self.setStrValue('global.language', language if language else '')

def manual_starts_countdown(self) -> int:
"""Countdown value about how often the users startet the Back In Time
GUI.
It is an internal variable not meant to be used or manipulated be the
users. At the end of the countown the
:py:class:`ApproachTranslatorDialog` is presented to the user.
"""
return self.intValue('internal.manual_starts_countdown', 10)

def decrement_manual_starts_countdown(self):
"""Counts down to -1.
See :py:func:`manual_starts_countdown()` for details.
"""
val = self.manual_starts_countdown()

if val > -1:
self.setIntValue('internal.manual_starts_countdown', val - 1)

# SSH
def sshSnapshotsPath(self, profile_id = None):
#?Snapshot path on remote host. If the path is relative (no leading '/')
Expand Down
1 change: 1 addition & 0 deletions common/languages.py
Original file line number Diff line number Diff line change
Expand Up @@ -2084,6 +2084,7 @@
'da': 25,
'de': 99,
'el': 12,
'en': 100,
'eo': 34,
'es': 55,
'et': 23,
Expand Down
33 changes: 25 additions & 8 deletions common/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,24 +196,24 @@ def get_available_language_codes():

# full path of one mo-file
# e.g. /usr/share/locale/de/LC_MESSAGES/backintime.mo
po = gettext.find(domain=_GETTEXT_DOMAIN, localedir=_GETTEXT_LOCALE_DIR)
mo = gettext.find(domain=_GETTEXT_DOMAIN, localedir=_GETTEXT_LOCALE_DIR)

if po:
po = pathlib.Path(po)
if mo:
mo = pathlib.Path(mo)
else:
# Workaround. This happens if LC_ALL=C and BIT don't use an explicite
# language. Should be re-design.
po = _GETTEXT_LOCALE_DIR / 'xy' / 'LC_MESSAGES' / 'backintime.po'
mo = _GETTEXT_LOCALE_DIR / 'xy' / 'LC_MESSAGES' / 'backintime.mo'

# e.g. de/LC_MESSAGES/backintime.mo
po = po.relative_to(_GETTEXT_LOCALE_DIR)
mo = mo.relative_to(_GETTEXT_LOCALE_DIR)

# e.g. */LC_MESSAGES/backintime.mo
po = pathlib.Path('*') / pathlib.Path(*po.parts[1:])
mo = pathlib.Path('*') / pathlib.Path(*mo.parts[1:])

pofiles = _GETTEXT_LOCALE_DIR.rglob(str(po))
mofiles = _GETTEXT_LOCALE_DIR.rglob(str(mo))

return [p.relative_to(_GETTEXT_LOCALE_DIR).parts[0] for p in pofiles]
return [p.relative_to(_GETTEXT_LOCALE_DIR).parts[0] for p in mofiles]


def get_language_names(language_code):
Expand Down Expand Up @@ -263,6 +263,23 @@ def get_language_names(language_code):
return result


def get_native_language_and_completeness(language_code):
"""Return the language name in its native flavour and the completeness of
its translation in percent.
Args:
language_code(str): The language code.
Returns:
A two-entry tuple with language name as string and a percent as
integer.
"""
name = languages.names[language_code][language_code]
completeness = languages.completeness[language_code]

return (name, completeness)


# |------------------------------------|
# | Miscellaneous, not categorized yet |
# |------------------------------------|
Expand Down
45 changes: 39 additions & 6 deletions qt/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
import snapshotsdialog
import logviewdialog
from restoredialog import RestoreDialog
from languagedialog import LanguageDialog
import languagedialog
import messagebox


Expand Down Expand Up @@ -400,6 +400,21 @@ def __init__(self, config, appInstance, qapp):

SetupCron(self).start()

# Finished countdown of manual GUI starts
if 0 == self.config.manual_starts_countdown():

# Do nothing if English is the current used language
if self.config.language_used != 'en':

# Show the message only if teh current used language is
# translated equal or less then 97%
self._open_approach_translator_dialog(cutoff=97)

# BIT counts down how often the GUI was started. Until the end of that
# countdown a dialog with a text about contributing to translating
# BIT is prestented to the users.
self.config.decrement_manual_starts_countdown()

@property
def showHiddenFiles(self):
return self.config.boolValue('qt.show_hidden_files', False)
Expand Down Expand Up @@ -473,15 +488,15 @@ def _create_actions(self):
self.btnLastLogViewClicked, None,
None),
'act_settings': (
icon.SETTINGS, _('Manage profiles…'),
icon.SETTINGS, '{}…'.format(_('Manage profiles')),
self.btnSettingsClicked, ['Ctrl+Shift+P'],
None),
'act_shutdown': (
icon.SHUTDOWN, _('Shutdown'),
None, None,
_('Shut down system after snapshot has finished.')),
'act_setup_language': (
None, _('Setup language…'),
None, '{}…'.format(_('Setup language')),
self.slot_setup_language, None,
None),
'act_quit': (
Expand Down Expand Up @@ -510,6 +525,9 @@ def _create_actions(self):
'act_help_bugreport': (
icon.BUG, _('Report a bug'),
self.btnReportBugClicked, None, None),
'act_help_translation': (
None, _('Translation'),
self.slot_help_translation, None, None),
'act_help_about': (
icon.ABOUT, _('About'),
self.btnAboutClicked, None, None),
Expand Down Expand Up @@ -540,7 +558,7 @@ def _create_actions(self):
icon.SHOW_HIDDEN, _('Show hidden files'),
None, ['Ctrl+H'], None),
'act_snapshots_dialog': (
icon.SNAPSHOTS, _('Compare snapshots…'),
icon.SNAPSHOTS, '{}…'.format(_('Compare snapshots')),
self.btnSnapshotsClicked, None, None),
}

Expand Down Expand Up @@ -626,6 +644,7 @@ def _create_menubar(self):
self.act_help_faq,
self.act_help_question,
self.act_help_bugreport,
self.act_help_translation,
self.act_help_about,
)
}
Expand Down Expand Up @@ -1750,27 +1769,41 @@ def suspendMouseButtonNavigation(self):
yield
self.setMouseButtonNavigation()

def _open_approach_translator_dialog(self, cutoff=101):
code = self.config.language_used
name, perc = tools.get_native_language_and_completeness(code)

if perc > cutoff:
return

dlg = languagedialog.ApproachTranslatorDialog(self, name, perc)
dlg.exec()

# |-------|
# | Slots |
# |-------|
def slot_setup_language(self):
"""Show a modal language settings dialog and modify the UI language
settings."""

dlg = LanguageDialog(
dlg = languagedialog.LanguageDialog(
used_language_code=self.config.language_used,
configured_language_code=self.config.language())

dlg.exec()

if dlg.result() == 1 and self.config.language != dlg.language_code:
# Apply/OK pressed & the language value modified
if dlg.result() == 1 and self.config.language() != dlg.language_code:

self.config.setLanguage(dlg.language_code)

messagebox.info(_('The language settings take effect only after '
'restarting Back In Time.'),
widget_to_center_on=dlg)

def slot_help_translation(self):
self._open_approach_translator_dialog()


class About(QDialog):
def __init__(self, parent = None):
Expand Down
Loading

0 comments on commit d7e0297

Please sign in to comment.