Skip to content

An open Cantonese dictionary for iOS and Android built with Flutter

License

Notifications You must be signed in to change notification settings

freestanding-binary/wordshk_app

 
 

Repository files navigation

wordshk

words.hk dictionary for Android and iOS

wordshk app logo

Download

Download on the App Store Get it on Google Play Get it on F-Droid

Build

Crate-Type

In your Cargo.toml, ensure the following crate-type is present:

[lib]
crate-type = ["staticlib", "cdylib"] # "staticlib" for iOS, "cdylib" for Android

SMTP Bug Reporting

We use the SMTP protocol to anonymously report bugs to the developers. If you wish to receive bug reports via email, add lib/smtp_credentials.dart with the following variables:

String host = 'YOUR SMTP HOST'; // eg: 'smtp.mailgun.org'
String username =
    'YOUR SMTP USERNAME'; // eg: '[email protected]';
String password = 'YOUR SMTP PASSWORD';
String recipient = 'YOUR DEVELOPER EMAIL ADDRESS'; // eg: '[email protected]'

If you are not interested in the bug reports, add lib/smtp_credentials.dart with following content:

// Turns off SMTP bug reporting
String host = '';
String username = '';
String password = '';
String recipient = '';

Rust for Android

Install Android NDK in Android Studio:

Android Studio > Tools > SDK Manager > SDK Tools > NDK (Side by side)

Install Cargo NDK for Android:

cargo install cargo-ndk --version ^2.7.0

See here for potential caveats.

Download the Android targets for Rust:

rustup target add armv7-linux-androideabi
rustup target add aarch64-linux-android

Rust for iOS

Install Cargo lip for iOS:

cargo install cargo-lipo

Download the ios targets for Rust:

rustup target add x86_64-apple-ios
rustup target add aarch64-apple-ios

Install Flutter Rust Bridge

Until this issue is fixed, we need to use an older version of flutter_rust_bridge_codegen.

cargo install flutter_rust_bridge_codegen --version=1.34.2

Install ffigen

flutter pub add --dev ffigen && flutter pub add ffi
dart pub global activate ffigen

Build Rust for iOS and Android

Give the build script execution permission:

chmod +x ./build_rust.sh

Run the build script to build Rust for Android and iOS:

./build_rust.sh

If you are building this app on an M1 mac, you may need to run the following line before running flutter run:

sudo gem uninstall ffi && sudo gem install ffi -- --enable-libffi-alloc

Updating Flutter Rust Bridge

  1. Update the version of flutter_rust_bridge in pubspec.yaml
  2. Update the version of ffigen in pubspec.yaml if not updated automatically
  3. Update the version of flutter_rust_bridge in rust/Cargo.toml to the same version as (1)
  4. Run dart pub global activate ffigen to activate updated ffigen
  5. Run ./build_rust.sh and fix any compiler error
  6. Run flutter clean to clean build files
  7. Restart flutter using flutter run

How Does the Build Script Work?

flutter_rust_bridge

The build script first generate a glue code that bridges Rust and Dart code using flutter_rust_bridge.

iOS

The build script then generate a release version of the iOS binary:

cargo lipo --release && cp target/universal/debug/libwordshk_api.a ../ios/Runner

If the release build is too slow, you can replace the above line in the build script with this instruction for running a debug build:

cargo lipo && cp target/universal/debug/libwordshk_api.a ../ios/Runner

Android

The build script then generate a release version of the Android binary.

cargo ndk -o ../android/app/src/main/jniLibs build --release

If the release build is too slow, you can replace the above line in the build script with this instruction for running a debug build:

cargo ndk -o ../android/app/src/main/jniLibs build

See this tutorial to set up Android.

Generate App Store images

Run snapshot:

bundle exec fastlane snapshot --configuration "Release" --stop_after_first_error

Reset all simulators in case of errors during snapshot:

bundle exec fastlane fastlane snapshot reset_simulators

Normalize jyutping syllable audios

  1. Open Adobe Audition, run the "Match Loudness" with these settings:

    • ITU-R BS.1770-3 Loudness
    • Target Loudness: -16 LUFS
    • Tolerance: 2 LU
    • Max True Peak Level: -2 dBTP
    • Look-ahead Time: 12ms
    • Release Time: 200ms
  2. Export the files with matched loudness With export settings as follows:

    • Format MP3
    • Sample Type: Same as source
    • Format settings: MP3 24 Kbps CBR (Constant type)
  3. Change directory into assets/jyutping_female or assets/jyutping_male.

  4. Run process_audios.sh. This script does three things:

    1. Trim silence at the beginning and end of all mp3 files
    2. Pad the end of jap6sing1 syllables so they are not too short
    3. Peak normalize jap6sing1 syllables to make they as loud as other syllables

TODO

  • Show jyutping help before search or suggestions for fix during search
  • Add spell checker suggestion to english search
  • Use word match percent instead of direct lookup for phrases with >1 words
  • Test multi-language support for entries
  • Add auto language detection for searches
  • Show possible jyutping when search result is not found.
  • Offer option to show entries in simplified
  • Wait for fast2s to merge my 乾/干 PR and update to use the new version
  • Make text selection in entries smoother
  • Fix ruby positioning in Entry M/jam's : "好M唔M,M套?"
  • Customize keyboard bar for iOS and Android using https://pub.dev/packages/keyboard_actions
  • Cut off audio when switching audio or exiting page
  • Add Yale romanization support
  • Convert traditional characters in links of eng explanation to simplified
  • Convert traditional characters in result not found to simplified

Legal

Software: Copyright (C) 2022 Xiang Li, licensed under the MIT license. Dictionary: Copyright (C) 2014-2022 Hong Kong Lexicography Limited.

"words.hk", "wordshk", "粵典" are trade names of Hong Kong Lexicography Limited. Permission by Hong Kong Lexicography Limited must be obtained to promote or distribute materials containing these names. In particular, notwithstanding any permission (if applicable) to redistribute the source code of this project and/or its derivative works by the copyright owner(s), unless you obtain explicit permission from Hong Kong Lexicography Limited, you are required to remove all mentions of "words.hk", "wordshk", "粵典" from your redistributions.

The dictionary contents published by words.hk is copyrighted by Hong Kong Lexicography Limited. You may be eligible to obtain a license from https://words.hk/base/hoifong/

About

An open Cantonese dictionary for iOS and Android built with Flutter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 84.2%
  • Rust 6.9%
  • Swift 4.2%
  • Ruby 1.9%
  • C 0.8%
  • HTML 0.8%
  • Other 1.2%