From ca0df4929da48a7e35b24e81d41cb6a4fab200a1 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 17 Feb 2020 17:39:01 +1000 Subject: [PATCH] add fallback for tr if collection not open When syncing media on close, the collection may be closed before media syncing completes. A better solution in the future will be decouple translations from the collection object. --- qt/aqt/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qt/aqt/utils.py b/qt/aqt/utils.py index b01cc7442..74d07ab32 100644 --- a/qt/aqt/utils.py +++ b/qt/aqt/utils.py @@ -34,7 +34,10 @@ def locale_dir() -> str: def tr(group: StringsGroup, key: str, **kwargs: Union[str, int, float]) -> str: """Shortcut to access translations from the backend. (Currently) requires an open collection.""" - return aqt.mw.col.backend.translate(group, key, **kwargs) + if aqt.mw.col: + return aqt.mw.col.backend.translate(group, key, **kwargs) + else: + return key def openHelp(section):