> ## Documentation Index
> Fetch the complete documentation index at: https://dripart-docs-recommend-assets-api.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# ComfyUI カスタムノードの多言語サポート

> ComfyUI カスタムノードに多言語サポートを追加する方法を学びます

複数の言語サポートを追加したい場合は、このドキュメントを参考にして多言語サポートの実装方法を確認できます。

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）

カスタムノード i18n デモ：[comfyui-wiki/ComfyUI-i18n-demo](https://github.com/comfyui-wiki/ComfyUI-i18n-demo)

## ディレクトリ構造

カスタムノードの下に `locales` フォルダを作成します。これは複数のタイプの翻訳ファイルをサポートしています。

```bash theme={null}
your_custom_node/
├── __init__.py
├── your_node.py
└── locales/                   # i18n サポートフォルダ
    ├── en/                    # 英語翻訳（基準として推奨）
    │   ├── main.json          # 一般的な英語翻訳コンテンツ
    │   ├── nodeDefs.json      # 英語ノード定義翻訳
    │   ├── settings.json      # オプション：設定インターフェース翻訳
    │   └── commands.json      # オプション：コマンド翻訳
    ├── zh/                    # 中国語翻訳ファイル
    │   ├── nodeDefs.json      # 中国語ノード定義翻訳
    │   ├── main.json          # 一般的な中国語翻訳コンテンツ
    │   ├── settings.json      # 中国語設定インターフェース翻訳
    │   └── commands.json      # 中国語コマンド翻訳
    ├──...

```

## nodeDefs.json - ノード定義翻訳

例として、[i18n-demo](https://github.com/comfyui-wiki/ComfyUI-i18n-demo) ノードの Python 定義例を以下に示します。

```python theme={null}
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)}",)
```

対応するローカライズサポートを含む nodeDefs.json ファイルの内容は以下の通りです。

```json theme={null}
{
  "I18nTextProcessor": {
    "display_name": "I18n テキストプロセッサ",
    "description": "国際化サポートを示すテキスト処理機能を持つシンプルな i18n デモノード",
    "inputs": {
      "text": {
        "name": "テキスト入力",
        "tooltip": "処理対象の元のテキストコンテンツ"
      },
      "operation": {
        "name": "操作タイプ",
        "tooltip": "実行するテキスト処理操作",
        "options": {
          "uppercase": "大文字化",
          "lowercase": "小文字化",
          "reverse": "テキスト逆順",
          "add_prefix": "プレフィックス追加"
        }
      },
      "count": {
        "name": "繰り返し回数",
        "tooltip": "操作を繰り返す回数"
      },
      "prefix": {
        "name": "プレフィックステキスト",
        "tooltip": "テキストに追加するプレフィックス"
      }
    },
    "outputs": {
      "0": {
        "name": "処理済みテキスト",
        "tooltip": "最終的な処理済みテキスト結果"
      }
    }
  }
}
```

ノード出力部分については、出力名ではなく対応する出力インデックスを使用します。例えば、最初の出力は `0`、2 番目の出力は `1` となります。

## メニュー設定

例として、i18n-demo カスタムノードでは以下の 2 つのメニュー設定を登録しています。

```javascript theme={null}
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
        }
    ],
    })
```

対応する国際化サポートを追加する場合、メニューカテゴリは `main.json` ファイルに追加する必要があります。

```json theme={null}
{
  "settingsCategories": {
    "I18nDemo": "I18n デモ",
    "DebugMode": "デバッグモード",
    "DefaultTextOperation": "デフォルトテキスト操作"
  }
}
```

対応する設定項目の翻訳は、`settings.json` ファイルで個別に更新することをお勧めします。

```json theme={null}
{
  "I18nDemo_EnableDebugMode": {
    "name": "デバッグモードを有効化",
    "tooltip": "i18n デモノードのデバッグ情報をコンソールに表示"
  },
  "I18nDemo_DefaultTextOperation": {
    "name": "デフォルトテキスト操作",
    "tooltip": "テキストプロセッサノードのデフォルト操作",
    "options": {
      "uppercase": "大文字",
      "lowercase": "小文字",
      "reverse": "逆順",
      "add_prefix": "プレフィックス追加"
    }
  }
}
```

対応する翻訳キーの名前は、元の id の `.` を `_` に置き換える必要があることに注意してください。例えば：

```
"I18nDemo.EnableDebugMode" -> "I18nDemo_EnableDebugMode"
```

## カスタムフロントエンドコンポーネントのローカライズサポート

\[更新予定]
