Welcome to my Japanese dictionary project!
This used to be a personal project of mine, but I have now spent enough time and effort on it that I think it might be useful for others.
|
Search for Japanese words and phrases or English glossary.
|
Advanced word conjugator.
|
|
Image recognition through the clipboard using tesseract (
ocr feature). |
Wildcard searching.
|
Install dependencies for the platform you intend to build for:
- For the
ocrfeature:Fedora-sudo dnf install tesseract-devel
Install trunk and the wasm32 toolchain to build the UI:
cargo install trunk
rustup target add wasm32-unknown-unknownsudo dnf install openssl-devel gitFor the ocr feature:
sudo dnf install gcc tesseract-devel leptonica-devel clang-develFor the gnome feature, we make use of gio in order to launch a browser
window which needs glib2:
sudo dnf install glib2-develThe OCR dependencies can be installed using homebrew
brew install tesseract leptonicaIn the case that brew does not link the pkg-config files, you may need to add these libraries' path to the PKG_CONFIG_PATH environment variable.
The OCR feature depends on tesseract which is dynamically loaded.
You'll have to install tesseract from the UB-Mannheim/tesseract project.
Make sure to install the "Japanese" and "Japanese (vertical)" under
Additional language data.
After this, you can run the project directly in the project directory:
trunk build --release
cargo run --features bundleNote: On Linux, you probably want to include the
gnomefeature for desktop integration.
There are scripts available to conveniently build and install packages for specific environments:
- tools/install-fedora to build and install for GNOME on Fedora.
You can also the project manually, but this will lack any system integration like clipboard capture:
cargo install --path crates/jpv --features bundle,gnomeAfter jpv has been installed, you must construct the dictionary file the
project will use.
jpv buildAfter this, you can start the dictionary in the background with. This will also automatically open up the interface.
jpv service --backgroundFor rust features, we have the following:
- The
gnomefeature enabled full GNOME desktop integration, which includes thedbusandocrfeatures. This is also necessary to use the GNOME extension to capture the clipboard. - The
dbusfeature provides the ability for the service to interact with D-Bus. Which is necessary for extensions to communicate with it and to perform D-Bus activation. - The
ocrfeature provides image recognition for clipboard events where the mimetype is appropriate. - The
mmapfeature (Unix only) loads the database using memory maps.
The dictionary is primarily interacted with using the jpv tools. It has a
comprehensive help section you can get through jpv --help, but some of the
more notable features are:
jpv cli <query>can be used to perform commandline queries.jpv send-clipboard --type text/plain hellocan be used to inject a phrase into the dictionary for analysis (requires thedbusfeature).
All relevant tools that interact with the background service rely on features such as D-Bus activation, which will ensure that a background service is up and running as needed.
To build an rpm package which is suitable for Fedora GNOME, you can do the following:
cargo build --release -p jpv --features bundle,gnome
cargo generate-rpm -p crates/jpvThe generated rpm will be located in target/generate-rpm.
sudo npm -i target/generate-rpm/jpv-0.0.0-1.x86_64.rpmOnce complete, this installs a desktop entry you can use to start the dictionary in the background. Starting the application will open up the browser UI.
Note that you still need to build the database before it can be used.
Since GNOME and Wayland desktop environments in general currently do not have any facilities to generically capture the clipboard we must rely on extensions.
To enable the Japanese Dictionary extension for gnome, start the extensions manager after installing the package:
Once enabled, clipboard capture has to be enabled in the panel item.
|
Extension button.
|
Clipboard capture enabled.
|
Note: while clipboard capture is running the extension icon will be red. Only enable it while it's in use since there are currently no security mechanisms in place other than your local system. Any application could pretend to be a dictionary application and capture the clipboard.
Clipboard capture is governed by the capture-clipboard-enabled setting:
> gsettings get se.tedro.japanese-dictionary.plugins capture-clipboard-enabled
true
> gsettings set se.tedro.japanese-dictionary.plugins capture-clipboard-enabled false