-
Notifications
You must be signed in to change notification settings - Fork 231
Bug with termTags and Translator data format #337
Comments
Do you mean when it is not I agree that the data format is problematic, but if I remember correctly it was decided in #84/#95 to be the easier way to move forward. I should have probably considered it technical debt to be fixed as soon as possible after the feature had been deployed. Now there are special cases everywhere causing bugs like #336. Do you think it would make sense to replace
with a
inside |
It seems to depend on which mode you have enabled when you import the dictionaries. I re-imported with |
(I also noticed that "Enable search" isn't checked automatically for imported dictionaries although they're enabled) |
I think this is a bug where the checkbox isn't updated properly after the import. Refresh the page after importing and it is should appear checked (without doing it yourself). |
Actually this was caused by having the wrong main dictionary. Now my dictionaries work with all three modes after the re-import. Still doesn't explain why re-import fixed |
c2ff25b could be relevant |
I reimported fairly recently, as I wind up purging my dev environment fairly often. Here's a few things I've noticed: Install two primary dictionaries (I tested with JMdict + KireiCake). Leave one enabled and disable the other. Set the main dictionary to the disabled one. Scan a word with termTags in merge mode, and no tags will show up. Change the main dictionary to the enabled one and then scan the word again, the term tags should appear. I don't know how my previous settings were causing it to not work (the settings from the video), as I messed around a bit and then it started working. The primary dictionary was enabled for that also. One thing I have done recently was import the settings from #327 (comment), but I updated the main/enabled dictionaries after doing that. |
I ran into the issue with missing tags again when testing with |
There is currently a bug with
termTags
not being shown properly when result grouping mode ismerge
, causing the tags to never be shown. The issue stems from thetermTags
not being consistently defined, andDisplayGenerator
is reading the property from the wrong object.yomichan/ext/mixed/js/display-generator.js
Lines 74 to 77 in 05bb4ae
Above,
DisplayGenerator.createTermExpression
will readtermTags
fromdetails.expressions[n]
inmerge
mode, and fromdetails
otherwise. However, inmerge
mode,termTags
is defined ondetails
, while all of the other data used to generate the expression is still ondetails.expressions[n]
.In my opinion, there is a larger issue at hand here where the data returned from the translator backend returns an inconsistent format, a format which changes based on the presentation mode. The
termTags
that is being read byDisplayGenerator.createTermExpression
can be eithernull
or an array, which is usually empty, which is another inconsistency.It would be nice if these data structures could be standardized, but this also presents several problems. The biggest issue I see is the handlebars templates used to generate the Anki fields. These templates rely on the current data format, so if the internal data structure is updated to be more consistent, this format would still need a way to be converted to the old format to provide backwards compatibility with Anki template generation.
However, in the long run, this is probably worth it. It's somewhat difficult to figure out what some of the logic in translator.js does due to this issue, as well as some confusing naming conventions (deinflections, definitions, definitions.definitions, expressions.expressions, etc.) Now that HTML templates are used for display content generation, it should also be easier to update the internal data format, as all of the presentation styling is handled using CSS now.
I'll look into a way to fix the tag bug in the short term, but as a longer term goal, a standardized data format may make development and debugging easier.
The text was updated successfully, but these errors were encountered: