Skip to content

Commit 018a1a3

Browse files
committed
151: Make compatible with Anki 2.1.22 and up
* Keep downwards compatibility until 2.1.15 * Idea for fix from @5hir0kur0 * Run `black` on `src/image_occlusion_enhanced/lang.py`
1 parent 2879730 commit 018a1a3

File tree

1 file changed

+7
-3
lines changed
  • src/image_occlusion_enhanced

1 file changed

+7
-3
lines changed

src/image_occlusion_enhanced/lang.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030

3131
import os
3232
import gettext
33-
import threading
3433

3534
import anki.lang
35+
from aqt import mw
3636

3737
# TODO maybe remove the table and 'mungeCode' once Anki 2.1.16 is released and
3838
# replace with calls to the API to reduce copied code
@@ -124,5 +124,9 @@ def mungeCode(code):
124124

125125

126126
if not currentTranslation:
127-
# FIXME:
128-
setLang(anki.lang.currentLang)
127+
if hasattr(anki.lang, "getLang"):
128+
# backwards compatibility Anki < 2.1.22
129+
# (commit 6c9e9eb3300707f534af5b57e45a0cec7ed91401)
130+
setLang(anki.lang.getLang())
131+
else:
132+
setLang(anki.lang.currentLang or mw.pm.meta["defaultLang"] or "en_US")

0 commit comments

Comments
 (0)