DEV Community

RK Riad Khan
RK Riad Khan

Posted on

I Built a Zero-Dependency English Translator (Python, Stdlib Only)

Why
Most "translator" projects lean on external APIs or heavyweight
dependencies. I wanted to see how far I could get with nothing but the
Python standard library — and have something genuinely usable at the
end. The result: emtranslator, a dictionary-based English-to-Monsu
translator with a CLI and an embeddable API.
The Monsu language
Monsu is fictional, invented for this project. Its vocabulary lives in
a 90-entry dictionary mapping English words to monsu_1 through
monsu_90.
Design highlights

  • Tokenizing is one regex: (\w+)|([^\w\s])|(\s+). Words get looked up; punctuation and whitespace pass through untouched.
  • Casing is preserved on the translated output — "Hello" → "Monsu_1".
  • Unknown words are kept as-is and reported via missing_words().
  • Reverse mode inverts the dictionary, so Monsu → English works out of the box.
  • The user dictionary is a flat TOML file at ~/.config/neostore/emtranslator/config.toml, read and written by a hand-rolled parser (because zero deps means zero deps). CLI quick start
emtrans "Hello, world!"          # Monsu_1, monsu_2!
emtrans --reverse "monsu_1"      # hello
emtrans add hi monsu_91          # persist a new word
emtrans --json "hello zebra"     # shows missing words
Enter fullscreen mode Exit fullscreen mode

Library quick start

from emtranslator import Translator
t = Translator()
t.translate("Hello world")       # Monsu_1 monsu_2
t.add_word("hola", "monsu_91")
Enter fullscreen mode Exit fullscreen mode

Testing & tooling

  • 32 pytest tests covering the API and the CLI end-to-end.
  • Full docs (mkdocs), a Docker image, and a logo. Building it dependency-free was a fun constraint — it makes you reach for the standard library instead of pulling in a package for every small problem. Worth trying on your next side project. → https://github.com/rkriad585/EMTranslator

Top comments (0)