Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion custom-nodes/help_page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ description: "How to create rich documentation for your custom nodes"

Custom nodes can include rich markdown documentation that will be displayed in the UI instead of the generic node description. This provides users with detailed information about your node's functionality, parameters, and usage examples.

If you have already added tooltips for each parameter in the node definition, this basic information can be directly accessed via the node documentation panel.
No additional node documentation needs to be added, and you can refer to the related implementation of [ContextWindowsManualNode](https://github.com/comfyanonymous/ComfyUI/blob/master/comfy_extras/nodes_context_windows.py#L7)

## Setup

To add documentation for your nodes:
To add documentation for your nodes or multi-language support documentation:

1. Create a `docs` folder inside your `WEB_DIRECTORY`
2. Add markdown files named after your nodes (the names of your nodes are the dictionary keys in the `NODE_CLASS_MAPPINGS` dictionary used to register the nodes):
Expand Down
217 changes: 217 additions & 0 deletions custom-nodes/i18n.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
---
title: "ComfyUI Custom Nodes i18n Support"
description: "Learn how to add multi-language support for ComfyUI custom nodes"
sidebarTitle: "i18n Support"
---

import SupportedLanguages from '/snippets/interface/supported-languages.mdx'

If you want to add support for multiple languages, you can refer to this document to learn how to implement multi-language support.

<SupportedLanguages />


Custom node i18n demo: [comfyui-wiki/ComfyUI-i18n-demo](https://github.com/comfyui-wiki/ComfyUI-i18n-demo)

## Directory Structure

Create a `locales` folder under your custom node, which supports multiple types of translation files:

```bash
your_custom_node/
├── __init__.py
├── your_node.py
└── locales/ # i18n support folder
├── en/ # English translations (recommended as the base)
│ ├── main.json # General English translation content
│ ├── nodeDefs.json # English node definition translations
│ ├── settings.json # Optional: settings interface translations
│ └── commands.json # Optional: command translations
├── zh/ # Chinese translation files
│ ├── nodeDefs.json # Chinese node definition translations
│ ├── main.json # General Chinese translation content
│ ├── settings.json # Chinese settings interface translations
│ └── commands.json # Chinese command translations
├──...

```

## nodeDefs.json - Node Definition Translation

For example, here is a Python definition example of an [i18n-demo](https://github.com/comfyui-wiki/ComfyUI-i18n-demo) node:

```python
class I18nTextProcessor:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"text": ("STRING", {
"multiline": True,
"default": "Hello World!",
"tooltip": "The original text content to be processed"
}),
"operation": (["uppercase", "lowercase", "reverse", "add_prefix"], {
"default": "uppercase",
"tooltip": "The text processing operation to be executed"
}),
"count": ("INT", {
"default": 1,
"min": 1,
"max": 10,
"step": 1,
"tooltip": "The number of times to repeat the operation"
}),
},
"optional": {
"prefix": ("STRING", {
"default": "[I18N] ",
"multiline": False,
"tooltip": "The prefix to add to the text"
}),
}
}

RETURN_TYPES = ("STRING",)
RETURN_NAMES = ("processed_text",)
FUNCTION = "process_text"
CATEGORY = "I18n Demo"
DESCRIPTION = "A simple i18n demo node that demonstrates text processing with internationalization support"

def process_text(self, text, operation, count, prefix=""):
try:
result = text

for _ in range(count):
if operation == "uppercase":
result = result.upper()
elif operation == "lowercase":
result = result.lower()
elif operation == "reverse":
result = result[::-1]
elif operation == "add_prefix":
result = prefix + result

return (result,)
except Exception as e:
print(f"I18nTextProcessor error: {e}")
return (f"Error: {str(e)}",)
```

Then the corresponding localized support nodeDefs.json file content should include:

```json
{
"I18nTextProcessor": {
"display_name": "I18n Text Processor",
"description": "A simple i18n demo node that demonstrates text processing with internationalization support",
"inputs": {
"text": {
"name": "Text Input",
"tooltip": "The original text content to be processed"
},
"operation": {
"name": "Operation Type",
"tooltip": "The text processing operation to be executed",
"options": {
"uppercase": "To Uppercase",
"lowercase": "To Lowercase",
"reverse": "Reverse Text",
"add_prefix": "Add Prefix"
}
},
"count": {
"name": "Repeat Count",
"tooltip": "The number of times to repeat the operation"
},
"prefix": {
"name": "Prefix Text",
"tooltip": "The prefix to add to the text"
}
},
"outputs": {
"0": {
"name": "Processed Text",
"tooltip": "The final processed text result"
}
}
}
}
```

For the node output part, the corresponding output index is used instead of the output name, for example, the first output should be `0`, the second output should be `1`, and so on.

## Menu Settings

For example, in the i18n-demo custom node, we registered the following two menu settings:
```javascript
app.registerExtension({
name: "I18nDemo",
settings: [
{
id: "I18nDemo.EnableDebugMode",
category: ["I18nDemo","DebugMode"], // This matches the settingsCategories key in main.json
name: "Enable Debug Mode", // Will be overridden by translation
tooltip: "Show debug information in console for i18n demo nodes", // Will be overridden by translation
type: "boolean",
defaultValue: false,
experimental: true,
onChange: (value) => {
console.log("I18n Demo:", value ? "Debug mode enabled" : "Debug mode disabled");
}
},
{
id: "I18nDemo.DefaultTextOperation",
category: ["I18nDemo","DefaultTextOperation"], // This matches the settingsCategories key in main.json
name: "Default Text Operation", // Will be overridden by translation
tooltip: "Default operation for text processor node", // Will be overridden by translation
type: "combo",
options: ["uppercase", "lowercase", "reverse", "add_prefix"],
defaultValue: "uppercase",
experimental: true
}
],
})
```

If you need to add corresponding internationalization support, for the menu category, you need to add it in the `main.json` file:

```json
{
"settingsCategories": {
"I18nDemo": "I18n Demo",
"DebugMode": "Debug Mode",
"DefaultTextOperation": "Default Text Operation"
}
}
```

For the translation of the corresponding setting items, it is recommended to update them separately in the `settings.json` file, for example:

```json
{
"I18nDemo_EnableDebugMode": {
"name": "Enable Debug Mode",
"tooltip": "Show debug information in console for i18n demo nodes"
},
"I18nDemo_DefaultTextOperation": {
"name": "Default Text Operation",
"tooltip": "Default operation for text processor node",
"options": {
"uppercase": "Uppercase",
"lowercase": "Lowercase",
"reverse": "Reverse",
"add_prefix": "Add Prefix"
}
}
}
```

Note that the name of the corresponding translation key should replace the `.` in the original id with `_`, for example:
```
"I18nDemo.EnableDebugMode" -> "I18nDemo_EnableDebugMode"
```

## Custom Frontend Component Localization Support

[To be updated]
6 changes: 6 additions & 0 deletions custom-nodes/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ simple node that takes an image and inverts it.
![Unique Images Node](/images/invert_image_node.png)


Custom node examples:
- [cookiecutter-comfy-extension](https://github.com/Comfy-Org/cookiecutter-comfy-extension)
- [ComfyUI-React-Extension-Template](https://github.com/Comfy-Org/ComfyUI-React-Extension-Template)
- [ComfyUI_frontend_vue_basic](https://github.com/jtydhr88/ComfyUI_frontend_vue_basic)


## Client-Server Model

Comfy runs in a client-server model. The server, written in Python, handles all the real work: data-processing, models, image diffusion etc. The client, written in Javascript, handles the user interface.
Expand Down
30 changes: 19 additions & 11 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,6 @@
"pages": [
"custom-nodes/backend/server_overview",
"custom-nodes/backend/lifecycle",
"custom-nodes/backend/manager",
"custom-nodes/backend/datatypes",
"custom-nodes/backend/images_and_masks",
"custom-nodes/backend/more_on_inputs",
Expand All @@ -528,7 +527,8 @@
"custom-nodes/js/javascript_selection_toolbox",
"custom-nodes/js/javascript_commands_keybindings",
"custom-nodes/js/javascript_topbar_menu",
"custom-nodes/js/javascript_examples"
"custom-nodes/js/javascript_examples",
"custom-nodes/i18n"
]
},
"custom-nodes/help_page",
Expand Down Expand Up @@ -682,13 +682,13 @@
{
"group": "Image",
"pages": [
{
"group": "Qwen",
"pages": [
"zh-CN/tutorials/image/qwen/qwen-image",
"zh-CN/tutorials/image/qwen/qwen-image-edit"
]
},
{
"group": "Qwen",
"pages": [
"zh-CN/tutorials/image/qwen/qwen-image",
"zh-CN/tutorials/image/qwen/qwen-image-edit"
]
},
{
"group": "HiDream",
"pages": [
Expand Down Expand Up @@ -1063,7 +1063,6 @@
"pages": [
"zh-CN/custom-nodes/backend/server_overview",
"zh-CN/custom-nodes/backend/lifecycle",
"zh-CN/custom-nodes/backend/manager",
"zh-CN/custom-nodes/backend/datatypes",
"zh-CN/custom-nodes/backend/images_and_masks",
"zh-CN/custom-nodes/backend/more_on_inputs",
Expand All @@ -1090,7 +1089,8 @@
"zh-CN/custom-nodes/js/javascript_selection_toolbox",
"zh-CN/custom-nodes/js/javascript_commands_keybindings",
"zh-CN/custom-nodes/js/javascript_topbar_menu",
"zh-CN/custom-nodes/js/javascript_examples"
"zh-CN/custom-nodes/js/javascript_examples",
"zh-CN/custom-nodes/i18n"
]
},
"zh-CN/custom-nodes/help_page",
Expand Down Expand Up @@ -1211,6 +1211,14 @@
}
]
},
"contextual": {
"options": [
"copy",
"view",
"chatgpt",
"claude"
]
},
"integrations": {
"mixpanel": {
"projectToken": "3f02b60047411909a040d32a7bf2abe7"
Expand Down
9 changes: 7 additions & 2 deletions installation/install_custom_node.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ We don't recommend this installation method as it loses version control capabili
</Step>
</Steps>

{/* ## Troubleshooting
## Custom Node Resources

[To Be Updated] */}
In ComfyUI, besides the basic node extension functionality, custom nodes can also include the following additional resources:
- [Node Documentation](/custom-nodes/help_page): This feature supports all custom and basic nodes. You can use it to view node documentation, understand the purpose and usage of nodes, and contribute documentation via PRs to the author.
- [Custom Node Workflow Templates](/custom-nodes/workflow_templates): Workflow templates provided by node authors as example workflows, which can be browsed and loaded from the ComfyUI templates.
- [Multi-language Support](/custom-nodes/i18n)

If you are a custom node developer, you can add these resources to make your custom node more user-friendly.
11 changes: 11 additions & 0 deletions snippets/interface/supported-languages.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Currently, ComfyUI supports the following languages:

- English(en)
- Chinese (Simplified)(zh)
- Chinese (Traditional)(zh-TW)
- French(fr)
- Korean(ko)
- Russian(ru)
- Spanish(es)
- Japanese(ja)
- Arabic(ar)
10 changes: 10 additions & 0 deletions snippets/zh/interface/supported-languages.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
目前,ComfyUI 支持以下语言:

- 英语(en)
- 简体中文(zh)
- 繁体中文(zh-TW)
- 法语(fr)
- 韩语(ko)
- 俄语(ru)
- 西班牙语(es)
- 日语(ja)
4 changes: 3 additions & 1 deletion zh-CN/custom-nodes/help_page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ description: "如何为自定义节点创建帮助文档"

自定义节点可以使用 Markdown 来创建富文本文档,这些文档信息将在 UI 中显示,取代常见的节点描述信息。可以为用户提供关于节点功能、参数和使用示例的详细信息。

如果你在节点的相关描述信息中已经添加的每个参数的说明信息(tooltip),那么这些基础信息可以被节点文档面板直接获取,而无需再额外添加节点文档,你可以参考 [ContextWindowsManualNode](https://github.com/comfyanonymous/ComfyUI/blob/master/comfy_extras/nodes_context_windows.py#L7) 的相关实现。

## 设置

为你的节点添加节点文档
为你的节点添加节点文档或多语言支持的节点文档

1. 在你的 `WEB_DIRECTORY` 中创建 `docs` 文件夹
2. 添加以节点名称命名的 Markdown 文件(您的节点名称是用于注册节点的 `NODE_CLASS_MAPPINGS` 字典中的字典键):
Expand Down
Loading
Loading