Nodes/ComfyUI-MakkiTools/translators(mki-多语言翻译)
ComfyUI Node

translators(mki-多语言翻译)

Translate Prompts With 39 Free Services and Zero API Keys

By MakkiShizu·Created about a year ago·Updated 7 months ago· 9
translators(mki-多语言翻译)
    • STRING
    query_text
    translatoralibaba
    from_languageauto
    to_languageenglish(en)
    if_use_preaccelerationfalse

    Ever wanted to run your English prompt through Japanese or Chinese because the model you're using visibly prefers its native language - or translate a model card's recommended tags into something you can actually read? That's this node. translators(mki-多语言翻译) wraps the Python translators library, which drives dozens of free online translation services - Google, Bing, DeepL, Baidu, Alibaba and more - with zero API keys and zero accounts. The name is a small lie in the good way: it doesn't call one API, it keeps an array of them to fall back on.

    Why you'd reach for it. Prompt translation is a genuinely common workflow, not a gimmick. The KB's prompt-engineering essay notes the community increasingly routes natural-language intents through translation on the fly; this is that idea done cheaply, locally, and without an LLM API bill. You wire the output STRING straight into a CLIP Text Encode node and get a prompt your model actually groks. It's equally handy for translating negative prompts or dataset captions before batch runs.

    How it works. The node sets the translators_default_region environment variable to EN, then calls the library's translate_text() on a background thread with a 10-second timeout. With from_language set to auto the service detects the source language itself. Each of the 39 services speaks a slightly different dialect of language codes, so the pack ships a mapping that normalizes codes per translator - which is why the dropdowns show "english(en)" style entries instead of raw codes. The if_use_preacceleration toggle runs the library's preaccelerate_and_speedtest() once per node instance: it pre-fetches the cookies and tokens a service wants, making later calls faster at the cost of a slow first run.

    The inputs that matter:

    • query_text - the text to translate (multiline).
    • translator - one of 39 services; the default is alibaba, and if a service starts rate-limiting you, switch to Google or Bing and it usually just works.
    • from_language (auto + 112) and to_language (112, default English).
    • if_use_preacceleration - worth flipping on if you're doing many calls in a row.

    The output is a single STRING with the translated text.

    Gotchas, and they're real ones. This is a network node; the README's entire requirement is that your connection works. If a service hangs, the 10-second timeout kicks in and you get your original text back unchanged - the node logs a warning to the console, so check there before assuming translation ran. Free services rate-limit aggressively and some block datacenter IPs, so "it stopped translating" almost always means "switch translator," not "restart ComfyUI." If a service errors with Unsupported or same, the node falls back to returning your input text - usually a sign the language pair isn't supported by that particular service.

    Install. The pack's requirements.txt pulls in translators>=6.0.0, langdetect, and sentencepiece:

    cd ComfyUI/custom_nodes
    git clone https://github.com/MakkiShizu/ComfyUI-MakkiTools
    cd ComfyUI-MakkiTools
    ..\..\..\python_embeded\python.exe -m pip install -r requirements.txt   # Windows portable
    pip install -r requirements.txt                                          # venv/conda
    

    Or search "ComfyUI-MakkiTools" in ComfyUI Manager, then restart ComfyUI so the new packages are importable.

    CategoryMakkiTools

    Inputs (5)

    NameTypeDefaultDescription
    query_textSTRINGText to translate 要翻译的文本
    translatorCOMBOalibabaTranslation service to use 要使用的翻译服务
    from_languageCOMBOautoSource language (auto for automatic detection) 源语言(auto为自动检测)
    to_languageCOMBOenglish(en)Target language 目标语言
    if_use_preaccelerationBOOLEANfalseEnable pre-acceleration for faster translation 启用预加速以提高翻译速度

    Outputs (1)

    NameTypeDescription
    STRINGSTRING