diff --git a/chinese/edit.py b/chinese/edit.py index b9c5e39..8564c99 100644 --- a/chinese/edit.py +++ b/chinese/edit.py @@ -58,7 +58,7 @@ def onToggle(self, editor): config.save() def updateButton(self, editor): - enabled = str(editor.note.model()['id']) in config['enabledModels'] + enabled = str(editor.note.note_type()['id']) in config['enabledModels'] if (enabled and not self.buttonOn) or (not enabled and self.buttonOn): editor.web.eval('toggleEditorButton(chineseSupport);') @@ -68,7 +68,7 @@ def onFocusLost(self, _, note, index): if not self.buttonOn: return False - allFields = mw.col.models.fieldNames(note.model()) + allFields = mw.col.models.field_names(note.note_type()) field = allFields[index] if update_fields(note, field, allFields): @@ -83,7 +83,7 @@ def onFocusLost(self, _, note, index): def append_tone_styling(editor): js = 'var css = document.styleSheets[0];' - for line in editor.note.model()['css'].split('\n'): + for line in editor.note.note_type()['css'].split('\n'): if line.startswith('.tone'): js += 'css.insertRule("{}", css.cssRules.length);'.format( line.rstrip()) diff --git a/chinese/gui.py b/chinese/gui.py index 64faea3..d913dec 100644 --- a/chinese/gui.py +++ b/chinese/gui.py @@ -75,24 +75,24 @@ def load_menu(): ) add_menu('Chinese::Bulk Fill') - add_menu_item('Chinese::Bulk Fill', _('Hanzi'), bulk_fill_hanzi) + add_menu_item('Chinese::Bulk Fill', 'Hanzi', bulk_fill_hanzi) add_menu_item( - 'Chinese::Bulk Fill', _('Transcription'), bulk_fill_transcript + 'Chinese::Bulk Fill', 'Transcription', bulk_fill_transcript ) - add_menu_item('Chinese::Bulk Fill', _('Definitions'), bulk_fill_defs) - add_menu_item('Chinese::Bulk Fill', _('Classifiers'), bulk_fill_classifiers) - add_menu_item('Chinese::Bulk Fill', _('Sound'), bulk_fill_sound) - add_menu_item('Chinese::Bulk Fill', _('Silhouette'), bulk_fill_silhouette) - add_menu_item('Chinese::Bulk Fill', _('Usage'), bulk_fill_usage) - add_menu_item('Chinese::Bulk Fill', _('All'), bulk_fill_all) + add_menu_item('Chinese::Bulk Fill', 'Definitions', bulk_fill_defs) + add_menu_item('Chinese::Bulk Fill', 'Classifiers', bulk_fill_classifiers) + add_menu_item('Chinese::Bulk Fill', 'Sound', bulk_fill_sound) + add_menu_item('Chinese::Bulk Fill', 'Silhouette', bulk_fill_silhouette) + add_menu_item('Chinese::Bulk Fill', 'Usage', bulk_fill_usage) + add_menu_item('Chinese::Bulk Fill', 'All', bulk_fill_all) add_menu('Chinese::Help') add_menu_item( 'Chinese::Help', - _('Report a bug or make a feature request'), + 'Report a bug or make a feature request', lambda: openLink(CSR_GITHUB_URL + '/issues'), ) - add_menu_item('Chinese::Help', _('About...'), showAbout) + add_menu_item('Chinese::Help', 'About...', showAbout) def unload_menu(): diff --git a/chinese/main.py b/chinese/main.py index 04ba325..e6529dd 100644 --- a/chinese/main.py +++ b/chinese/main.py @@ -57,7 +57,7 @@ def load(): def add_models(): models.append(('Chinese (Advanced)', advanced.add_model)) models.append(('Chinese (Basic)', basic.add_model)) - if not mw.col.models.byName('Chinese (Advanced)'): + if not mw.col.models.by_name('Chinese (Advanced)'): advanced.add_model(mw.col) - if not mw.col.models.byName('Chinese (Basic)'): + if not mw.col.models.by_name('Chinese (Basic)'): basic.add_model(mw.col) diff --git a/chinese/templates/chinese_new.py b/chinese/templates/chinese_new.py index 6354750..bad8382 100644 --- a/chinese/templates/chinese_new.py +++ b/chinese/templates/chinese_new.py @@ -10,7 +10,7 @@ import re from anki import hooks -from anki.utils import stripHTML +from anki.utils import strip_html as stripHTML from anki.template import TemplateRenderContext from .ruby import ruby_top, ruby_top_text, ruby_bottom_text, no_sound