Hi! I have used Google translate web API many times in my java applications for dynamic translation into different languages (e.g printing a receipt in Hindi,Urdu or French Language.) But now I want an API or Jar file to translate text to different languages Offline. I have searched a lot on internet but all the answers redirected me to online APIs. But I want translation in offline mode. My program will need to translate dynamically in different languages.I myself don't now which words will my client will need to translate. So I want a dynamic functionality(offline). Please direct me to a solution. I will be thankful to you.

Dani AI

Generated

A short, practical follow-up to the thread (notes for and others who land here later).

You tried Apertium (as pointed out) and hit two limits: a Windows/runtime install issue and no reliable English↔Urdu pair for your needs. For a dynamic, offline Java app there are two pragmatic paths that avoid the online Google API: run a small local translation server you call from Java, or run a converted NMT model inside the JVM. The server route is the quickest to try; the in-process route gives tighter integration and lower latency once set up. Argos Translate (models) and LibreTranslate (self-hosted REST API). (github.com)

Try this if you want the fastest working solution:

  • Launch LibreTranslate (Docker or pip) on the same host, update/download models (Urdu was added to the Argos/LibreTranslate index). Then call the local POST /translate endpoint from Java (HttpClient/HttpURLConnection) and cache responses for repeated strings (receipts/templates). This gives offline operation with minimal Java work. [LibreTranslate docs / community notes on Urdu models]. (github.com)

If you need a pure-Java, in-process solution (no local HTTP server): use a prebuilt OPUS/Marian model (Helsinki-NLP opus-mt en↔ur), convert/export it to ONNX or TorchScript, then run it with ONNX Runtime for Java or with the Deep Java Library (DJL). That keeps everything inside your JVM and lets you optimize/quantize for CPU. Expect modest quality for low-resource pairs and test against your real texts. See the Helsinki-NLP opus-mt en-ur model and runtime docs. (huggingface.co)

Practical tips: pre-translate templates and product labels (very small phrasebook), cache results, test quality for Urdu on a small sample, and prefer the LibreTranslate/Docker route to validate requirements before investing in model conversion and JVM inference.

Recommended Answers

All 3 Replies

Keeping in mind all the prior discussions about this I will not duplicate that here.

In short, look at "Offline, Desktop" at https://wiki.apertium.org/wiki/Installation

commented: apertium has two problems. I ran it and downloaded one language pair. After that when I clicked on Run button, following error occured: +3

Thanks brother. You link did not solved my problem yet. I faced two problems:
1-) I ran it and downloaded one language pair. After that when I clicked on Run button, following error occured:

'apertium-destxt' is not recognized as an internal or external command,
operable program or batch file.

And second problem is that Apertium has no language pair English to Urdu. which i need at the moment.
What other possibilty I can try?

The search continues. But when you get an error you head to the source which in this case is apertium.org

Next, consider what other companies do.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.