Skip to content

About

Tool to generate Project Zomboid translations using Google translate API calls.

Resources

Stars

5 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

pz-translator 3.0

Automated batch-capable Project Zomboid B42 translations.

original concept by Poltergeist

PZ Translation .txt to .json converter script - MassCraxx, tweaked by SimKDT


How to Use (Simple)

  • Run the pzTranslate.exe (utilizes PyInstaller built PyQt GUI)
  • Select any directory to process.
    • Any Translate subdirectories will be processed.
    • Note: Google Translator has a 200k character daily limit.
  • Select which Languages you would like files to be generated for.
    • Note: Selecting no languages will enable all languages.
  • Optionally enable Overwrite to re-translate keys that already exist in target files.
    • By default, existing translated keys are preserved and only missing ones are filled in.

B42 Behaviour

The tool targets B42 Translate directories and always outputs .json files. Both .json and old-format .txt source files are supported as input.

Source files Output
.json .json (UTF-8)
.txt (pre-42.15 format) .json (UTF-8) — converted automatically

Old pre-42.15 .txt translation files are parsed and written out as properly formatted B42.15 .json files as a natural part of the translation process.

Developed Using

Note: You can also download these programs if you wish to modify any stage of the translation process.

Dependency Purpose
Python 3.10+ Runs the translation and GUI scripts.
deep_translator 1.11.4+ Handles automated language translation via Google Translate.
PyQt5 5.15.11+ Provides the graphical user interface (GUI).
PyInstaller 6.11.1+ Packages the Python script into a standalone executable.

How to Use (Complex)

In any CLI (cmd), run repository/pz-translator/translate.py with any relative path to any directory you want processed.

Parameters:

Parameter Description
<directory> Root directory to process (required)
-source <code> Source language code (default: EN)
-languages <codes> Space-separated language codes to translate to (default: all)
-overwrite Re-translate keys that already exist in target files

Example Parameters:

For a singular sub-mod within a mods folder:

py translate.py "\Workshop\<your mod>\Contents\mods\<your mod>\"

For a mod along with any sub-mods:

py translate.py "\Workshop\<your mod>\"

For all mods, specific languages only:

py translate.py "\Workshop\" -languages DE FR RU

For all mods, overwriting all existing translations:

py translate.py "\Workshop\" -overwrite
  • The script will parse through every subdirectory to find any \Translate directories.
  • If you install PyQt5 you can also run TranslateGUI.py directly.

IntelliJ

Go to the translate.py file and select to edit configurations.

image

Once in the configurations menu, enter in a relative path you want processed as the parameter.

image


Command Line

Example for Windows — you can also write this into a .cmd file for a shortcut.

py "repository/pz-translator/translate.py" "relative-path to translate"

VSCode Task

You can add a task like this to run the script. This will target the workspaceFolder for translation.

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Translate Project",
      "type": "shell",
      "command": "py",
      "args": [ "repository/pz-translator/translate.py", "${workspaceFolder}" ],
      "group": "none",
      "presentation": {
        "reveal": "always",
        "panel": "new"
      }
    }
  ]
}

See https://go.microsoft.com/fwlink/?LinkId=733558 for the documentation about the tasks.json format


Text Translator

Deep translator supports different translation backends. More information at: https://pypi.org/project/deep-translator/

WARNING: By default the script skips keys that already exist in target files. Use -overwrite to replace them. If you are not using version control, keep backups!

About

Tool to generate Project Zomboid translations using Google translate API calls.

Resources

Stars

5 stars

Watchers

0 watching

Forks

Contributors

Languages