> ## Documentation Index
> Fetch the complete documentation index at: https://docs.comfy.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Soporte de i18n para nodos personalizados de ComfyUI

> Aprende a agregar soporte multilingüe a los nodos personalizados de ComfyUI

Si quieres agregar soporte para varios idiomas, puedes consultar este documento para aprender a implementar la compatibilidad multilingüe.

Actualmente, ComfyUI es compatible con los siguientes idiomas:

* English（en）
* 中文（简体）（zh）
* 中文（繁體）（zh-TW）
* Français（fr）
* 한국어（ko）
* Русский（ru）
* Español（es）
* 日本語（ja）
* العربية（ar）
* Deutsch（de）
* עברית（he）
* Italiano（it）
* فارسی（fa）
* Português (BR)（pt-BR）
* Türkçe（tr）

Demostración de i18n para nodos personalizados: [comfyui-wiki/ComfyUI-i18n-demo](https://github.com/comfyui-wiki/ComfyUI-i18n-demo)

## Estructura de directorios

Crea una carpeta `locales` dentro de tu nodo personalizado, que admite varios tipos de archivos de traducción:

```bash theme={null}
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 - Traducción de definiciones de nodos

Por ejemplo, aquí tienes un ejemplo de definición en Python de un nodo [i18n-demo](https://github.com/comfyui-wiki/ComfyUI-i18n-demo):

```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)}",)
```

Después, el contenido correspondiente del archivo nodeDefs.json de soporte de localización debe incluir:

```json theme={null}
{
  "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"
      }
    }
  }
}
```

En la parte de salida del nodo, usa el índice de salida correspondiente en lugar del nombre de la salida: por ejemplo, la primera salida debe ser `0`, la segunda debe ser `1`, y así sucesivamente.

## Configuración de menús

Por ejemplo, en el nodo personalizado i18n-demo registramos las siguientes dos configuraciones de menú:

```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
        }
    ],
    })
```

Si necesitas añadir el soporte de internacionalización correspondiente, para la categoría del menú debes añadirlo en el archivo `main.json`:

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

Para la traducción de los elementos de configuración correspondientes, se recomienda actualizarlos por separado en el archivo `settings.json`, por ejemplo:

```json theme={null}
{
  "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"
    }
  }
}
```

Ten en cuenta que el nombre de la clave de traducción correspondiente debe reemplazar el `.` del id original por `_`, por ejemplo:

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

## Soporte de localización de componentes personalizados del frontend

\[Por actualizar]


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.