Skip to content

About

Language translation service for the Frostfire Forge MMO game engine.

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

frostfire-forge-language-service

To install dependencies:

bun install

Use from the game engine

This is a module, not a server. The game engine has this repository as a git submodule at src/language-service and calls it in its own process:

import { set_logger, start_translator, translate_text } from "../language-service/src/api";

set_logger({ info: log.info, warn: log.warn, error: log.error }); // optional, defaults to console
start_translator(); // optional: load the model now instead of with the first line

const { translated_text } = await translate_text({ source_language: "en", target_languages: ["es", "fr"], source_text: "where is the mine?" });

translate_text throws TranslationRequestError for a request it refuses (unknown language, missing or too long text) and a plain Error when the translator could not answer. Importing src/api.ts starts nothing. The Python environment below goes inside the submodule folder.

Translator

Translations come from the offline model in translator/, run on the CPU by a Python child process (translator/serve.py). It starts with the first translation (or with start_translator()), loads in a few seconds, and starts again with the next translation if it stops.

The game asks once per language for each chat line, all at the same time. Requests for the same line that arrive within a few milliseconds of each other are merged, and each language runs as its own batch in parallel (6 at once, 2 CPU threads each), so six languages take about as long as one.

  • translator/model/: the exported model (from Frostfire Translate's scripts/export.py)
  • translator/ffmt/: a copy of Frostfire Translate's inference code (ffmt/__init__.py, translator.py, chat.py, langid.py, names.py)

It needs Python 3 in .venv in this folder. Create it once:

python -m venv .venv
.venv/Scripts/python -m pip install -r translator/requirements.txt   # Linux/macOS: .venv/bin/python

The model's binary files (*.bin, *.npz, *.model) are stored with Git LFS, so run git lfs install once before cloning. To update the model, replace translator/model/ with Frostfire Translate's exports/latest/.

translate_text({ source_language: "en", target_languages: "es,fr,cn", source_text: "where is the mine?" }) gives translated_text as {"es": "...", "fr": "...", "cn": "..."}. Chinese is accepted as cn or zh.

To type check:

bun check

Model training data

The model in translator/model/ was trained from scratch by Frostfire Interactive. Its training data keeps its own licences and credits:

License

Free for noncommercial use under the PolyForm Noncommercial License 1.0.0. Every commercial use needs a paid commercial license from Frostfire Interactive. See LICENSING.md for which one applies to you.

Contributions are welcome and need a signed Contributor License Agreement; see CONTRIBUTING.md.

About

Language translation service for the Frostfire Forge MMO game engine.

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages