Skip to content

About

Local machine translation app for Windows and macOS. Translate text offline with NLLB-200 and other CTranslate2 models, on the CPU or an NVIDIA GPU.

Topics

Resources

Stars

105 stars

Watchers

3 watching

Forks

Repository files navigation

DesktopTranslator DesktopTranslator Support this project on Ko-fi

DesktopTranslator

DesktopTranslator translates text and documents on your own computer. Nothing is sent to a server, and no internet connection is needed once you have a model. It runs CTranslate2 models with SentencePiece, including the multilingual NLLB-200 (200 languages) and M2M-100 (100 languages) and bilingual models such as OPUS-MT, including Argos Translate packages.

  • The source language is detected, and each sentence is translated on its own, keeping your paragraphs
  • The translation appears as it is made, and you can cancel and keep what is done
  • Long files are translated in the background with File menu > Translate Document...
  • Right-to-left languages such as Arabic are edited right to left
  • The app follows the dark mode of your system
  • Models can run on an NVIDIA GPU, chosen in Edit menu > Preferences...
  • Installers for Windows and macOS, or run it from source

DesktopTranslator

Table of contents

  1. Download DesktopTranslator
  2. Using DesktopTranslator
  3. Run from Source
  4. Translation Models
  5. [Optional] Build Stand-alone Executable
  6. Licenses
  7. References

Download DesktopTranslator

DesktopTranslator DesktopTranslator

The installers are not signed. On macOS (Apple Silicon), open System Settings > Privacy & Security and click Open Anyway the first time you launch the app. On Windows, SmartScreen may show a warning; click More info > Run anyway.

Using DesktopTranslator

At the first start, the app offers to download the NLLB-200 distilled 600M model (582 MB, CC-BY-NC 4.0). You can also open a model you already have.

  1. Choose Translate menu > Open Model... (Ctrl/Cmd + M) and select the folder of a translation model. The SentencePiece model is found in the same folder; if there are several, you are asked which one to use.
  2. For a multilingual model, select the target language. The source language is detected, and the Source header shows it with the number of words. To choose the source language yourself, use the From list. The ⇄ button swaps the two languages.
  3. Type or paste text on the left, or open a file with File menu > Open Text... (plain text files only; use Reopen Text with Encoding... if the characters look wrong). You can also drop a text file on the source pane.
  4. Click Translate. The translation appears as it is made, with the time left, and you can click Cancel to stop; the part that is done is kept. Use Copy or File menu > Save Translation... when it is finished.

Right-to-left languages such as Arabic, Persian, Urdu, and Hebrew are displayed and edited right to left. The app follows the dark mode of your system. Use the View menu to change the text size.

Preferences (Edit menu > Preferences...)

Option Effect
Translation quality Fast (beam size 2), Balanced (3, the default), or Thorough (5, slower)
Speed on the CPU Standard (8 sentences per batch), Faster (16), Fastest (32), or Automatic, which makes each batch as large as the speed of the computer allows in about 5 seconds. In our tests, Fastest was about 1.2 to 1.5 times as fast as Standard on five machines. Progress and Cancel update less often with larger batches, and with Automatic the same text can be translated a little differently from one run to another
Run on The CPU, or an NVIDIA GPU when one is found. It is tested on an RTX 5090 with Linux and on an RTX 5060 with Windows. CTranslate2 needs the NVIDIA driver and the CUDA 12 libraries to use a GPU, so install CUDA Toolkit 12.8 or 12.9 from the CUDA Toolkit Archive. CUDA 13 does not have these libraries, but it can stay installed next to CUDA 12. If the option does not appear, CTranslate2 found no usable GPU, because the computer has none or the driver is missing. If the CUDA 12 libraries are missing, the option is disabled and its tooltip says what to install. Please report what you see in an issue
Avoid repeated words A repetition penalty of 1.2, off by default because translations scored higher without it in tests (tests/repetition_penalty_eval.py)
Join lines inside a paragraph For text from PDF files or OCR, where lines break in the middle of a sentence
Remember the last model and target language Opens the same model the next time
Load the last model at start Loads the model when the app starts, so the first translation does not wait for it

Long texts. The text area accepts up to 20,000 words. For a longer text, use File menu > Translate Document... (Ctrl/Cmd + Shift + O), which translates a plain text file into another file in the background, with progress and the time left. If you cancel, the translated part is saved. PDF and Word files are not supported; save them as plain text first.

Each sentence is translated on its own, and a sentence that repeats is translated once and reused, so it is translated the same way everywhere.

Updates. Choose Help menu > Check for Updates... to see whether a newer version is available. This asks GitHub for the latest release, and the app does it only when you choose it. The app also connects to the internet when you download a model. It does not update itself.

Reporting an issue. Choose Help menu > Copy Diagnostic Info..., check the text, copy it, and paste it into a new issue. The report includes the versions, the hardware, the settings, the name of the model folder, and the last error. It does not include your text, file names, or paths. Check it before you share it.

Memory. Larger models need more memory. The app warns you if the computer may not have enough free memory for the model you open.

Run from Source

You need Python 3.11 or later.

git clone https://github.com/ymoslem/DesktopTranslator.git
cd DesktopTranslator
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python qt_app.py

On Windows, activate the virtual environment with .venv\Scripts\activate.

Translation Models

DesktopTranslator supports CTranslate2 models with their SentencePiece subwording models (you need both). If you have a model for OpenNMT-py, OpenNMT-tf, or FairSeq, you can convert it to the CTranslate2 format.

NLLB-200 Multilingual Model

DesktopTranslator supports NLLB-200 (NLLB Team et al., 2022), a multilingual model that can translate between 200 languages. Note that Meta released the NLLB-200 models under the CC-BY-NC 4.0 license, which does not allow commercial use. The int8 files run on the CPU, and on an NVIDIA GPU, where the app runs them as float16. To use them, please follow these steps:

  1. Download one of the NLLB-200 models, converted to the CTranslate2 format with int8 quantization:
    a. NLLB-200 distilled 600M-parameter model; the smallest and fastest, and good for most uses. You can also use the Help menu > Get Models...; or
    b. NLLB-200 distilled 1.3B-parameter model; slower and needs more memory, but sometimes more accurate. You can also use the Help menu > Get Models...; or
    c. NLLB-200 3.3B-parameter model (3.1 GB); the largest, slowest, and needs the most memory. This archive does not include a SentencePiece model, so also download NLLB-200_sentencepiece.model.
  2. Extract the *.zip archive. (With Get Models..., the 600M and 1.3B models download and open inside the app, so you can skip steps 2 and 3.)
  3. In DesktopTranslator, click the Open Model... button, and select the model folder, for example nllb-200-distilled-600M-int8. Its sentencepiece.model is used automatically. For the 3.3B model, when you are asked, select the NLLB-200_sentencepiece.model file you downloaded.
  4. From the To list, select the language to which you want to translate. You can type to search the list. Language varieties are grouped, for example "Arabic (Modern Standard)" and "Arabic (Egyptian)". The source language is detected automatically; to choose it yourself, use the From list.
  5. Click the Translate button. You can click Cancel to stop a long translation.

M2M-100 Multilingual Model

DesktopTranslator also supports M2M-100 (Fan et al., 2020), a multilingual model that can translate between 100 languages.

To use M2M-100 models in DesktopTranslator, please follow these steps:

  1. Download one of the M2M-100 models, converted to the CTranslate2 format:
    a. M2M-100 418M-parameter model; smaller and faster, but sometimes less accurate; or
    b. M2M-100 1.2B-parameter model; bigger and somehow slower, but sometimes more accurate.
  2. Extract the *.zip arhieve of the model you downloaded.
  3. In DesktopTranslator, click the Open Model... button, and select the m2m100_418m or m2m100_12b folder. Its sentencepiece.model is used automatically.
  4. From the To list, select the language to which you want to translate. The source language is detected, or you can select it in the From list.
  5. In the left text area, type some text in any language or use the File menu > Open Text... to open a *.txt file.
  6. Click the Translate button.

OPUS Models

OPUS models (Tatoeba-Challenge) can be used and they can be more efficient. As of now, only bilingual models are supported by DesktopTranslator. Note: You must convert an OPUS model to the CTranslate2 format first. Example command:

ct2-opus-mt-converter --model_dir opus_model_dir --output_dir ct2_model_dir --quantization int8

The source and target tokenization SentencePiece models can be found in the same archive of the downloaded model.

Argos Translate Models

Argos Translate packages contain CTranslate2 models, each for one language direction. You can find them in the Argos Translate package index. DesktopTranslator does not distribute these models, and each package has its own license, so read the README inside a package before you use it.

  1. Download a package, a file with the extension .argosmodel, from the index.
  2. In DesktopTranslator, choose Translate menu > Open Argos Package..., or drop the file on the left text area. The app extracts the model into its models folder and opens it.
  3. The From and To boxes show the two languages of the package. Type or open your text, and click Translate.

Quality differs between packages and language pairs, so try a package on your own texts first. To extract a package yourself, rename the file to .zip, unzip it, and open its model folder with Open Model... in DesktopTranslator. The SentencePiece model is found in the folder above it.

French-to-English Generic Model

If you would like a small model to try the app, you can download my French-to-English generic model here.

  1. Unzip the fren.zip archive of the French-to-English generic model you just downloaded. It has two folders, ct2_model for the CTranslate2 model and sp_model for the SentencePiece subwording models of French (source) and English (target).
  2. In DesktopTranslator, click the Open Model... button, and select the ct2_model folder.
  3. When you are asked for the SentencePiece model, navigate to the sp_model folder, and select fr.model.
  4. In the left text area, type some text in French or use the File menu > Open Text... to open a *.txt file.
  5. Click the Translate button. The default translation quality is "Balanced"; you can change it in the Preferences.

[Optional] Build Stand-alone Executable

The installers are built automatically with the GitHub Actions workflow, which uses PyInstaller on both platforms, and installer.nsi for the Windows installer. To build them yourself, you can follow the steps below.

Build Windows Installer

If you want to adjust the code and then build an installer yourself, you can follow these steps:

  1. Install the requirements and PyInstaller, preferably in a virtual environment.
pip3 install -r requirements.txt pyinstaller==6.22.3
  1. Run PyInstaller. The data folders and the --collect-data options are needed, otherwise some languages, such as Turkish, fail to be split into sentences.
pyinstaller -y --windowed --name DesktopTranslator --add-data "utils;utils" --add-data "img/icon.png;img" --add-data "NOTICE.md;." --icon img/icon.png --collect-data sentence_splitter --collect-data pysbd --collect-all ctranslate2 qt_app.py
  1. Try the *.exe file under "dist\DesktopTranslator" to make sure it works.
  2. Download and install NSIS, and then create the installer with the script installer.nsi. It installs the app to "Program Files", and adds Start menu and Desktop shortcuts and an uninstaller.
makensis /DVERSION=0.4.6 installer.nsi

If you prefer to create the installer with the NSIS graphical interface, you can follow these steps instead of step 4:

  1. Compress the "DesktopTranslator" folder under "dist" into a *.zip archive.
  2. Launch NSIS, click Installer based on a .ZIP file, and then click Open to locate the *.zip archive you have just created.
  3. If you want to make the files installed (extracted) to the “Program Files” of the target user, in the Default Folder enter $PROGRAMFILES
  4. If you want to add a shortcut to the internal *.exe file on the Desktop after installation, you can add something like this to the file “Modern.nsh” located at: "C:\Program Files\NSIS\Contrib\zip2exe". Depending on your OS, the path could be at “Program Files (x86)”. Note that the EXE file path should be consistent with the path you selected under NSIS’s “Default Folder” drop-down menu, the folder name, and the EXE file name.
Section "Desktop Shortcut" SectionX
    SetShellVarContext current
    CreateShortCut "$DESKTOP\DesktopTranslator.lnk" "$PROGRAMFILES\DesktopTranslator\DesktopTranslator.exe"
SectionEnd

If you get a permission error while trying to save the edited version of “Modern.nsh”, right-click your text editor (e.g. Notepad), and select "Run as administrator". Then, copy the contents of the file into a new file, and save it to the original location.
5. Finally, click the NSIS Generate button, which will create the *.exe installer that can be shipped to other Windows machines, without the need to install any extra requirements. 6. After installation, if you applied the shortcut step, you should find an icon on the Desktop. To uninstall, you can simply remove the app folder from "Program Files". For more NSIS options, check this example.

Build macOS App

  1. Install the requirements and PyInstaller, preferably in a virtual environment.
pip3 install -r requirements.txt pyinstaller==6.22.3
  1. Run PyInstaller. This creates "dist/DesktopTranslator.app", for the type of Mac you are using.
pyinstaller -y --windowed --name DesktopTranslator --add-data "utils:utils" --add-data "img/icon.png:img" --add-data "NOTICE.md:." --icon img/icon-macos.png --collect-data sentence_splitter --collect-data pysbd --collect-all ctranslate2 qt_app.py
  1. To share the app, compress it into a *.zip archive.
ditto -c -k --keepParent dist/DesktopTranslator.app DesktopTranslator_macOS.zip

The app is not signed, so on another Mac, users need to click Open Anyway in System Settings > Privacy & Security the first time.

Licenses

DesktopTranslator is released under the MIT License. See NOTICE.md for the licenses of the software, the language identification model, and the translation models it uses.

References

About

Local machine translation app for Windows and macOS. Translate text offline with NLLB-200 and other CTranslate2 models, on the CPU or an NVIDIA GPU.

Topics

Resources

Stars

105 stars

Watchers

3 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages