Nodes/ComfyUI_Lam/中文或其他翻译
ComfyUI Node

中文或其他翻译

Translate prompts to 11 languages locally, no API key

By yanlang0123·Created 2 years ago·Updated 11 days ago· 77
中文或其他翻译
  • textList
  • STRING
  • LIST
text_trans
model_type
to_lang

ZhPromptTranslator (中文或其他翻译, "Chinese or other translation") is a fully local translation node built on Meta's NLLB-200 models. You feed it text, pick a target language, and get a translation back - no API key, no network call at inference time, no per-character billing. It's aimed squarely at the pack's Chinese-speaking audience, but it's useful to anyone who wants to translate prompts or batch text without phoning home to a translation service.

How it works

Under the hood it loads facebook/nllb-200-distilled-600M or the 1.3B variant - NLLB-200 is Meta's "No Language Left Behind" model family, which covers 200 languages and was trained specifically for translation. Translation happens by setting the model's forced_bos_token_id to the target language's token (English is eng_Latn, Chinese is zho_Hans, and so on) and running a standard seq2seq generation. It's a real model, not a lookup table.

The inputs that matter:

  • text_trans - multiline STRING, the text to translate.
  • model_type - 600M or 1.3B. The 600M is faster and lighter; the 1.3B is noticeably more accurate on tricky phrasing. For short prompts, 600M is honestly fine.
  • to_lang - a dropdown of 11 languages: English, simplified and traditional Chinese, Spanish, French, German, Japanese, Korean, Russian, Arabic, and Portuguese.
  • textList - optional LIST. Every entry gets translated too, and comes back as a LIST.

Outputs are a STRING (the translated single text) and a LIST (the translated batch). The classic use: write your prompt in Chinese, translate it to English, and feed the result into CLIPTextEncode - SDXL and its fine-tunes want their tag vocabulary in English, and this gives you a fluent translation rather than a keyword-for-keyword garble.

The download is the real cost

On first use the node auto-downloads the model you chose from the HF mirror (hf-mirror.com) into the pack's models/ folder. That's ~1.2GB for the 600M and ~2.5GB for the 1.3B - it's a one-time hit, but it will look like the workflow is frozen while it happens, and it's the kind of thing you want to trigger on purpose, not discover mid-run. Note the mirror is China-facing; if you're outside China and the download crawls, pre-download the model from huggingface.co/facebook/nllb-200-distilled-<size> into models/nllb-200-distilled-<size> and the node will find it.

The honest limitation

There's a hard cap hiding in the code: the generation call uses max_length=30, so any single translation is truncated around 30 tokens. Long paragraphs get cut off mid-sentence. For SDXL prompts this is rarely a problem - most prompts fit comfortably - but don't feed this node a full script and expect it back intact. Keep inputs short, or split them.

Installing it

Part of the ComfyUI_Lam pack - install via ComfyUI Manager (search "ComfyUI_Lam") or:

cd ComfyUI/custom_nodes
git clone https://github.com/yanlang0123/ComfyUI_Lam

Restart ComfyUI. This node specifically needs the transformers library (in the pack's requirements.txt) - on a manual install, pip install transformers is the dependency that matters, plus the model download above.

Troubleshooting

"模型下载失败" - the auto-download failed; check connectivity to hf-mirror.com and try again, or pre-download manually as described above. Truncated output - that's the 30-token cap, split the text. And if translation quality on a to_lang option feels weak, switch from 600M to 1.3B; the difference shows up most on the less-common target languages.

Categorylam

Inputs (4)

NameTypeDefaultDescription
text_transSTRING
model_typeCOMBO2 options: 600M, 1.3B
to_langCOMBO11 options: 英语, 中文(简体), 中文(繁体), 西班牙语, 法语, 德语, +5
textListoptLIST

Outputs (2)

NameTypeDescription
STRINGSTRING
LISTLIST