meddl_translate
Translates German to Meddlfrängisch. If you don't know what that is, this is not for you.
Example:
There's also other examples available:
$ cargo run --example hello
$ cargo run --example long-text
Exceptions
It's possible to exclude words that should not be translated, e. g. "den" by adding it to the "ignored" array in the translation file:
"ignored":
To see it in action, run:
$ cargo run --example ignored
Translations file
A dictionary can be found in the src directory.
WebAssembly
The translate function is exported through wasm-bindgen when you build for wasm32-unknown-unknown.
Building
-
Install the WebAssembly target (once):
rustup target add wasm32-unknown-unknown -
Install wasm-pack (or
cargo install wasm-pack). -
From this repository’s root, build the JavaScript + WASM bundle:
wasm-pack build --target web --out-dir pkgThis writes
pkg/with the.wasmfile, a JS glue module, and apackage.json. Use--target bundlerinstead ofwebif you bundle with Vite, webpack, or similar.
Using it in a web project
Option A — ES modules (--target web)
Copy pkg/ into your site (or depend on the crate via a path/git dependency and run wasm-pack build in your pipeline). In a module script, load the WASM and call translate:
import init from './pkg/meddl_translate.js';
;
Serve the page over HTTP(S); opening file:// URLs usually breaks WASM fetch. Use any static server (e.g. npx serve) during development.
Option B — Bundler (--target bundler)
Build with wasm-pack build --target bundler --out-dir pkg, then import the same module from your bundled app:
import init from './pkg/meddl_translate.js';
await ;
;
Configure your bundler to treat .wasm as a WebAssembly asset if it does not already.