Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

udoprog/jpv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jpv

github docs.rs build status chat on discord

Japanese Dictionary by John-John Tedro

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.


Overview

Searching for english text
Search for Japanese words and phrases or English glossary.
Conjugations
Advanced word conjugator.
Image recognition using tesseract through the clipboard
Image recognition through the clipboard using tesseract (ocr feature).
Wildcard searching
Wildcard searching.

Building and Installing

Install dependencies for the platform you intend to build for:

  • For the ocr feature:
    • Fedora - sudo dnf install tesseract-devel

Install trunk and the wasm32 toolchain to build the UI:

cargo install trunk
rustup target add wasm32-unknown-unknown

Fedora

sudo dnf install openssl-devel git

For the ocr feature:

sudo dnf install gcc tesseract-devel leptonica-devel clang-devel

For the gnome feature, we make use of gio in order to launch a browser window which needs glib2:

sudo dnf install glib2-devel

MacOS

The OCR dependencies can be installed using homebrew

brew install tesseract leptonica

In 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.


Windows

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.

Additional language data


Building the project

After this, you can run the project directly in the project directory:

trunk build --release
cargo run --features bundle

Note: On Linux, you probably want to include the gnome feature for desktop integration.

There are scripts available to conveniently build and install packages for specific environments:

You can also the project manually, but this will lack any system integration like clipboard capture:

cargo install --path crates/jpv --features bundle,gnome

Configuring

After jpv has been installed, you must construct the dictionary file the project will use.

jpv build

After this, you can start the dictionary in the background with. This will also automatically open up the interface.

jpv service --background

Good morning!


Features

For rust features, we have the following:

  • The gnome feature enabled full GNOME desktop integration, which includes the dbus and ocr features. This is also necessary to use the GNOME extension to capture the clipboard.
  • The dbus feature 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 ocr feature provides image recognition for clipboard events where the mimetype is appropriate.
  • The mmap feature (Unix only) loads the database using memory maps.

Interface

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 hello can be used to inject a phrase into the dictionary for analysis (requires the dbus feature).

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.


Building and packing for Fedora GNOME

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/jpv

The generated rpm will be located in target/generate-rpm.

sudo npm -i target/generate-rpm/jpv-0.0.0-1.x86_64.rpm

Once 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.

Desktop entry


GNOME Extension

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:

Gnome extension

Once enabled, clipboard capture has to be enabled in the panel item.

Searching for english text
Extension button.
Conjugations
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

About

My personal Japanese dictionary based on JMdict

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •