Add support for custom dictionaries - #19
Open
Zenous07 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Adds support for registering custom dictionaries in
lithiumpatch, on top of the existing built-in ones (edgedict, webster1913). Users can now convert any dictionary they own into a simple JSON format and plug it into the build — no need to touch the core patching logic.This is implemented as a new
dict/custompackage that://go:embed.dict.Register(name, priority, parseFunc)API — the same mechanism the built-in dictionaries already use.main.go(_ "github.com/pgaskin/lithiumpatch/dict/custom") to activate.How to use it
dict.Entrystruct — each entry hasTerms,Name,MeaningGroups(withMeanings[].Textetc.), andSource. No changes were made todict.Entryitself..jsonfile indict/custom/.//go:embed+dict.Register(...)block for it indict/custom/custom.go— a couple of lines per dictionary.go run . app/Lithium_0.24.5.apk. The dictionary shows up in the reader's lookup feature alongside the built-in ones.Full details, including a worked StarDict conversion example and a CSV conversion example, are documented in the new "Custom Dictionaries" section added to the README.
Backward compatibility
This change is fully additive and backward-compatible:
dict/custom.custompackage, behavior is identical to the currentmasterbranch.Testing
Built and tested locally with
go run . app/Lithium_0.24.5.apk. Confirmed the custom dictionary registered viadict/customappears correctly in the app's word-lookup UI alongside the built-in dictionaries, with no regressions to existing dictionary behavior.