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.
This commit is contained in:
Damien Elmes 2020-02-17 17:39:01 +10:00
parent 44053f0715
commit ca0df4929d

View File

@ -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):