diff --git a/doc/p/quickdic6.md b/doc/p/quickdic6.md index 7e0c6ceec..58bdf4c44 100644 --- a/doc/p/quickdic6.md +++ b/doc/p/quickdic6.md @@ -19,11 +19,9 @@ ### Write options -| Name | Default | Type | Comment | -| ---------------- | ------- | ---- | -------------------------------------------------- | -| normalizer_rules | | str | ICU normalizer rules to use for index sorting | -| source_lang | | str | The language of the tokens in the dictionary index | -| target_lang | | str | The language of the dictionary entries | +| Name | Default | Type | Comment | +| ---------------- | ------- | ---- | --------------------------------------------- | +| normalizer_rules | | str | ICU normalizer rules to use for index sorting | ### Dependencies for reading diff --git a/plugins-meta/index.json b/plugins-meta/index.json index a63dde746..6bf474610 100644 --- a/plugins-meta/index.json +++ b/plugins-meta/index.json @@ -1419,18 +1419,6 @@ "type": "str", "customValue": true, "comment": "ICU normalizer rules to use for index sorting" - }, - "source_lang": { - "class": "StrOption", - "type": "str", - "customValue": true, - "comment": "The language of the tokens in the dictionary index" - }, - "target_lang": { - "class": "StrOption", - "type": "str", - "customValue": true, - "comment": "The language of the dictionary entries" } }, "canRead": true, @@ -1438,9 +1426,7 @@ "sortOnWrite": "never", "readOptions": {}, "writeOptions": { - "normalizer_rules": "", - "source_lang": "", - "target_lang": "" + "normalizer_rules": "" }, "readDepends": { "icu": "PyICU" diff --git a/pyglossary/plugins/quickdic6.py b/pyglossary/plugins/quickdic6.py index 0860f7a51..327b8167c 100644 --- a/pyglossary/plugins/quickdic6.py +++ b/pyglossary/plugins/quickdic6.py @@ -22,7 +22,6 @@ from pyglossary.core import log from pyglossary.flags import NEVER from pyglossary.html_utils import unescape_unicode -from pyglossary.langs import langDict from pyglossary.option import ( Option, StrOption, @@ -65,12 +64,6 @@ "normalizer_rules": StrOption( comment="ICU normalizer rules to use for index sorting", ), - "source_lang": StrOption( - comment="The language of the tokens in the dictionary index", - ), - "target_lang": StrOption( - comment="The language of the dictionary entries", - ), } HASH_SET_INIT = ( @@ -810,8 +803,6 @@ def __iter__(self) -> typing.Iterator[EntryType]: class Writer: _normalizer_rules = "" - _source_lang = "" - _target_lang = "" def __init__(self, glos: GlossaryType) -> None: self._glos = glos @@ -852,28 +843,20 @@ def write(self) -> typing.Generator[None, EntryType, None]: # specifies the entry type to use. htmls.append((0, words[0], entry.defi)) + glos = self._glos + log.info("Collecting meta data ...") - name = self._glos.getInfo("bookname") + name = glos.getInfo("bookname") if not name: - name = self._glos.getInfo("description") + name = glos.getInfo("description") - sourceLang = ( - self._glos.sourceLang - if not self._source_lang - else langDict[self._source_lang] - ) - targetLang = ( - self._glos.targetLang - if not self._target_lang - else langDict[self._target_lang] - ) - if sourceLang and targetLang: - sourceLang = sourceLang.code - targetLang = targetLang.code - else: - # fallback if no languages are specified - sourceLang = targetLang = "EN" - langs = f"{sourceLang}->{targetLang}" + sourceLangCode, targetLangCode = "EN", "EN" + if glos.sourceLang: + sourceLangCode = glos.sourceLang.code + if glos.targetLang: + targetLangCode = glos.targetLang.code + + langs = f"{sourceLangCode}->{targetLangCode}" if langs not in name.lower(): name = f"{self._glos.getInfo('name')} ({langs})" @@ -898,7 +881,7 @@ def write(self) -> typing.Generator[None, EntryType, None]: # indices: list[EntryIndexTuple] | None = None, ) - short_name = long_name = iso = sourceLang + short_name = long_name = iso = sourceLangCode normalizer_rules = self._normalizer_rules or ( default_de_normalizer_rules if iso == "DE" else default_normalizer_rules )